From 47d462174a706d82dd563fd61765364b121dc11b Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 2 Dec 2005 13:42:29 +0000 Subject: More fixes (mostly getting rid of excess spaces) --- win/tkWin3d.c | 8 +- win/tkWinButton.c | 39 ++- win/tkWinColor.c | 4 +- win/tkWinDraw.c | 4 +- win/tkWinEmbed.c | 53 +++-- win/tkWinInt.h | 4 +- win/tkWinKey.c | 155 ++++++------ win/tkWinPixmap.c | 40 ++-- win/tkWinScrlbr.c | 4 +- win/tkWinSendCom.c | 432 +++++++++++++++++---------------- win/tkWinSendCom.h | 33 +-- win/tkWinTest.c | 6 +- win/tkWinWindow.c | 37 +-- win/tkWinWm.c | 683 +++++++++++++++++++++++++++-------------------------- win/tkWinX.c | 456 ++++++++++++++++++----------------- 15 files changed, 1009 insertions(+), 949 deletions(-) diff --git a/win/tkWin3d.c b/win/tkWin3d.c index 8d1002b..a619082 100644 --- a/win/tkWin3d.c +++ b/win/tkWin3d.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWin3d.c,v 1.8 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWin3d.c,v 1.9 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -455,9 +455,9 @@ TkpGetShadows( lightColor.blue = (tmp1 > tmp2) ? tmp1 : tmp2; } - /* - * Allocate the light shadow color and its GC - */ + /* + * Allocate the light shadow color and its GC + */ borderPtr->lightColorPtr = Tk_GetColorByValue(tkwin, &lightColor); gcValues.foreground = borderPtr->lightColorPtr->pixel; diff --git a/win/tkWinButton.c b/win/tkWinButton.c index bd9768c..c7efb90 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinButton.c,v 1.27 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinButton.c,v 1.28 2005/12/02 13:42:29 dkf Exp $ */ #define OEMRESOURCE @@ -131,7 +131,7 @@ InitBoxes(void) LPBITMAPINFOHEADER newBitmap; DWORD size; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); hrsrc = FindResource(module, "buttons", RT_BITMAP); if (hrsrc) { @@ -146,14 +146,14 @@ InitBoxes(void) if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4) && !(tsdPtr->boxesPtr->biHeight % 2)) { size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount) - * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; + * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; newBitmap = (LPBITMAPINFOHEADER) ckalloc(size); memcpy(newBitmap, tsdPtr->boxesPtr, size); tsdPtr->boxesPtr = newBitmap; tsdPtr->boxWidth = tsdPtr->boxesPtr->biWidth / 4; tsdPtr->boxHeight = tsdPtr->boxesPtr->biHeight / 2; tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr) - + tsdPtr->boxesPtr->biSize); + + tsdPtr->boxesPtr->biSize); tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette) + ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD)); } else { @@ -187,7 +187,7 @@ TkpButtonSetDefaults( { int width; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->defWidth[0] == 0) { width = GetSystemMetrics(SM_CXEDGE); @@ -363,7 +363,7 @@ TkpDisplayButton( DWORD *boxesPalette; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); boxesPalette= tsdPtr->boxesPalette; butPtr->flags &= ~REDRAW_PENDING; @@ -722,10 +722,9 @@ TkpDisplayButton( border, TK_3D_FLAT_GC)); dc = TkWinGetDrawableDC(butPtr->display, pixmap, &state); - StretchDIBits(dc, x, y, tsdPtr->boxWidth, tsdPtr->boxHeight, - xSrc, ySrc, tsdPtr->boxWidth, tsdPtr->boxHeight, - tsdPtr->boxesBits, (LPBITMAPINFO) tsdPtr->boxesPtr, - DIB_RGB_COLORS, SRCCOPY); + StretchDIBits(dc, x, y, tsdPtr->boxWidth, tsdPtr->boxHeight, xSrc, + ySrc, tsdPtr->boxWidth, tsdPtr->boxHeight, tsdPtr->boxesBits, + (LPBITMAPINFO) tsdPtr->boxesPtr, DIB_RGB_COLORS, SRCCOPY); TkWinReleaseDrawableDC(pixmap, dc, &state); } @@ -1118,16 +1117,16 @@ TkpComputeButtonGeometry( height = imgHeight; } } else { - /* + /* * No image. May or may not be text. May or may not be compound. */ - /* + /* * butPtr->width is in characters. We need to allow for that many * characters on the face, not in the over-all button width */ - if (butPtr->width > 0) { + if (butPtr->width > 0) { width = butPtr->width * avgWidth; } @@ -1170,14 +1169,14 @@ TkpComputeButtonGeometry( if (butPtr->indicatorOn) { butPtr->indicatorDiameter = tsdPtr->boxHeight; - /* - * Make sure we can see the whole indicator, even if the text or - * image is very small. - */ + /* + * Make sure we can see the whole indicator, even if the text or + * image is very small. + */ - if (height < butPtr->indicatorDiameter) { - height = butPtr->indicatorDiameter; - } + if (height < butPtr->indicatorDiameter) { + height = butPtr->indicatorDiameter; + } /* * There is no rule for space between the indicator and the text diff --git a/win/tkWinColor.c b/win/tkWinColor.c index ce2f75e..911a4d1 100644 --- a/win/tkWinColor.c +++ b/win/tkWinColor.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinColor.c,v 1.9 2005/12/02 00:29:59 dkf Exp $ + * RCS: @(#) $Id: tkWinColor.c,v 1.10 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -105,7 +105,7 @@ FindSystemColor( { int l, u, r, i; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Count the number of elements in the color array if we haven't done so diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index cf97f8f..d351a0f 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinDraw.c,v 1.16 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinDraw.c,v 1.17 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -234,7 +234,7 @@ ConvertPoints( RECT *bbox) /* Bounding box of points. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); int i; /* diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 9b5150c..71f8116 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinEmbed.c,v 1.29 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinEmbed.c,v 1.30 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -74,12 +74,12 @@ TkWinCleanupContainerList(void) { Container *nextPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (; tsdPtr->firstContainerPtr != (Container *) NULL; tsdPtr->firstContainerPtr = nextPtr) { - nextPtr = tsdPtr->firstContainerPtr->nextPtr; - ckfree((char *) tsdPtr->firstContainerPtr); + nextPtr = tsdPtr->firstContainerPtr->nextPtr; + ckfree((char *) tsdPtr->firstContainerPtr); } tsdPtr->firstContainerPtr = (Container *) NULL; } @@ -241,7 +241,7 @@ TkpUseWindow( int id; HWND hwnd; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* if (winPtr->window != None) { @@ -258,7 +258,7 @@ TkpUseWindow( } if (Tcl_GetInt(interp, string, &id) != TCL_OK) { - return TCL_ERROR; + return TCL_ERROR; } hwnd = (HWND) id; if ((HWND)winPtr->privatePtr == hwnd) { @@ -272,33 +272,34 @@ TkpUseWindow( */ if (!IsWindow(hwnd)) { - if (interp != NULL) { + if (interp != NULL) { Tcl_AppendResult(interp, "window \"", string, "\" doesn't exist", NULL); - } - return TCL_ERROR; + } + return TCL_ERROR; } id = SendMessage(hwnd, TK_INFO, TK_CONTAINER_VERIFY, 0); if (id == (long)hwnd) { - if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) { + if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) { Tcl_AppendResult(interp, "The container is already in use", NULL); return TCL_ERROR; } } else if (id == -(long)hwnd) { - Tcl_AppendResult(interp, "the window to use is not a Tk container", + Tcl_AppendResult(interp, "the window to use is not a Tk container", NULL); return TCL_ERROR; } else { - /* - * Proceed if the user decide to do so because it can be a legacy - * container application. However we may have to return a TCL_ERROR in - * order to avoid bug 1096074 in future. - */ - - char msg[256]; - sprintf(msg, "Unable to get information of window \"%s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); - if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", + /* + * Proceed if the user decide to do so because it can be a legacy + * container application. However we may have to return a TCL_ERROR in + * order to avoid bug 1096074 in future. + */ + + char msg[256]; + + sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC); return TCL_ERROR; @@ -353,7 +354,7 @@ TkpMakeContainer( TkWindow *winPtr = (TkWindow *) tkwin; Container *containerPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Register the window as a container so that, for example, we can find @@ -446,7 +447,7 @@ TkWinEmbeddedEventProc( int result = 1; Container *containerPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Find the Container structure associated with the parent window. @@ -920,7 +921,7 @@ TkpGetOtherWindow( { Container *containerPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { @@ -957,7 +958,7 @@ Tk_GetEmbeddedHWnd( { Container *containerPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { @@ -992,7 +993,7 @@ Tk_GetEmbeddedMenuHWND( TkWindow *winPtr = (TkWindow*)tkwin; Container *containerPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { @@ -1091,7 +1092,7 @@ EmbedWindowDeleted( { Container *containerPtr, *prevPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Find the Container structure for this window work. Delete the diff --git a/win/tkWinInt.h b/win/tkWinInt.h index eb04dec..9b5c36a 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinInt.h,v 1.25 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinInt.h,v 1.26 2005/12/02 13:42:29 dkf Exp $ */ #ifndef _TKWININT @@ -141,7 +141,7 @@ extern int tkpWinBltModes[]; #define TK_3D_DARK2 TK_3D_DARK_GC+2 /* - * Internal procedures used by more than one source file. + * Internal functions used by more than one source file. */ #include "tkIntPlatDecls.h" diff --git a/win/tkWinKey.c b/win/tkWinKey.c index f43c6e9..22e5dd9 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -6,10 +6,10 @@ * * Copyright (c) 1995 Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinKey.c,v 1.15 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinKey.c,v 1.16 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -24,6 +24,7 @@ */ #define MAX_KEYCODE 145 /* VK_SCROLL is the last entry in our table below */ + static KeySym keymap[] = { NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab, @@ -58,7 +59,7 @@ static KeySym keymap[] = { }; /* - * Prototypes for local procedures defined in this file: + * Prototypes for local functions defined in this file: */ static KeySym KeycodeToKeysym(unsigned int keycode, @@ -93,27 +94,27 @@ TkpGetString( Tcl_DStringInit(dsPtr); if (eventPtr->xkey.send_event == -1) { - if (eventPtr->xkey.nbytes > 0) { + if (eventPtr->xkey.nbytes > 0) { Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(), - eventPtr->xkey.trans_chars, eventPtr->xkey.nbytes, dsPtr); - } + eventPtr->xkey.trans_chars, eventPtr->xkey.nbytes, dsPtr); + } } else if (eventPtr->xkey.send_event == -2) { - /* - * Special case for win2000 multi-lingal IME input. - * xkey.trans_chars[] already contains a UNICODE char. - */ + /* + * Special case for win2000 multi-lingal IME input. + * xkey.trans_chars[] already contains a UNICODE char. + */ - int unichar; - char buf[TCL_UTF_MAX]; - int len; + int unichar; + char buf[TCL_UTF_MAX]; + int len; - unichar = (eventPtr->xkey.trans_chars[1] & 0xff); - unichar <<= 8; - unichar |= (eventPtr->xkey.trans_chars[0] & 0xff); + unichar = (eventPtr->xkey.trans_chars[1] & 0xff); + unichar <<= 8; + unichar |= (eventPtr->xkey.trans_chars[0] & 0xff); - len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); + len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); - Tcl_DStringAppend(dsPtr, buf, len); + Tcl_DStringAppend(dsPtr, buf, len); } else { /* * This is an event generated from generic code. It has no nchars or @@ -202,27 +203,31 @@ KeycodeToKeysym( if (noascii || keycode == VK_CAPITAL || keycode == VK_SCROLL || keycode == VK_NUMLOCK) { - goto skipToAscii; + goto skipToAscii; } /* * Use MapVirtualKey() to detect some dead keys. */ - if (MapVirtualKey(keycode, 2) > 0x7fffUL) - return XK_Multi_key; + if (MapVirtualKey(keycode, 2) > 0x7fffUL) { + return XK_Multi_key; + } /* * Set up a keyboard with correct modifiers */ memset(keys, 0, 256); - if (state & ShiftMask) - keys[VK_SHIFT] = 0x80; - if (state & ControlMask) + if (state & ShiftMask) { + keys[VK_SHIFT] = 0x80; + } + if (state & ControlMask) { keys[VK_CONTROL] = 0x80; - if (state & Mod2Mask) + } + if (state & Mod2Mask) { keys[VK_MENU] = 0x80; + } /* * Make sure all lock button info is correct so we don't mess up the @@ -242,46 +247,47 @@ KeycodeToKeysym( result = ToAscii(keycode, scancode, keys, (LPWORD) buf, 0); if (result < 0) { - /* - * Win95/98: This was a dead char, which is now remembered by the - * keyboard. Call ToAscii() again to forget it. - * WinNT: This was a dead char, overwriting any previously remembered - * key. Calling ToAscii() again does not affect anything. - */ - - ToAscii(keycode, scancode, keys, (LPWORD) buf, 0); - return XK_Multi_key; + /* + * Win95/98: This was a dead char, which is now remembered by the + * keyboard. Call ToAscii() again to forget it. + * WinNT: This was a dead char, overwriting any previously remembered + * key. Calling ToAscii() again does not affect anything. + */ + + ToAscii(keycode, scancode, keys, (LPWORD) buf, 0); + return XK_Multi_key; } + if (result == 2) { - /* - * This was a dead char, and there were one previously remembered by - * the keyboard. Call ToAscii() again with proper parameters to - * restore it. - * + /* + * This was a dead char, and there were one previously remembered by + * the keyboard. Call ToAscii() again with proper parameters to + * restore it. + * * Get information about the old char */ - deadkey = VkKeyScan(buf[0]); - shift = deadkey >> 8; - deadkey &= 255; - scancode = MapVirtualKey(deadkey, 0); + deadkey = VkKeyScan(buf[0]); + shift = deadkey >> 8; + deadkey &= 255; + scancode = MapVirtualKey(deadkey, 0); - /* + /* * Set up a keyboard with proper modifier keys */ - memset(keys, 0, 256); - if (shift & 1) { - keys[VK_SHIFT] = 0x80; + memset(keys, 0, 256); + if (shift & 1) { + keys[VK_SHIFT] = 0x80; } - if (shift & 2) { - keys[VK_CONTROL] = 0x80; + if (shift & 2) { + keys[VK_CONTROL] = 0x80; } - if (shift & 4) { - keys[VK_MENU] = 0x80; + if (shift & 4) { + keys[VK_MENU] = 0x80; } - ToAscii(deadkey, scancode, keys, (LPWORD) buf, 0); - return XK_Multi_key; + ToAscii(deadkey, scancode, keys, (LPWORD) buf, 0); + return XK_Multi_key; } /* @@ -301,7 +307,7 @@ KeycodeToKeysym( * considered "more correct" (although the correctness would be dependant * on whether you believe that ToAscii is doing the right thing in that * case); however, this would break backwards compatibility, and worse, it - * would limit application programmers -- they would effectively be unable + * would limit application programmers; they would effectively be unable * to bind to on Windows. We therefore chose instead * to return XK_BackSpace (handled here by letting the code "fall-through" * to the return statement below, which works because the keycode for this @@ -332,6 +338,7 @@ KeycodeToKeysym( * appropriate keycode. Otherwise, we fall through and rely on the * keymap table to hold the correct keysym value. */ + case VK_CONTROL: if (GetKeyState(VK_RCONTROL) & 0x80) { return XK_Control_R; @@ -394,12 +401,12 @@ TkpGetKeySym( */ if ((sym == NoSymbol) && ((state & ControlMask) || (state & Mod2Mask))) { - state &= ~(ControlMask | Mod2Mask); - sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0); + state &= ~(ControlMask | Mod2Mask); + sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0); } if ((sym == NoSymbol) && (state & ShiftMask)) { - state &= ~ShiftMask; - sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0); + state &= ~ShiftMask; + sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0); } return sym; } @@ -409,9 +416,9 @@ TkpGetKeySym( * * TkpInitKeymapInfo -- * - * This procedure is invoked to scan keymap information to recompute - * stuff that's important for binding, such as the modifier key (if any) - * that corresponds to "mode switch". + * This function is invoked to scan keymap information to recompute stuff + * that's important for binding, such as the modifier key (if any) that + * corresponds to "mode switch". * * Results: * None. @@ -521,7 +528,7 @@ TkpInitKeymapInfo( arraySize *= 2; new = (KeyCode *) ckalloc((unsigned) (arraySize * sizeof(KeyCode))); - memcpy((VOID *) new, (VOID *) dispPtr->modKeyCodes, + memcpy((void *) new, (void *) dispPtr->modKeyCodes, (dispPtr->numModKeyCodes * sizeof(KeyCode))); ckfree((char *) dispPtr->modKeyCodes); dispPtr->modKeyCodes = new; @@ -551,7 +558,7 @@ TkpSetKeycodeAndState( eventPtr->xkey.keycode = 0; if (keySym == NoSymbol) { - return; + return; } /* @@ -562,21 +569,21 @@ TkpSetKeycodeAndState( for (i = 0; i <= MAX_KEYCODE; i++) { if (keymap[i] == keySym) { - eventPtr->xkey.keycode = i; - return; + eventPtr->xkey.keycode = i; + return; } } if (keySym >= 0x20) { result = VkKeyScan((char) keySym); if (result != -1) { - shift = result >> 8; - if (shift & 1) - eventPtr->xkey.state |= ShiftMask; - if (shift & 2) - eventPtr->xkey.state |= ControlMask; - if (shift & 4) - eventPtr->xkey.state |= Mod2Mask; - eventPtr->xkey.keycode = (KeyCode) (result & 0xff); + shift = result >> 8; + if (shift & 1) + eventPtr->xkey.state |= ShiftMask; + if (shift & 2) + eventPtr->xkey.state |= ControlMask; + if (shift & 4) + eventPtr->xkey.state |= Mod2Mask; + eventPtr->xkey.keycode = (KeyCode) (result & 0xff); } } } diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index 73882b1..ee07e7c 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinPixmap.c,v 1.5 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinPixmap.c,v 1.6 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -169,30 +169,30 @@ XGetGeometry( BITMAPINFO info; if (twdPtr->bitmap.handle == NULL) { - Tcl_Panic("XGetGeometry: invalid pixmap"); - } - dc = GetDC(NULL); - info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - info.bmiHeader.biBitCount = 0; - if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info, - DIB_RGB_COLORS)) { - Tcl_Panic("XGetGeometry: unable to get bitmap size"); - } - ReleaseDC(NULL, dc); + Tcl_Panic("XGetGeometry: invalid pixmap"); + } + dc = GetDC(NULL); + info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info.bmiHeader.biBitCount = 0; + if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info, + DIB_RGB_COLORS)) { + Tcl_Panic("XGetGeometry: unable to get bitmap size"); + } + ReleaseDC(NULL, dc); - *width_return = info.bmiHeader.biWidth; - *height_return = info.bmiHeader.biHeight; + *width_return = info.bmiHeader.biWidth; + *height_return = info.bmiHeader.biHeight; } else if (twdPtr->type == TWD_WINDOW) { RECT rect; - if (twdPtr->window.handle == NULL) { - Tcl_Panic("XGetGeometry: invalid window"); - } - GetClientRect(twdPtr->window.handle, &rect); - *width_return = rect.right - rect.left; - *height_return = rect.bottom - rect.top; + if (twdPtr->window.handle == NULL) { + Tcl_Panic("XGetGeometry: invalid window"); + } + GetClientRect(twdPtr->window.handle, &rect); + *width_return = rect.right - rect.left; + *height_return = rect.bottom - rect.top; } else { - Tcl_Panic("XGetGeometry: invalid window"); + Tcl_Panic("XGetGeometry: invalid window"); } return 1; } diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index e76a299..742c941 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinScrlbr.c,v 1.11 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinScrlbr.c,v 1.12 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -116,7 +116,7 @@ TkpCreateScrollbar( TkWindow *winPtr = (TkWindow *)tkwin; if (!initialized) { - Tcl_MutexLock(&winScrlbrMutex); + Tcl_MutexLock(&winScrlbrMutex); UpdateScrollbarMetrics(); initialized = 1; Tcl_MutexUnlock(&winScrlbrMutex); diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c index 28dc960..8b54d51 100644 --- a/win/tkWinSendCom.c +++ b/win/tkWinSendCom.c @@ -1,23 +1,24 @@ -/* - * tkWinSend.c -- +/* + * tkWinSendCom.c -- * - * This file provides procedures that implement the Windows "send" - * command, allowing commands to be passed from interpreter - * to interpreter. + * This file provides support functions that implement the Windows "send" + * command using COM interfaces, allowing commands to be passed from + * interpreter to interpreter. See also tkWinSend.c, where most of the + * interesting functions are. * - * We implement a COM class for use in registering Tcl interpreters - * with the system's Running Object Table. - * This class implements an IDispatch interface with the following method: - * Send(String cmd) As String - * In other words the Send methods takes a string and evaluates this in - * the Tcl interpreter. The result is returned as another string. + * We implement a COM class for use in registering Tcl interpreters with the + * system's Running Object Table. This class implements an IDispatch interface + * with the following method: + * Send(String cmd) As String + * In other words the Send methods takes a string and evaluates this in the + * Tcl interpreter. The result is returned as another string. * * Copyright (C) 2002 Pat Thoyts * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinSendCom.c,v 1.5 2005/10/14 11:59:19 patthoyts Exp $ + * RCS: @(#) $Id: tkWinSendCom.c,v 1.6 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinSendCom.h" @@ -26,45 +27,44 @@ * ---------------------------------------------------------------------- * Non-public prototypes. * - * These are the interface methods for IUnknown, IDispatch and - * ISupportErrorInfo. + * These are the interface methods for IUnknown, IDispatch and + * ISupportErrorInfo. * * ---------------------------------------------------------------------- */ -static void TkWinSendCom_Destroy(LPDISPATCH pdisp); - -static STDMETHODIMP WinSendCom_QueryInterface(IDispatch *This, - REFIID riid, void **ppvObject); -static STDMETHODIMP_(ULONG) WinSendCom_AddRef(IDispatch *This); -static STDMETHODIMP_(ULONG) WinSendCom_Release(IDispatch *This); -static STDMETHODIMP WinSendCom_GetTypeInfoCount(IDispatch *This, - UINT *pctinfo); -static STDMETHODIMP WinSendCom_GetTypeInfo(IDispatch *This, UINT iTInfo, - LCID lcid, ITypeInfo **ppTI); -static STDMETHODIMP WinSendCom_GetIDsOfNames(IDispatch *This, REFIID riid, - LPOLESTR *rgszNames, - UINT cNames, LCID lcid, - DISPID *rgDispId); -static STDMETHODIMP WinSendCom_Invoke(IDispatch *This, DISPID dispidMember, - REFIID riid, LCID lcid, WORD wFlags, - DISPPARAMS *pDispParams, - VARIANT *pvarResult, - EXCEPINFO *pExcepInfo, - UINT *puArgErr); - -static STDMETHODIMP ISupportErrorInfo_QueryInterface(ISupportErrorInfo *This, - REFIID riid, void **ppvObject); -static STDMETHODIMP_(ULONG) ISupportErrorInfo_AddRef(ISupportErrorInfo *This); -static STDMETHODIMP_(ULONG) ISupportErrorInfo_Release(ISupportErrorInfo *This); -static STDMETHODIMP ISupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *This, - REFIID riid); - -static HRESULT Send(TkWinSendCom* obj, VARIANT vCmd, VARIANT* pvResult, - EXCEPINFO* pExcepInfo, UINT *puArgErr); -static HRESULT Async(TkWinSendCom* obj, VARIANT Cmd, - EXCEPINFO *pExcepInfo, UINT *puArgErr); +static void TkWinSendCom_Destroy(LPDISPATCH pdisp); +static STDMETHODIMP WinSendCom_QueryInterface(IDispatch *This, + REFIID riid, void **ppvObject); +static STDMETHODIMP_(ULONG) WinSendCom_AddRef(IDispatch *This); +static STDMETHODIMP_(ULONG) WinSendCom_Release(IDispatch *This); +static STDMETHODIMP WinSendCom_GetTypeInfoCount(IDispatch *This, + UINT *pctinfo); +static STDMETHODIMP WinSendCom_GetTypeInfo(IDispatch *This, UINT iTInfo, + LCID lcid, ITypeInfo **ppTI); +static STDMETHODIMP WinSendCom_GetIDsOfNames(IDispatch *This, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, + DISPID *rgDispId); +static STDMETHODIMP WinSendCom_Invoke(IDispatch *This, DISPID dispidMember, + REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS *pDispParams, VARIANT *pvarResult, + EXCEPINFO *pExcepInfo, UINT *puArgErr); +static STDMETHODIMP ISupportErrorInfo_QueryInterface( + ISupportErrorInfo *This, REFIID riid, + void **ppvObject); +static STDMETHODIMP_(ULONG) ISupportErrorInfo_AddRef( + ISupportErrorInfo *This); +static STDMETHODIMP_(ULONG) ISupportErrorInfo_Release( + ISupportErrorInfo *This); +static STDMETHODIMP ISupportErrorInfo_InterfaceSupportsErrorInfo( + ISupportErrorInfo *This, REFIID riid); +static HRESULT Send(TkWinSendCom *obj, VARIANT vCmd, + VARIANT *pvResult, EXCEPINFO *pExcepInfo, + UINT *puArgErr); +static HRESULT Async(TkWinSendCom *obj, VARIANT Cmd, + EXCEPINFO *pExcepInfo, UINT *puArgErr); + /* * ---------------------------------------------------------------------- * @@ -77,49 +77,55 @@ static HRESULT Async(TkWinSendCom* obj, VARIANT Cmd, */ HRESULT -TkWinSendCom_CreateInstance(Tcl_Interp *interp, REFIID riid, void **ppv) +TkWinSendCom_CreateInstance( + Tcl_Interp *interp, + REFIID riid, + void **ppv) { - /* construct v-tables for each interface */ + /* + * Construct v-tables for each interface. + */ + static IDispatchVtbl vtbl = { - WinSendCom_QueryInterface, - WinSendCom_AddRef, - WinSendCom_Release, - WinSendCom_GetTypeInfoCount, - WinSendCom_GetTypeInfo, - WinSendCom_GetIDsOfNames, - WinSendCom_Invoke, + WinSendCom_QueryInterface, + WinSendCom_AddRef, + WinSendCom_Release, + WinSendCom_GetTypeInfoCount, + WinSendCom_GetTypeInfo, + WinSendCom_GetIDsOfNames, + WinSendCom_Invoke, }; - static ISupportErrorInfoVtbl vtbl2 = { - ISupportErrorInfo_QueryInterface, - ISupportErrorInfo_AddRef, - ISupportErrorInfo_Release, - ISupportErrorInfo_InterfaceSupportsErrorInfo, + ISupportErrorInfo_QueryInterface, + ISupportErrorInfo_AddRef, + ISupportErrorInfo_Release, + ISupportErrorInfo_InterfaceSupportsErrorInfo, }; - HRESULT hr = S_OK; TkWinSendCom *obj = NULL; - + /* - * This had probably better always be globally visible memory so - * we shall use the COM Task allocator. + * This had probably better always be globally visible memory so we shall + * use the COM Task allocator. */ - - obj = (TkWinSendCom*)CoTaskMemAlloc(sizeof(TkWinSendCom)); + + obj = (TkWinSendCom *) CoTaskMemAlloc(sizeof(TkWinSendCom)); if (obj == NULL) { - *ppv = NULL; - hr = E_OUTOFMEMORY; + *ppv = NULL; + hr = E_OUTOFMEMORY; } else { - obj->lpVtbl = &vtbl; - obj->lpVtbl2 = &vtbl2; - obj->refcount = 0; - obj->interp = interp; - - /* lock the interp? Tcl_AddRef/Retain? */ - - hr = obj->lpVtbl->QueryInterface((IDispatch*)obj, riid, ppv); + obj->lpVtbl = &vtbl; + obj->lpVtbl2 = &vtbl2; + obj->refcount = 0; + obj->interp = interp; + + /* + * lock the interp? Tcl_AddRef/Retain? + */ + + hr = obj->lpVtbl->QueryInterface((IDispatch*)obj, riid, ppv); } - + return hr; } @@ -139,7 +145,8 @@ TkWinSendCom_CreateInstance(Tcl_Interp *interp, REFIID riid, void **ppv) * ---------------------------------------------------------------------- */ static void -TkWinSendCom_Destroy(LPDISPATCH pdisp) +TkWinSendCom_Destroy( + LPDISPATCH pdisp) { CoTaskMemFree((void*)pdisp); } @@ -150,139 +157,145 @@ TkWinSendCom_Destroy(LPDISPATCH pdisp) * IDispatch -- * * The IDispatch interface implements the 'late-binding' COM methods - * typically used by scripting COM clients. - * The Invoke method is the most important one. + * typically used by scripting COM clients. The Invoke method is the most + * important one. * * ---------------------------------------------------------------------- */ static STDMETHODIMP WinSendCom_QueryInterface( - IDispatch *This, - REFIID riid, - void **ppvObject) + IDispatch *This, + REFIID riid, + void **ppvObject) { HRESULT hr = E_NOINTERFACE; TkWinSendCom *this = (TkWinSendCom*)This; *ppvObject = NULL; - + if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0 || memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) { - *ppvObject = (void**)this; - this->lpVtbl->AddRef(This); - hr = S_OK; + *ppvObject = (void**)this; + this->lpVtbl->AddRef(This); + hr = S_OK; } else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) { - *ppvObject = (void**)(this + 1); - this->lpVtbl2->AddRef((ISupportErrorInfo*)(this + 1)); - hr = S_OK; + *ppvObject = (void**)(this + 1); + this->lpVtbl2->AddRef((ISupportErrorInfo*)(this + 1)); + hr = S_OK; } return hr; } static STDMETHODIMP_(ULONG) -WinSendCom_AddRef(IDispatch *This) +WinSendCom_AddRef( + IDispatch *This) { TkWinSendCom *this = (TkWinSendCom*)This; + return InterlockedIncrement(&this->refcount); } static STDMETHODIMP_(ULONG) -WinSendCom_Release(IDispatch *This) +WinSendCom_Release( + IDispatch *This) { long r = 0; TkWinSendCom *this = (TkWinSendCom*)This; + if ((r = InterlockedDecrement(&this->refcount)) == 0) { - TkWinSendCom_Destroy(This); + TkWinSendCom_Destroy(This); } return r; } static STDMETHODIMP -WinSendCom_GetTypeInfoCount(IDispatch *This, UINT *pctinfo) +WinSendCom_GetTypeInfoCount( + IDispatch *This, + UINT *pctinfo) { HRESULT hr = E_POINTER; + if (pctinfo != NULL) { - *pctinfo = 0; - hr = S_OK; + *pctinfo = 0; + hr = S_OK; } return hr; } -static STDMETHODIMP +static STDMETHODIMP WinSendCom_GetTypeInfo( - IDispatch *This, - UINT iTInfo, - LCID lcid, - ITypeInfo **ppTI) + IDispatch *This, + UINT iTInfo, + LCID lcid, + ITypeInfo **ppTI) { HRESULT hr = E_POINTER; - if (ppTI) - { - *ppTI = NULL; - hr = E_NOTIMPL; + + if (ppTI) { + *ppTI = NULL; + hr = E_NOTIMPL; } return hr; } -static STDMETHODIMP +static STDMETHODIMP WinSendCom_GetIDsOfNames( - IDispatch *This, - REFIID riid, - LPOLESTR *rgszNames, - UINT cNames, - LCID lcid, - DISPID *rgDispId) + IDispatch *This, + REFIID riid, + LPOLESTR *rgszNames, + UINT cNames, + LCID lcid, + DISPID *rgDispId) { HRESULT hr = E_POINTER; - if (rgDispId) - { - hr = DISP_E_UNKNOWNNAME; - if (_wcsicmp(*rgszNames, L"Send") == 0) - *rgDispId = TKWINSENDCOM_DISPID_SEND, hr = S_OK; - else if (_wcsicmp(*rgszNames, L"Async") == 0) - *rgDispId = TKWINSENDCOM_DISPID_ASYNC, hr = S_OK; + + if (rgDispId) { + hr = DISP_E_UNKNOWNNAME; + if (_wcsicmp(*rgszNames, L"Send") == 0) { + *rgDispId = TKWINSENDCOM_DISPID_SEND, hr = S_OK; + } else if (_wcsicmp(*rgszNames, L"Async") == 0) { + *rgDispId = TKWINSENDCOM_DISPID_ASYNC, hr = S_OK; + } } return hr; } -static STDMETHODIMP +static STDMETHODIMP WinSendCom_Invoke( - IDispatch *This, - DISPID dispidMember, - REFIID riid, - LCID lcid, - WORD wFlags, - DISPPARAMS *pDispParams, - VARIANT *pvarResult, - EXCEPINFO *pExcepInfo, - UINT *puArgErr) + IDispatch *This, + DISPID dispidMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pvarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) { HRESULT hr = DISP_E_MEMBERNOTFOUND; TkWinSendCom *this = (TkWinSendCom*)This; - + switch (dispidMember) { - case TKWINSENDCOM_DISPID_SEND: - if (wFlags | DISPATCH_METHOD) { - if (pDispParams->cArgs != 1) { - hr = DISP_E_BADPARAMCOUNT; - } else { - hr = Send(this, pDispParams->rgvarg[0], - pvarResult, pExcepInfo, puArgErr); - } + case TKWINSENDCOM_DISPID_SEND: + if (wFlags | DISPATCH_METHOD) { + if (pDispParams->cArgs != 1) { + hr = DISP_E_BADPARAMCOUNT; + } else { + hr = Send(this, pDispParams->rgvarg[0], pvarResult, + pExcepInfo, puArgErr); } - break; - - case TKWINSENDCOM_DISPID_ASYNC: - if (wFlags | DISPATCH_METHOD) { - if (pDispParams->cArgs != 1) { - hr = DISP_E_BADPARAMCOUNT; - } else { - hr = Async(this, pDispParams->rgvarg[0], - pExcepInfo, puArgErr); - } + } + break; + + case TKWINSENDCOM_DISPID_ASYNC: + if (wFlags | DISPATCH_METHOD) { + if (pDispParams->cArgs != 1) { + hr = DISP_E_BADPARAMCOUNT; + } else { + hr = Async(this, pDispParams->rgvarg[0], pExcepInfo, puArgErr); } - break; - + } + break; } return hr; } @@ -292,37 +305,45 @@ WinSendCom_Invoke( * * ISupportErrorInfo -- * - * This interface provides rich error information to COM clients. - * Used by VB and scripting COM clients. + * This interface provides rich error information to COM clients. Used by + * VB and scripting COM clients. * * ---------------------------------------------------------------------- */ -static STDMETHODIMP -ISupportErrorInfo_QueryInterface(ISupportErrorInfo *This, - REFIID riid, void **ppvObject) +static STDMETHODIMP +ISupportErrorInfo_QueryInterface( + ISupportErrorInfo *This, + REFIID riid, + void **ppvObject) { TkWinSendCom *this = (TkWinSendCom*)(This - 1); + return this->lpVtbl->QueryInterface((IDispatch*)this, riid, ppvObject); } static STDMETHODIMP_(ULONG) -ISupportErrorInfo_AddRef(ISupportErrorInfo *This) +ISupportErrorInfo_AddRef( + ISupportErrorInfo *This) { TkWinSendCom *this = (TkWinSendCom*)(This - 1); + return InterlockedIncrement(&this->refcount); } static STDMETHODIMP_(ULONG) -ISupportErrorInfo_Release(ISupportErrorInfo *This) +ISupportErrorInfo_Release( + ISupportErrorInfo *This) { TkWinSendCom *this = (TkWinSendCom*)(This - 1); + return this->lpVtbl->Release((IDispatch*)this); } static STDMETHODIMP -ISupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *This, - REFIID riid) +ISupportErrorInfo_InterfaceSupportsErrorInfo( + ISupportErrorInfo *This, + REFIID riid) { /*TkWinSendCom *this = (TkWinSendCom*)(This - 1);*/ return S_OK; /* or S_FALSE */ @@ -345,33 +366,36 @@ ISupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *This, */ static HRESULT -Async(TkWinSendCom* obj, VARIANT Cmd, EXCEPINFO *pExcepInfo, UINT *puArgErr) +Async( + TkWinSendCom *obj, + VARIANT Cmd, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) { HRESULT hr = S_OK; int result = TCL_OK; VARIANT vCmd; - + VariantInit(&vCmd); - + hr = VariantChangeType(&vCmd, &Cmd, 0, VT_BSTR); if (FAILED(hr)) { - Tcl_SetStringObj(Tcl_GetObjResult(obj->interp), + Tcl_SetStringObj(Tcl_GetObjResult(obj->interp), "invalid args: Async(command)", -1); - SetExcepInfo(obj->interp, pExcepInfo); - hr = DISP_E_EXCEPTION; + SetExcepInfo(obj->interp, pExcepInfo); + hr = DISP_E_EXCEPTION; } - - + if (SUCCEEDED(hr)) { - if (obj->interp) { - Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal, + if (obj->interp) { + Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal, (int)SysStringLen(vCmd.bstrVal)); - result = TkWinSend_QueueCommand(obj->interp, scriptPtr); - } + result = TkWinSend_QueueCommand(obj->interp, scriptPtr); + } } - + VariantClear(&vCmd); - + return hr; } @@ -380,13 +404,13 @@ Async(TkWinSendCom* obj, VARIANT Cmd, EXCEPINFO *pExcepInfo, UINT *puArgErr) * * Send -- * - * Evaluates the string in the assigned interpreter. If the result - * is a valid address then set it to the result returned by the - * evaluation. Tcl exceptions are converted into COM exceptions. + * Evaluates the string in the assigned interpreter. If the result is a + * valid address then set it to the result returned by the evaluation. + * Tcl exceptions are converted into COM exceptions. * * Results: - * A standard COM HRESULT is returned. The Tcl result is set as - * the method calls result. + * A standard COM HRESULT is returned. The Tcl result is set as the + * method calls result. * * Side effects: * The interpreters state and result will be modified. @@ -395,34 +419,46 @@ Async(TkWinSendCom* obj, VARIANT Cmd, EXCEPINFO *pExcepInfo, UINT *puArgErr) */ static HRESULT -Send(TkWinSendCom* obj, VARIANT vCmd, - VARIANT* pvResult, EXCEPINFO* pExcepInfo, UINT *puArgErr) +Send( + TkWinSendCom *obj, + VARIANT vCmd, + VARIANT *pvResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) { HRESULT hr = S_OK; int result = TCL_OK; VARIANT v; - + VariantInit(&v); hr = VariantChangeType(&v, &vCmd, 0, VT_BSTR); if (SUCCEEDED(hr)) { - if (obj->interp) { - Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(v.bstrVal, + if (obj->interp) { + Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(v.bstrVal, (int)SysStringLen(v.bstrVal)); - - result = Tcl_EvalObjEx(obj->interp, scriptPtr, + + result = Tcl_EvalObjEx(obj->interp, scriptPtr, TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL); - if (pvResult) { - VariantInit(pvResult); - pvResult->vt = VT_BSTR; - pvResult->bstrVal = SysAllocString(Tcl_GetUnicode(Tcl_GetObjResult(obj->interp))); - } - if (result == TCL_ERROR) { - hr = DISP_E_EXCEPTION; - SetExcepInfo(obj->interp, pExcepInfo); - } - } - VariantClear(&v); + if (pvResult) { + VariantInit(pvResult); + pvResult->vt = VT_BSTR; + pvResult->bstrVal = SysAllocString( + Tcl_GetUnicode(Tcl_GetObjResult(obj->interp))); + } + if (result == TCL_ERROR) { + hr = DISP_E_EXCEPTION; + SetExcepInfo(obj->interp, pExcepInfo); + } + } + VariantClear(&v); } return hr; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/win/tkWinSendCom.h b/win/tkWinSendCom.h index 2344431..2992232 100644 --- a/win/tkWinSendCom.h +++ b/win/tkWinSendCom.h @@ -1,16 +1,16 @@ -/* +/* * tkWinSendCom.h -- * * This file provides procedures that implement the Windows "send" - * command, allowing commands to be passed from interpreter - * to interpreter. + * command, allowing commands to be passed from interpreter to + * interpreter. * * Copyright (C) 2002 Pat Thoyts * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinSendCom.h,v 1.2 2005/10/14 11:59:19 patthoyts Exp $ + * RCS: @(#) $Id: tkWinSendCom.h,v 1.3 2005/12/02 13:42:29 dkf Exp $ */ #ifndef _tkWinSendCom_h_INCLUDE @@ -26,14 +26,14 @@ #endif /* - * TkWinSendCom CoClass structure + * TkWinSendCom CoClass structure */ typedef struct { - IDispatchVtbl *lpVtbl; + IDispatchVtbl *lpVtbl; ISupportErrorInfoVtbl *lpVtbl2; - long refcount; - Tcl_Interp *interp; + long refcount; + Tcl_Interp *interp; } TkWinSendCom; /* @@ -47,16 +47,17 @@ typedef struct { * TkWinSendCom public functions */ -HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, - REFIID riid, void **ppv); -int TkWinSend_QueueCommand(Tcl_Interp *interp, Tcl_Obj *cmdPtr); -void SetExcepInfo(Tcl_Interp* interp, EXCEPINFO *pExcepInfo); +HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp, + REFIID riid, void **ppv); +int TkWinSend_QueueCommand(Tcl_Interp *interp, + Tcl_Obj *cmdPtr); +void SetExcepInfo(Tcl_Interp *interp, + EXCEPINFO *pExcepInfo); #endif /* _tkWinSendCom_h_INCLUDE */ /* * Local Variables: - * mode: c - * indent-tabs-mode: nil + * mode: c * End: */ diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 600f490..958ac6d 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinTest.c,v 1.9 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinTest.c,v 1.10 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -56,7 +56,7 @@ TkplatformtestInit( Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateCommand(interp, "testwinevent", TestwineventCmd, - (ClientData) Tk_MainWindow(interp), NULL); + (ClientData) Tk_MainWindow(interp), NULL); return TCL_OK; } @@ -138,7 +138,7 @@ AppendSystemError( } sprintf(id, "%ld", error); - Tcl_SetErrorCode(interp, "WINDOWS", id, msg, (char *) NULL); + Tcl_SetErrorCode(interp, "WINDOWS", id, msg, NULL); Tcl_AppendToObj(resultPtr, msg, length); if (length != 0) { diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index dccfd92..2f6ab18 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -9,20 +9,20 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWindow.c,v 1.11 2005/12/02 00:19:04 dkf Exp $ + * RCS: @(#) $Id: tkWinWindow.c,v 1.12 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" typedef struct ThreadSpecificData { - int initialized; /* 0 means table below needs initializing. */ - Tcl_HashTable windowTable; /* The windowTable maps from HWND to - * Tk_Window handles. */ + int initialized; /* 0 means table below needs initializing. */ + Tcl_HashTable windowTable; /* The windowTable maps from HWND to Tk_Window + * handles. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; /* - * Forward declarations for procedures defined in this file: + * Forward declarations for functions defined in this file: */ static void NotifyVisibility(XEvent *eventPtr, TkWindow *winPtr); @@ -32,8 +32,8 @@ static void NotifyVisibility(XEvent *eventPtr, TkWindow *winPtr); * * Tk_AttachHWND -- * - * This function binds an HWND and a reflection procedure to the - * specified Tk_Window. + * This function binds an HWND and a reflection function to the specified + * Tk_Window. * * Results: * Returns an X Window that encapsulates the HWND. @@ -54,7 +54,7 @@ Tk_AttachHWND( Tcl_HashEntry *entryPtr; TkWinDrawable *twdPtr = (TkWinDrawable *) Tk_WindowId(tkwin); ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { Tcl_InitHashTable(&tsdPtr->windowTable, TCL_ONE_WORD_KEYS); @@ -110,13 +110,13 @@ Tk_HWNDToWindow( { Tcl_HashEntry *entryPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { Tcl_InitHashTable(&tsdPtr->windowTable, TCL_ONE_WORD_KEYS); tsdPtr->initialized = 1; } - entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char*)hwnd); + entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char *) hwnd); if (entryPtr != NULL) { return (Tk_Window) Tcl_GetHashValue(entryPtr); } @@ -217,7 +217,7 @@ TkpScanWindowId( if ( #ifdef _WIN64 - (sscanf(string, "0x%p", &number) != 1) && + (sscanf(string, "0x%p", &number) != 1) && #endif Tcl_GetInt(interp, string, (int *) &number) != TCL_OK) { return TCL_ERROR; @@ -306,7 +306,7 @@ XDestroyWindow( TkWindow *winPtr = TkWinGetWinPtr(w); HWND hwnd = Tk_GetHWND(w); ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); display->request++; @@ -372,7 +372,7 @@ XMapWindow( if (!(winPtr->flags & TK_TOP_HIERARCHY)) { for (parentPtr = winPtr->parentPtr; ; - parentPtr = parentPtr->parentPtr) { + parentPtr = parentPtr->parentPtr) { if ((parentPtr == NULL) || !(parentPtr->flags & TK_MAPPED)) { return; } @@ -535,7 +535,7 @@ void XMoveWindow( Display *display, Window w, - int x, int y) + int x, int y) /* Position relative to parent */ { TkWindow *winPtr = TkWinGetWinPtr(w); @@ -625,7 +625,7 @@ void XConfigureWindow( Display *display, Window w, - unsigned int value_mask, + unsigned int valueMask, XWindowChanges *values) { TkWindow *winPtr = TkWinGetWinPtr(w); @@ -637,7 +637,7 @@ XConfigureWindow( * Change the shape and/or position of the window. */ - if (value_mask & (CWX|CWY|CWWidth|CWHeight)) { + if (valueMask & (CWX|CWY|CWWidth|CWHeight)) { MoveWindow(hwnd, winPtr->changes.x, winPtr->changes.y, winPtr->changes.width, winPtr->changes.height, TRUE); } @@ -646,9 +646,10 @@ XConfigureWindow( * Change the stacking order of the window. */ - if (value_mask & CWStackMode) { + if (valueMask & CWStackMode) { HWND sibling; - if ((value_mask & CWSibling) && (values->sibling != None)) { + + if ((valueMask & CWSibling) && (values->sibling != None)) { sibling = Tk_GetHWND(values->sibling); } else { sibling = NULL; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 36d7dd0..cb423b7 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.105 2005/12/02 00:29:59 dkf Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.106 2005/12/02 13:42:29 dkf Exp $ */ #include "tkWinInt.h" @@ -143,10 +143,10 @@ typedef struct { */ typedef struct WinIconInstance { - int refCount; /* Number of instances that share this data - * structure. */ + int refCount; /* Number of instances that share this data + * structure. */ BlockOfIconImagesPtr iconBlock; - /* Pointer to icon resource data for image */ + /* Pointer to icon resource data for image */ } WinIconInstance; typedef struct WinIconInstance *WinIconPtr; @@ -200,7 +200,7 @@ typedef struct TkWmInfo { * step). */ struct { int x; /* numerator */ - int y; /* denominator */ + int y; /* denominator */ } minAspect, maxAspect; /* Min/max aspect ratios for window. */ int reqGridWidth, reqGridHeight; /* The dimensions of the window (in grid @@ -267,8 +267,8 @@ typedef struct TkWmInfo { * property, or NULL. */ int flags; /* Miscellaneous flags, defined below. */ int numTransients; /* Number of transients on this window */ - WinIconPtr iconPtr; /* Pointer to titlebar icon structure for this - * window, or NULL. */ + WinIconPtr iconPtr; /* Pointer to titlebar icon structure for this + * window, or NULL. */ struct TkWmInfo *nextPtr; /* Next in list of all top-level windows. */ } WmInfo; @@ -442,107 +442,107 @@ static void WmWaitVisibilityOrMapProc(ClientData clientData, XEvent *eventPtr); static BlockOfIconImagesPtr ReadIconOrCursorFromFile(Tcl_Interp *interp, Tcl_Obj* fileName, BOOL isIcon); -static WinIconPtr ReadIconFromFile(Tcl_Interp *interp, +static WinIconPtr ReadIconFromFile(Tcl_Interp *interp, Tcl_Obj *fileName); -static WinIconPtr GetIconFromPixmap(Display *dsPtr, Pixmap pixmap); -static int ReadICOHeader(Tcl_Channel channel); -static BOOL AdjustIconImagePointers(LPICONIMAGE lpImage); -static HICON MakeIconOrCursorFromResource(LPICONIMAGE lpIcon, +static WinIconPtr GetIconFromPixmap(Display *dsPtr, Pixmap pixmap); +static int ReadICOHeader(Tcl_Channel channel); +static BOOL AdjustIconImagePointers(LPICONIMAGE lpImage); +static HICON MakeIconOrCursorFromResource(LPICONIMAGE lpIcon, BOOL isIcon); -static HICON GetIcon(WinIconPtr titlebaricon, int icon_size); -static int WinSetIcon(Tcl_Interp *interp, +static HICON GetIcon(WinIconPtr titlebaricon, int icon_size); +static int WinSetIcon(Tcl_Interp *interp, WinIconPtr titlebaricon, Tk_Window tkw); -static void FreeIconBlock(BlockOfIconImagesPtr lpIR); -static void DecrIconRefCount(WinIconPtr titlebaricon); +static void FreeIconBlock(BlockOfIconImagesPtr lpIR); +static void DecrIconRefCount(WinIconPtr titlebaricon); -static int WmAspectCmd(Tk_Window tkwin, +static int WmAspectCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmAttributesCmd(Tk_Window tkwin, +static int WmAttributesCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmClientCmd(Tk_Window tkwin, +static int WmClientCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmColormapwindowsCmd(Tk_Window tkwin, +static int WmColormapwindowsCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmCommandCmd(Tk_Window tkwin, +static int WmCommandCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmDeiconifyCmd(Tk_Window tkwin, +static int WmDeiconifyCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmFocusmodelCmd(Tk_Window tkwin, +static int WmFocusmodelCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmFrameCmd(Tk_Window tkwin, +static int WmFrameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmGeometryCmd(Tk_Window tkwin, +static int WmGeometryCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmGridCmd(Tk_Window tkwin, +static int WmGridCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmGroupCmd(Tk_Window tkwin, +static int WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconbitmapCmd(Tk_Window tkwin, +static int WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconifyCmd(Tk_Window tkwin, +static int WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconmaskCmd(Tk_Window tkwin, +static int WmIconmaskCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconnameCmd(Tk_Window tkwin, +static int WmIconnameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconphotoCmd(Tk_Window tkwin, +static int WmIconphotoCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconpositionCmd(Tk_Window tkwin, +static int WmIconpositionCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmIconwindowCmd(Tk_Window tkwin, +static int WmIconwindowCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmMaxsizeCmd(Tk_Window tkwin, +static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmMinsizeCmd(Tk_Window tkwin, +static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmOverrideredirectCmd(Tk_Window tkwin, +static int WmOverrideredirectCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmPositionfromCmd(Tk_Window tkwin, +static int WmPositionfromCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmProtocolCmd(Tk_Window tkwin, +static int WmProtocolCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmResizableCmd(Tk_Window tkwin, +static int WmResizableCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmSizefromCmd(Tk_Window tkwin, +static int WmSizefromCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmStackorderCmd(Tk_Window tkwin, +static int WmStackorderCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmStateCmd(Tk_Window tkwin, +static int WmStateCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmTitleCmd(Tk_Window tkwin, +static int WmTitleCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmTransientCmd(Tk_Window tkwin, +static int WmTransientCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); -static int WmWithdrawCmd(Tk_Window tkwin, +static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); @@ -551,7 +551,7 @@ static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); * Used in BytesPerLine */ -#define WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2) +#define WIDTHBYTES(bits) ((((bits) + 31)>>5)<<2) /* *---------------------------------------------------------------------- @@ -562,7 +562,7 @@ static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); * lpbi - pointer to the CF_DIB memory block. Used by titlebar icon code. * * Results: - * WORD - Number of entries in the color table. + * WORD - Number of entries in the color table. * *---------------------------------------------------------------------- */ @@ -576,8 +576,9 @@ DIBNumColors( dwClrUsed = ((LPBITMAPINFOHEADER) lpbi)->biClrUsed; - if (dwClrUsed) + if (dwClrUsed) { return (WORD) dwClrUsed; + } wBitCount = ((LPBITMAPINFOHEADER) lpbi)->biBitCount; @@ -632,9 +633,9 @@ PaletteSize( static LPSTR FindDIBBits( - LPSTR lpbi) + LPSTR lpbi) { - return lpbi + *(LPDWORD)lpbi + PaletteSize(lpbi); + return lpbi + *(LPDWORD)lpbi + PaletteSize(lpbi); } /* @@ -723,7 +724,7 @@ AdjustIconImagePointers( */ lpImage->lpAND = lpImage->lpXOR + (lpImage->Height* - BytesPerLine((LPBITMAPINFOHEADER)(lpImage->lpbi))); + BytesPerLine((LPBITMAPINFOHEADER)(lpImage->lpbi))); return TRUE; } @@ -765,9 +766,9 @@ MakeIconOrCursorFromResource( HMODULE hMod = GetModuleHandleA("USER32.DLL"); initinfo = 1; - if (hMod){ - pfnCreateIconFromResourceEx = GetProcAddress(hMod, - "CreateIconFromResourceEx"); + if (hMod) { + pfnCreateIconFromResourceEx = + GetProcAddress(hMod, "CreateIconFromResourceEx"); } } @@ -1002,6 +1003,7 @@ InitWindowClass( * *---------------------------------------------------------------------- */ + static void InitWm(void) { @@ -1045,7 +1047,7 @@ WinSetIcon( int application = 0; if (tkw == NULL) { - tkw = Tk_MainWindow(interp); + tkw = Tk_MainWindow(interp); application = 1; } @@ -1057,7 +1059,11 @@ WinSetIcon( if (Tk_WindowId(tkw) == None) { Tk_MakeWindowExist(tkw); } - /* We must get the window's wrapper, not the window itself */ + + /* + * We must get the window's wrapper, not the window itself. + */ + wmPtr = ((TkWindow*)tkw)->wmInfoPtr; hwnd = wmPtr->wrapper; @@ -1137,6 +1143,7 @@ WinSetIcon( (void) InitWindowClass(NULL); } + /* * The following code is exercised if you do * @@ -1204,6 +1211,7 @@ WinSetIcon( * *---------------------------------------------------------------------- */ + HICON TkWinGetIcon( Tk_Window tkwin, @@ -1308,91 +1316,91 @@ ReadIconFromFile( Tcl_Obj *fileName) { WinIconPtr titlebaricon = NULL; + BlockOfIconImagesPtr lpIR; if (0 /* If we already have an icon for this filename */) { titlebaricon = NULL; /* Get the real value from a lookup */ titlebaricon->refCount++; return titlebaricon; - } else { - /* - * First check if it is a .ico file. - */ + } - BlockOfIconImagesPtr lpIR; - lpIR = ReadIconOrCursorFromFile(interp, fileName, TRUE); + /* + * First check if it is a .ico file. + */ - /* - * Then see if we can ask the shell for the icon for this file. We - * want both the regular and small icons so that the Alt-Tab (task- - * switching) display uses the right icon. - */ + lpIR = ReadIconOrCursorFromFile(interp, fileName, TRUE); - if (lpIR == NULL && shgetfileinfoProc != NULL) { - SHFILEINFO sfiSM; - Tcl_DString ds, ds2; - DWORD *res; - CONST char *file; + /* + * Then see if we can ask the shell for the icon for this file. We + * want both the regular and small icons so that the Alt-Tab (task- + * switching) display uses the right icon. + */ - file = Tcl_TranslateFileName(interp, Tcl_GetString(fileName), &ds); - if (file == NULL) { - return NULL; - } - Tcl_UtfToExternalDString(NULL, file, -1, &ds2); - Tcl_DStringFree(&ds); - res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfiSM, - sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON); + if (lpIR == NULL && shgetfileinfoProc != NULL) { + SHFILEINFO sfiSM; + Tcl_DString ds, ds2; + DWORD *res; + CONST char *file; - if (res != 0) { - SHFILEINFO sfi; - int size; + file = Tcl_TranslateFileName(interp, Tcl_GetString(fileName), &ds); + if (file == NULL) { + return NULL; + } + Tcl_UtfToExternalDString(NULL, file, -1, &ds2); + Tcl_DStringFree(&ds); + res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfiSM, + sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON); - Tcl_ResetResult(interp); - res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfi, - sizeof(SHFILEINFO), SHGFI_ICON); + if (res != 0) { + SHFILEINFO sfi; + int size; - /* - * Account for extra icon, if necessary. - */ + Tcl_ResetResult(interp); + res = (*shgetfileinfoProc)(Tcl_DStringValue(&ds2), 0, &sfi, + sizeof(SHFILEINFO), SHGFI_ICON); - size = sizeof(BlockOfIconImages) - + ((res != 0) ? sizeof(ICONIMAGE) : 0); - lpIR = (BlockOfIconImagesPtr) ckalloc(size); - if (lpIR == NULL) { - if (res != 0) { - DestroyIcon(sfi.hIcon); - } - DestroyIcon(sfiSM.hIcon); - Tcl_DStringFree(&ds2); - return NULL; + /* + * Account for extra icon, if necessary. + */ + + size = sizeof(BlockOfIconImages) + + ((res != 0) ? sizeof(ICONIMAGE) : 0); + lpIR = (BlockOfIconImagesPtr) ckalloc(size); + if (lpIR == NULL) { + if (res != 0) { + DestroyIcon(sfi.hIcon); } - ZeroMemory(lpIR, size); + DestroyIcon(sfiSM.hIcon); + Tcl_DStringFree(&ds2); + return NULL; + } + ZeroMemory(lpIR, size); - lpIR->nNumImages = ((res != 0) ? 2 : 1); - lpIR->IconImages[0].Width = 16; - lpIR->IconImages[0].Height = 16; - lpIR->IconImages[0].Colors = 4; - lpIR->IconImages[0].hIcon = sfiSM.hIcon; + lpIR->nNumImages = ((res != 0) ? 2 : 1); + lpIR->IconImages[0].Width = 16; + lpIR->IconImages[0].Height = 16; + lpIR->IconImages[0].Colors = 4; + lpIR->IconImages[0].hIcon = sfiSM.hIcon; - /* - * All other IconImages fields are ignored. - */ + /* + * All other IconImages fields are ignored. + */ - if (res != 0) { - lpIR->IconImages[1].Width = 32; - lpIR->IconImages[1].Height = 32; - lpIR->IconImages[1].Colors = 4; - lpIR->IconImages[1].hIcon = sfi.hIcon; - } + if (res != 0) { + lpIR->IconImages[1].Width = 32; + lpIR->IconImages[1].Height = 32; + lpIR->IconImages[1].Colors = 4; + lpIR->IconImages[1].hIcon = sfi.hIcon; } - Tcl_DStringFree(&ds2); - } - if (lpIR != NULL) { - titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance)); - titlebaricon->iconBlock = lpIR; - titlebaricon->refCount = 1; } - return titlebaricon; + Tcl_DStringFree(&ds2); + } + if (lpIR != NULL) { + titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance)); + titlebaricon->iconBlock = lpIR; + titlebaricon->refCount = 1; } + return titlebaricon; } /* @@ -1433,61 +1441,60 @@ GetIconFromPixmap( Pixmap pixmap) { WinIconPtr titlebaricon = NULL; - TkWinDrawable* twdPtr = (TkWinDrawable*) pixmap; + TkWinDrawable *twdPtr = (TkWinDrawable*) pixmap; + BlockOfIconImagesPtr lpIR; + ICONINFO icon; + HICON hIcon; + int width, height; if (twdPtr == NULL) { - return NULL; + return NULL; } if (0 /* If we already have an icon for this pixmap */) { titlebaricon = NULL; /* Get the real value from a lookup */ titlebaricon->refCount++; return titlebaricon; - } else { - BlockOfIconImagesPtr lpIR; - ICONINFO icon; - HICON hIcon; - int width, height; + } - Tk_SizeOfBitmap(dsPtr, pixmap, &width, &height); + Tk_SizeOfBitmap(dsPtr, pixmap, &width, &height); - icon.fIcon = TRUE; - icon.xHotspot = 0; - icon.yHotspot = 0; - icon.hbmMask = twdPtr->bitmap.handle; - icon.hbmColor = twdPtr->bitmap.handle; + icon.fIcon = TRUE; + icon.xHotspot = 0; + icon.yHotspot = 0; + icon.hbmMask = twdPtr->bitmap.handle; + icon.hbmColor = twdPtr->bitmap.handle; - hIcon = CreateIconIndirect(&icon); - if (hIcon == NULL) { - return NULL; - } + hIcon = CreateIconIndirect(&icon); + if (hIcon == NULL) { + return NULL; + } - lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages)); - if (lpIR == NULL) { - DestroyIcon(hIcon); - return NULL; - } + lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages)); + if (lpIR == NULL) { + DestroyIcon(hIcon); + return NULL; + } - lpIR->nNumImages = 1; - lpIR->IconImages[0].Width = width; - lpIR->IconImages[0].Height = height; - lpIR->IconImages[0].Colors = 1 << twdPtr->bitmap.depth; - lpIR->IconImages[0].hIcon = hIcon; + lpIR->nNumImages = 1; + lpIR->IconImages[0].Width = width; + lpIR->IconImages[0].Height = height; + lpIR->IconImages[0].Colors = 1 << twdPtr->bitmap.depth; + lpIR->IconImages[0].hIcon = hIcon; - /* - * These fields are ignored. - */ + /* + * These fields are ignored. + */ - lpIR->IconImages[0].lpBits = 0; - lpIR->IconImages[0].dwNumBytes = 0; - lpIR->IconImages[0].lpXOR = 0; - lpIR->IconImages[0].lpAND = 0; + lpIR->IconImages[0].lpBits = 0; + lpIR->IconImages[0].dwNumBytes = 0; + lpIR->IconImages[0].lpXOR = 0; + lpIR->IconImages[0].lpAND = 0; - titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance)); - titlebaricon->iconBlock = lpIR; - titlebaricon->refCount = 1; - return titlebaricon; - } + titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance)); + titlebaricon->iconBlock = lpIR; + titlebaricon->refCount = 1; + return titlebaricon; } /* @@ -1583,7 +1590,7 @@ GetIcon( BlockOfIconImagesPtr lpIR; if (titlebaricon == NULL) { - return NULL; + return NULL; } lpIR = titlebaricon->iconBlock; @@ -1599,8 +1606,8 @@ GetIcon( */ if ((lpIR->IconImages[i].Height == size) - && (lpIR->IconImages[i].Width == size) - && (lpIR->IconImages[i].Colors >= 4)) { + && (lpIR->IconImages[i].Width == size) + && (lpIR->IconImages[i].Colors >= 4)) { return lpIR->IconImages[i].hIcon; } } @@ -1626,7 +1633,7 @@ TclWinReadCursorFromFile( lpIR = ReadIconOrCursorFromFile(interp, fileName, FALSE); if (lpIR == NULL) { - return NULL; + return NULL; } if (lpIR->nNumImages >= 1) { res = CopyImage(lpIR->IconImages[0].hIcon, IMAGE_CURSOR,0,0,0); @@ -1647,7 +1654,7 @@ TclWinReadCursorFromFile( * Returns an icon resource, if found, else NULL. * * Side effects: - * May leave error messages in the Tcl interpreter. + * May leave error messages in the Tcl interpreter. * *---------------------------------------------------------------------- */ @@ -1690,20 +1697,15 @@ ReadIconOrCursorFromFile( */ lpIR = (BlockOfIconImagesPtr) ckalloc(sizeof(BlockOfIconImages)); - if (lpIR == NULL) { - Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL); - Tcl_Close(NULL, channel); - return NULL; - } /* * Read in the header */ - if ((lpIR->nNumImages = ReadICOHeader( channel )) == -1) { - Tcl_AppendResult(interp,"Invalid file header",(char*)NULL); + if ((lpIR->nNumImages = ReadICOHeader(channel)) == -1) { + Tcl_AppendResult(interp, "Invalid file header", NULL); Tcl_Close(NULL, channel); - ckfree((char*) lpIR ); + ckfree((char*) lpIR); return NULL; } @@ -1711,38 +1713,27 @@ ReadIconOrCursorFromFile( * Adjust the size of the struct to account for the images. */ - lpNew = (BlockOfIconImagesPtr) ckrealloc((char*)lpIR, - sizeof(BlockOfIconImages) + ((lpIR->nNumImages-1)*sizeof(ICONIMAGE))); - if (lpNew == NULL) { - Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL); - Tcl_Close(NULL, channel); - ckfree( (char*)lpIR ); - return NULL; - } - lpIR = lpNew; + lpIR = (BlockOfIconImagesPtr) ckrealloc((char*) lpIR, + sizeof(BlockOfIconImages) + + ((lpIR->nNumImages - 1) * sizeof(ICONIMAGE))); /* * Allocate enough memory for the icon directory entries. */ lpIDE = (LPICONDIRENTRY) ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY)); - if (lpIDE == NULL) { - Tcl_AppendResult(interp,"Error allocating memory",(char*)NULL); - Tcl_Close(NULL, channel); - ckfree( (char*)lpIR ); - return NULL; - } /* * Read in the icon directory entries. */ - dwBytesRead = Tcl_Read(channel, (char*)lpIDE, + dwBytesRead = Tcl_Read(channel, (char*) lpIDE, lpIR->nNumImages * sizeof(ICONDIRENTRY)); - if (dwBytesRead != lpIR->nNumImages * sizeof( ICONDIRENTRY )) { + if (dwBytesRead != lpIR->nNumImages * sizeof(ICONDIRENTRY)) { Tcl_AppendResult(interp, "Error reading file", NULL); Tcl_Close(NULL, channel); - ckfree((char*) lpIR); + ckfree((char *) lpIDE); + ckfree((char *) lpIR); return NULL; } @@ -1758,16 +1749,12 @@ ReadIconOrCursorFromFile( * Loop through and read in each image. */ - for( i = 0; i < lpIR->nNumImages; i++ ) { + for (i=0 ; inNumImages ; i++) { /* * Allocate memory for the resource. */ lpIR->IconImages[i].lpBits = (LPBYTE) ckalloc(lpIDE[i].dwBytesInRes); - if (lpIR->IconImages[i].lpBits == NULL) { - Tcl_AppendResult(interp, "Error allocating memory", NULL); - goto readError; - } lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes; /* @@ -1800,14 +1787,14 @@ ReadIconOrCursorFromFile( goto readError; } lpIR->IconImages[i].hIcon = - MakeIconOrCursorFromResource(&(lpIR->IconImages[i]), isIcon); + MakeIconOrCursorFromResource(&(lpIR->IconImages[i]), isIcon); } /* * Clean up */ - ckfree((char*)lpIDE); + ckfree((char *) lpIDE); Tcl_Close(NULL, channel); if (lpIR == NULL){ Tcl_AppendResult(interp, "Reading of ", Tcl_GetString(fileName), @@ -1819,12 +1806,12 @@ ReadIconOrCursorFromFile( readError: Tcl_Close(NULL, channel); for (i = 0; i < lpIR->nNumImages; i++) { - if (lpIR->IconImages[i].lpBits != NULL) { - ckfree((char*) lpIR->IconImages[i].lpBits); + if (lpIR->IconImages[i].lpBits != NULL) { + ckfree((char *) lpIR->IconImages[i].lpBits); } } - ckfree((char*) lpIDE); - ckfree((char*) lpIR); + ckfree((char *) lpIDE); + ckfree((char *) lpIR); return NULL; } @@ -1849,7 +1836,7 @@ GetTopLevel( HWND hwnd) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * If this function is called before the CreateWindowEx call has @@ -1985,7 +1972,7 @@ TkWinWmCleanup( #ifdef USE_TCL_STUBS if (tclStubsPtr == NULL) { - return; + return; } #endif @@ -1995,10 +1982,10 @@ TkWinWmCleanup( initialized = 0; tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { - return; + return; } tsdPtr->initialized = 0; @@ -2132,7 +2119,7 @@ UpdateWrapper( Tcl_DString titleString, classString; int *childStateInfo = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->window == None) { /* @@ -2208,7 +2195,7 @@ UpdateWrapper( wmPtr->exStyle = EX_TOPLEVEL_STYLE; } - wmPtr->style |= wmPtr->styleConfig; + wmPtr->style |= wmPtr->styleConfig; wmPtr->exStyle |= wmPtr->exStyleConfig; if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) @@ -2255,7 +2242,7 @@ UpdateWrapper( tsdPtr->createWindow = winPtr; Tcl_WinUtfToTChar(((wmPtr->title != NULL) ? - wmPtr->title : winPtr->nameUid), -1, &titleString); + wmPtr->title : winPtr->nameUid), -1, &titleString); #ifndef TCL_THREADS /* @@ -2516,7 +2503,7 @@ TkWmMapWindow( { register WmInfo *wmPtr = winPtr->wmInfoPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { InitWm(); @@ -2528,7 +2515,7 @@ TkWmMapWindow( */ if (wmPtr->masterPtr != NULL && - !Tk_IsMapped(wmPtr->masterPtr)) { + !Tk_IsMapped(wmPtr->masterPtr)) { wmPtr->hints.initial_state = WithdrawnState; return; } @@ -2685,7 +2672,7 @@ TkpWmSetFullScreen( UpdateWrapper(winPtr); if (focusWinPtr = TkGetFocusWin(winPtr)) { - TkSetFocusWin(focusWinPtr, 1); + TkSetFocusWin(focusWinPtr, 1); } } } @@ -2771,8 +2758,8 @@ TkWmDeadWindow( if (wmPtr2->masterPtr == winPtr) { wmPtr->numTransients--; Tk_DeleteEventHandler((Tk_Window) wmPtr2->masterPtr, - VisibilityChangeMask|StructureNotifyMask, - WmWaitVisibilityOrMapProc, (ClientData) wmPtr2->winPtr); + VisibilityChangeMask|StructureNotifyMask, + WmWaitVisibilityOrMapProc, (ClientData) wmPtr2->winPtr); wmPtr2->masterPtr = NULL; if ((wmPtr2->wrapper != None) && !(wmPtr2->flags & (WM_NEVER_MAPPED))) { @@ -2781,7 +2768,7 @@ TkWmDeadWindow( } } if (wmPtr->numTransients != 0) - Tcl_Panic("numTransients should be 0"); + Tcl_Panic("numTransients should be 0"); if (wmPtr->title != NULL) { ckfree(wmPtr->title); @@ -2861,7 +2848,7 @@ TkWmDeadWindow( * is using this icon. */ - DecrIconRefCount(wmPtr->iconPtr); + DecrIconRefCount(wmPtr->iconPtr); } ckfree((char *) wmPtr); @@ -2928,19 +2915,19 @@ Tk_WmObjCmd( "iconify", "iconmask", "iconname", "iconphoto", "iconposition", "iconwindow", "maxsize", "minsize", "overrideredirect", - "positionfrom", "protocol", "resizable", "sizefrom", - "stackorder", "state", "title", "transient", + "positionfrom", "protocol", "resizable", "sizefrom", + "stackorder", "state", "title", "transient", "withdraw", NULL }; enum options { - WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS, + WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS, WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP, WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPHOTO, WMOPT_ICONPOSITION, WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, - WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, - WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, + WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RESIZABLE, WMOPT_SIZEFROM, + WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, WMOPT_WITHDRAW }; int index, length; @@ -3031,7 +3018,7 @@ Tk_WmObjCmd( case WMOPT_ICONNAME: return WmIconnameCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ICONPHOTO: - return WmIconphotoCmd(tkwin, winPtr, interp, objc, objv); + return WmIconphotoCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ICONPOSITION: return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv); case WMOPT_ICONWINDOW: @@ -3119,10 +3106,8 @@ WmAspectCmd( || (Tcl_GetIntFromObj(interp, objv[6], &denom2) != TCL_OK)) { return TCL_ERROR; } - if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || - (denom2 <= 0)) { - Tcl_SetResult(interp, "aspect number can't be <= 0", - TCL_STATIC); + if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) { + Tcl_SetResult(interp, "aspect number can't be <= 0", TCL_STATIC); return TCL_ERROR; } wmPtr->minAspect.x = numer1; @@ -3179,7 +3164,7 @@ WmAttributesCmd( return TCL_ERROR; } exStyle = wmPtr->exStyleConfig; - style = wmPtr->styleConfig; + style = wmPtr->styleConfig; if (objc == 3) { Tcl_Obj *objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, @@ -3219,11 +3204,11 @@ WmAttributesCmd( config_fullscreen = 1; styleBit = 0; } else if ((length > 3) - && (strncmp(string, "-toolwindow", length) == 0)) { + && (strncmp(string, "-toolwindow", length) == 0)) { stylePtr = &exStyle; styleBit = WS_EX_TOOLWINDOW; } else if ((length > 3) - && (strncmp(string, "-topmost", length) == 0)) { + && (strncmp(string, "-topmost", length) == 0)) { stylePtr = &exStyle; styleBit = WS_EX_TOPMOST; if ((i < objc-1) && (winPtr->flags & TK_EMBEDDED)) { @@ -3286,7 +3271,7 @@ WmAttributesCmd( if (config_fullscreen) { if (objc == 4) { Tcl_SetBooleanObj(Tcl_GetObjResult(interp), - (wmPtr->flags & WM_FULLSCREEN)); + (wmPtr->flags & WM_FULLSCREEN)); } else { fullscreen_attr_changed = 1; fullscreen_attr = boolean; @@ -3339,32 +3324,32 @@ WmAttributesCmd( if (fullscreen_attr_changed) { if (fullscreen_attr) { if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { - Tcl_AppendResult(interp, + Tcl_AppendResult(interp, "can't set fullscreen attribute for \"", winPtr->pathName, "\": override-redirect flag is set", NULL); - return TCL_ERROR; + return TCL_ERROR; } /* * Check max width and height if set by the user, don't worry * about the default values since they will likely be smaller than * screen width/height. - */ + */ if (((wmPtr->maxWidth > 0) && - (WidthOfScreen(Tk_Screen(winPtr)) > wmPtr->maxWidth)) || - ((wmPtr->maxHeight > 0) && - (HeightOfScreen(Tk_Screen(winPtr)) > wmPtr->maxHeight))) { - Tcl_AppendResult(interp, + (WidthOfScreen(Tk_Screen(winPtr)) > wmPtr->maxWidth)) || + ((wmPtr->maxHeight > 0) && + (HeightOfScreen(Tk_Screen(winPtr)) > wmPtr->maxHeight))) { + Tcl_AppendResult(interp, "can't set fullscreen attribute for \"", winPtr->pathName, "\": max width/height is too small", NULL); - return TCL_ERROR; + return TCL_ERROR; } - } + } - TkpWmSetFullScreen(winPtr, fullscreen_attr); + TkpWmSetFullScreen(winPtr, fullscreen_attr); } return TCL_OK; @@ -3495,8 +3480,7 @@ WmColormapwindowsCmd( gotToplevel = 0; for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], - (Tk_Window *) &winPtr2) != TCL_OK) - { + (Tk_Window *) &winPtr2) != TCL_OK) { ckfree((char *) cmapList); return TCL_ERROR; } @@ -4012,8 +3996,8 @@ WmIconbitmapCmd( char *argv3 = Tcl_GetString(objv[3]); if (strcmp(argv3, "-default")) { - Tcl_AppendResult(interp, "illegal option \"", - argv3, "\" must be \"-default\"", NULL); + Tcl_AppendResult(interp, "illegal option \"", argv3, + "\" must be \"-default\"", NULL); return TCL_ERROR; } useWinPtr = NULL; @@ -4329,7 +4313,7 @@ WmIconphotoCmd( photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { Tcl_AppendResult(interp, "can't use \"", Tcl_GetString(objv[i]), - "\" as iconphoto: not a photo image", (char *) NULL); + "\" as iconphoto: not a photo image", NULL); return TCL_ERROR; } } @@ -4368,10 +4352,10 @@ WmIconphotoCmd( Tcl_GetString(objv[i]), "\"", NULL); return TCL_ERROR; } - lpIR->IconImages[i-startObj].Width = width; + lpIR->IconImages[i-startObj].Width = width; lpIR->IconImages[i-startObj].Height = height; lpIR->IconImages[i-startObj].Colors = 4; - lpIR->IconImages[i-startObj].hIcon = hIcon; + lpIR->IconImages[i-startObj].hIcon = hIcon; } titlebaricon = (WinIconPtr) ckalloc(sizeof(WinIconInstance)); titlebaricon->iconBlock = lpIR; @@ -4685,8 +4669,9 @@ WmOverrideredirectCmd( } if(winPtr->flags & TK_EMBEDDED) { curValue = SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, -1, -1)-1; - if(curValue < 0) { - Tcl_AppendResult(interp, "Container does not support overrideredirect", NULL); + if (curValue < 0) { + Tcl_AppendResult(interp, + "Container does not support overrideredirect", NULL); return TCL_ERROR; } } else { @@ -4747,9 +4732,11 @@ WmPositionfromCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; static CONST char *optionStrings[] = { - "program", "user", (char *) NULL }; + "program", "user", NULL + }; enum options { - OPT_PROGRAM, OPT_USER }; + OPT_PROGRAM, OPT_USER + }; int index; if ((objc != 3) && (objc != 4)) { @@ -4837,7 +4824,7 @@ WmProtocolCmd( */ for (protPtr = wmPtr->protPtr; protPtr != NULL; - protPtr = protPtr->nextPtr) { + protPtr = protPtr->nextPtr) { if (protPtr->protocol == protocol) { Tcl_SetResult(interp, protPtr->command, TCL_STATIC); return TCL_OK; @@ -4911,8 +4898,8 @@ WmResizableCmd( char buf[TCL_INTEGER_SPACE * 2]; sprintf(buf, "%d %d", - (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1, - (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1); + (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1, + (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_OK; } @@ -5031,9 +5018,11 @@ WmStackorderCmd( { TkWindow **windows, **window_ptr; static CONST char *optionStrings[] = { - "isabove", "isbelow", (char *) NULL }; + "isabove", "isbelow", NULL + }; enum options { - OPT_ISABOVE, OPT_ISBELOW }; + OPT_ISABOVE, OPT_ISBELOW + }; int index; if ((objc != 3) && (objc != 5)) { @@ -5091,15 +5080,19 @@ WmStackorderCmd( return TCL_ERROR; } else { for (window_ptr = windows; *window_ptr ; window_ptr++) { - if (*window_ptr == winPtr) + if (*window_ptr == winPtr) { index1 = (window_ptr - windows); - if (*window_ptr == winPtr2) + } + if (*window_ptr == winPtr2) { index2 = (window_ptr - windows); + } } - if (index1 == -1) + if (index1 == -1) { Tcl_Panic("winPtr window not found"); - if (index2 == -1) + } + if (index2 == -1) { Tcl_Panic("winPtr2 window not found"); + } ckfree((char *) windows); } @@ -5146,9 +5139,11 @@ WmStateCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; static CONST char *optionStrings[] = { - "normal", "iconic", "withdrawn", "zoomed", (char *) NULL }; + "normal", "iconic", "withdrawn", "zoomed", NULL + }; enum options { - OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED }; + OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED + }; int index; if ((objc < 3) || (objc > 4)) { @@ -5190,9 +5185,9 @@ WmStateCmd( } if(state+1 != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) { - Tcl_AppendResult(interp, "can't change state of ", - winPtr->pathName, ": the container does not support the request", - (char *) NULL); + Tcl_AppendResult(interp, "can't change state of ", + winPtr->pathName, + ": the container does not support the request", NULL); return TCL_ERROR; } return TCL_OK; @@ -5208,9 +5203,8 @@ WmStateCmd( */ } else if (index == OPT_ICONIC) { if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { - Tcl_AppendResult(interp, "can't iconify \"", - winPtr->pathName, "\": override-redirect flag is set", - NULL); + Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, + "\": override-redirect flag is set", NULL); return TCL_ERROR; } if (wmPtr->masterPtr != NULL) { @@ -5301,7 +5295,8 @@ WmTitleCmd( if (wrapper) { char buf[512]; Tcl_DString titleString; - int size = tkWinProcs->useWide? 256:512; + int size = tkWinProcs->useWide ? 256 : 512; + (*tkWinProcs->getWindowText)(wrapper, (LPCTSTR)buf, size); Tcl_WinTCharToUtf(buf, -1, &titleString); Tcl_SetResult(interp, Tcl_DStringValue(&titleString),TCL_VOLATILE); @@ -5530,8 +5525,9 @@ WmWaitVisibilityOrMapProc( return; if (eventPtr->type == MapNotify) { - if (!(winPtr->wmInfoPtr->flags & WM_WITHDRAWN)) + if (!(winPtr->wmInfoPtr->flags & WM_WITHDRAWN)) { TkpWmSetState(winPtr, NormalState); + } } else if (eventPtr->type == UnmapNotify) { TkpWmSetState(winPtr, WithdrawnState); } @@ -5791,7 +5787,7 @@ TopLevelReqProc( wmPtr = winPtr->wmInfoPtr; if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) { SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin), - Tk_ReqHeight(tkwin)); + Tk_ReqHeight(tkwin)); } if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr); @@ -5890,7 +5886,7 @@ UpdateGeometryInfo( + (wmPtr->minWidth - wmPtr->reqGridWidth)*wmPtr->widthInc; if (wmPtr->maxWidth > 0) { max = winPtr->reqWidth - + (wmPtr->maxWidth - wmPtr->reqGridWidth)*wmPtr->widthInc; + + (wmPtr->maxWidth - wmPtr->reqGridWidth)*wmPtr->widthInc; } else { max = 0; } @@ -5925,7 +5921,7 @@ UpdateGeometryInfo( + (wmPtr->minHeight - wmPtr->reqGridHeight)*wmPtr->heightInc; if (wmPtr->maxHeight > 0) { max = winPtr->reqHeight - + (wmPtr->maxHeight - wmPtr->reqGridHeight)*wmPtr->heightInc; + + (wmPtr->maxHeight-wmPtr->reqGridHeight)*wmPtr->heightInc; } else { max = 0; } @@ -5951,13 +5947,13 @@ UpdateGeometryInfo( x = DisplayWidth(winPtr->display, winPtr->screenNum) - wmPtr->x - (width + wmPtr->borderWidth); } else { - x = wmPtr->x; + x = wmPtr->x; } if (wmPtr->flags & WM_NEGATIVE_Y) { y = DisplayHeight(winPtr->display, winPtr->screenNum) - wmPtr->y - (height + wmPtr->borderHeight); } else { - y = wmPtr->y; + y = wmPtr->y; } /* @@ -5969,9 +5965,9 @@ UpdateGeometryInfo( /* TODO: need to add flag for possible menu size change */ - if (!((wmPtr->flags & WM_MOVE_PENDING) - || (width != wmPtr->configWidth) - || (height != wmPtr->configHeight))) { + if (!(wmPtr->flags & WM_MOVE_PENDING) + && (width == wmPtr->configWidth) + && (height == wmPtr->configHeight)) { return; } wmPtr->flags &= ~WM_MOVE_PENDING; @@ -6450,8 +6446,8 @@ TkWmProtocolEventProc( CONST char *name = Tk_GetAtomName((Tk_Window) winPtr, protocol); Tcl_Preserve((ClientData) protPtr); - interp = protPtr->interp; - Tcl_Preserve((ClientData) interp); + interp = protPtr->interp; + Tcl_Preserve((ClientData) interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (command for \""); @@ -6459,7 +6455,7 @@ TkWmProtocolEventProc( Tcl_AddErrorInfo(interp, "\" window manager protocol)"); Tcl_BackgroundError(interp); } - Tcl_Release((ClientData) interp); + Tcl_Release((ClientData) interp); Tcl_Release((ClientData) protPtr); return; } @@ -6501,26 +6497,28 @@ TkWmStackorderToplevelEnumProc( TkWindow *childWinPtr; TkWmStackorderToplevelPair *pair = - (TkWmStackorderToplevelPair *) lParam; + (TkWmStackorderToplevelPair *) lParam; /*fprintf(stderr, "Looking up HWND %d\n", hwnd);*/ hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd); if (hPtr != NULL) { - childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr); + childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr); - /* + /* * Double check that same HWND does not get passed twice. */ - if (childWinPtr == NULL) { - Tcl_Panic("duplicate HWND in TkWmStackorderToplevelEnumProc"); - } else { - Tcl_SetHashValue(hPtr, NULL); - } - /*fprintf(stderr, "Found mapped HWND %d -> %x (%s)\n", hwnd, - childWinPtr, childWinPtr->pathName);*/ - *(pair->window_ptr)-- = childWinPtr; + if (childWinPtr == NULL) { + Tcl_Panic("duplicate HWND in TkWmStackorderToplevelEnumProc"); + } else { + Tcl_SetHashValue(hPtr, NULL); + } + /* + fprintf(stderr, "Found mapped HWND %d -> %x (%s)\n", hwnd, + childWinPtr, childWinPtr->pathName); + */ + *(pair->window_ptr)-- = childWinPtr; } return TRUE; } @@ -6554,19 +6552,21 @@ TkWmStackorderToplevelWrapperMap( int newEntry; if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && - !Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { - wrapper = TkWinGetWrapperWindow((Tk_Window) winPtr); + !Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { + wrapper = TkWinGetWrapperWindow((Tk_Window) winPtr); - /*fprintf(stderr, "Mapped HWND %d to %x (%s)\n", wrapper, - winPtr, winPtr->pathName);*/ + /* + fprintf(stderr, "Mapped HWND %d to %x (%s)\n", wrapper, + winPtr, winPtr->pathName); + */ - hPtr = Tcl_CreateHashEntry(table, (char *) wrapper, &newEntry); - Tcl_SetHashValue(hPtr, winPtr); + hPtr = Tcl_CreateHashEntry(table, (char *) wrapper, &newEntry); + Tcl_SetHashValue(hPtr, winPtr); } for (childPtr = winPtr->childList; childPtr != NULL; - childPtr = childPtr->nextPtr) { - TkWmStackorderToplevelWrapperMap(childPtr, display, table); + childPtr = childPtr->nextPtr) { + TkWmStackorderToplevelWrapperMap(childPtr, display, table); } } /* @@ -6604,7 +6604,7 @@ TkWmStackorderToplevel( TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); windows = (TkWindow **) ckalloc((table.numEntries+1) - * sizeof(TkWindow *)); + * sizeof(TkWindow *)); /* * Special cases: If zero or one toplevels were mapped there is no need to @@ -6613,13 +6613,13 @@ TkWmStackorderToplevel( switch (table.numEntries) { case 0: - windows[0] = NULL; - goto done; + windows[0] = NULL; + goto done; case 1: - hPtr = Tcl_FirstHashEntry(&table, &search); - windows[0] = (TkWindow *) Tcl_GetHashValue(hPtr); - windows[1] = NULL; - goto done; + hPtr = Tcl_FirstHashEntry(&table, &search); + windows[0] = (TkWindow *) Tcl_GetHashValue(hPtr); + windows[1] = NULL; + goto done; } /* @@ -6634,8 +6634,8 @@ TkWmStackorderToplevel( if (EnumWindows((WNDENUMPROC) TkWmStackorderToplevelEnumProc, (LPARAM) &pair) == 0) { - ckfree((char *) windows); - windows = NULL; + ckfree((char *) windows); + windows = NULL; } else if (pair.window_ptr != (windows-1)) { Tcl_Panic("num matched toplevel windows does not equal num children"); } @@ -6910,12 +6910,12 @@ TkWinSetMenu( wmPtr->hMenu = hMenu; if (!(wmPtr->flags & WM_NEVER_MAPPED)) { - int syncPending = wmPtr->flags & WM_SYNC_PENDING; + int syncPending = wmPtr->flags & WM_SYNC_PENDING; - wmPtr->flags |= WM_SYNC_PENDING; - SetMenu(wmPtr->wrapper, hMenu); - if (!syncPending) { - wmPtr->flags &= ~WM_SYNC_PENDING; + wmPtr->flags |= WM_SYNC_PENDING; + SetMenu(wmPtr->wrapper, hMenu); + if (!syncPending) { + wmPtr->flags &= ~WM_SYNC_PENDING; } } if (!(winPtr->flags & TK_EMBEDDED)) { @@ -6925,7 +6925,7 @@ TkWinSetMenu( } } else { SendMessage(wmPtr->wrapper, TK_SETMENU, - (WPARAM)hMenu, (LPARAM)Tk_GetMenuHWND(tkwin)); + (WPARAM)hMenu, (LPARAM)Tk_GetMenuHWND(tkwin)); } } @@ -7069,8 +7069,8 @@ ConfigureTopLevel( } else { if (wmPtr->gridWin != NULL) { wmPtr->width = wmPtr->reqGridWidth - + (winPtr->changes.width - winPtr->reqWidth) - / wmPtr->widthInc; + + (winPtr->changes.width - winPtr->reqWidth) + / wmPtr->widthInc; if (wmPtr->width < 0) { wmPtr->width = 0; } @@ -7087,8 +7087,8 @@ ConfigureTopLevel( } else { if (wmPtr->gridWin != NULL) { wmPtr->height = wmPtr->reqGridHeight - + (winPtr->changes.height - winPtr->reqHeight) - / wmPtr->heightInc; + + (winPtr->changes.height - winPtr->reqHeight) + / wmPtr->heightInc; if (wmPtr->height < 0) { wmPtr->height = 0; } @@ -7205,7 +7205,7 @@ InstallColormaps( TkWindow *winPtr = GetTopLevel(hwnd); WmInfo *wmPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr == NULL || (winPtr->flags & TK_ALREADY_DEAD) ) { return 0; @@ -7417,7 +7417,7 @@ InvalidateSubTreeDepth( #endif for (childPtr = winPtr->childList; childPtr != NULL; - childPtr = childPtr->nextPtr) { + childPtr = childPtr->nextPtr) { /* * We can stop the descent when we hit a non-embedded toplevel window, * as it should get its own message. @@ -7450,7 +7450,7 @@ HPALETTE TkWinGetSystemPalette(void) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); return tsdPtr->systemPalette; } @@ -7542,11 +7542,10 @@ GetMinSize( * defaulted. * * Results: - * The values at *maxWidthPtr and *maxHeightPtr are filled - * in with the maximum allowable dimensions of wmPtr's window, - * in grid units. If no maximum has been specified for the - * window, then this function computes the largest sizes that - * will fit on the screen. + * The values at *maxWidthPtr and *maxHeightPtr are filled in with the + * maximum allowable dimensions of wmPtr's window, in grid units. If no + * maximum has been specified for the window, then this function computes + * the largest sizes that will fit on the screen. * * Side effects: * None. @@ -7739,7 +7738,7 @@ WmProc( screen->width = LOWORD(lParam); /* horizontal res */ screen->height = HIWORD(lParam); /* vertical res */ - screen->mwidth = MulDiv(screen->width, 254, + screen->mwidth = MulDiv(screen->width, 254, GetDeviceCaps(dc, LOGPIXELSX) * 10); screen->mheight = MulDiv(screen->height, 254, GetDeviceCaps(dc, LOGPIXELSY) * 10); @@ -8124,7 +8123,8 @@ TkpWinToplevelWithDraw(winPtr) *---------------------------------------------------------------------- */ -void TkpWinToplevelIconify( +void +TkpWinToplevelIconify( TkWindow *winPtr) { TkpWmSetState(winPtr, IconicState); @@ -8147,7 +8147,8 @@ void TkpWinToplevelIconify( *---------------------------------------------------------------------- */ -void TkpWinToplevelDeiconify( +void +TkpWinToplevelDeiconify( TkWindow *winPtr) { register WmInfo *wmPtr = winPtr->wmInfoPtr; @@ -8289,13 +8290,13 @@ TkpWinToplevelOverrideRedirect( if (curValue != reqValue) { XSetWindowAttributes atts; - /* - * Only do this if we are really changing value, because it causes - * some funky stuff to occur - */ + /* + * Only do this if we are really changing value, because it causes + * some funky stuff to occur + */ - atts.override_redirect = reqValue ? True : False; - Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, + atts.override_redirect = reqValue ? True : False; + Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); if (!(wmPtr->flags & (WM_NEVER_MAPPED)) && !(winPtr->flags & TK_EMBEDDED)) { @@ -8331,11 +8332,11 @@ TkpWinToplevelDetachWindow( if (winPtr->flags & TK_EMBEDDED) { int state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1) - 1; - SendMessage(wmPtr->wrapper, TK_SETMENU, 0, 0); - SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0); - winPtr->flags &= ~TK_EMBEDDED; + SendMessage(wmPtr->wrapper, TK_SETMENU, 0, 0); + SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0); + winPtr->flags &= ~TK_EMBEDDED; winPtr->privatePtr = NULL; - wmPtr->wrapper = None; + wmPtr->wrapper = None; if (state >= 0 && state <= 3) { wmPtr->hints.initial_state = state; } diff --git a/win/tkWinX.c b/win/tkWinX.c index 5686a5c..ce2230e 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinX.c,v 1.51 2005/12/02 00:37:20 dkf Exp $ + * RCS: @(#) $Id: tkWinX.c,v 1.52 2005/12/02 13:42:29 dkf Exp $ */ /* @@ -96,26 +96,28 @@ TkWinProcs *tkWinProcs; * Declarations of static variables used in this file. */ -static char winScreenName[] = ":0"; /* Default name of windows display. */ -static HINSTANCE tkInstance = NULL; /* Application instance handle. */ -static int childClassInitialized; /* Registered child class? */ -static WNDCLASS childClass; /* Window class for child windows. */ -static int tkPlatformId = 0; /* version of Windows platform */ -static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */ -static Tcl_Encoding keyInputEncoding = NULL;/* The current character - * encoding for keyboard input */ -static int keyInputCharset = -1; /* The Win32 CHARSET for the keyboard - * encoding */ -static Tcl_Encoding unicodeEncoding = NULL; /* unicode encoding */ +static char winScreenName[] = ":0"; /* Default name of windows display. */ +static HINSTANCE tkInstance = NULL; /* Application instance handle. */ +static int childClassInitialized; /* Registered child class? */ +static WNDCLASS childClass; /* Window class for child windows. */ +static int tkPlatformId = 0; /* version of Windows platform */ +static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */ +static Tcl_Encoding keyInputEncoding = NULL; + /* The current character encoding for + * keyboard input */ +static int keyInputCharset = -1; /* The Win32 CHARSET for the keyboard + * encoding */ +static Tcl_Encoding unicodeEncoding = NULL; + /* The UNICODE encoding */ /* * Thread local storage. Notice that now each thread must have its own - * TkDisplay structure, since this structure contains most of the - * thread-specific date for threads. + * TkDisplay structure, since this structure contains most of the thread- + * specific date for threads. */ typedef struct ThreadSpecificData { - TkDisplay *winDisplay; /* TkDisplay structure that represents Windows + TkDisplay *winDisplay; /* TkDisplay structure that represents Windows * screen. */ int updatingClipboard; /* If 1, we are updating the clipboard. */ } ThreadSpecificData; @@ -129,8 +131,8 @@ static void GenerateXEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam); static void GetTranslatedKey(XKeyEvent *xkey); -static void UpdateInputLanguage(int charset); -static int HandleIMEComposition(HWND hwnd, LPARAM lParam); +static void UpdateInputLanguage(int charset); +static int HandleIMEComposition(HWND hwnd, LPARAM lParam); /* *---------------------------------------------------------------------- @@ -329,8 +331,8 @@ TkWinXCleanup( */ if (childClassInitialized) { - childClassInitialized = 0; - UnregisterClass(TK_WIN_CHILD_CLASS_NAME, hInstance); + childClassInitialized = 0; + UnregisterClass(TK_WIN_CHILD_CLASS_NAME, hInstance); } if (unicodeEncoding != NULL) { @@ -376,31 +378,32 @@ TkWinGetPlatformId(void) GetVersionEx(&os); tkPlatformId = os.dwPlatformId; - /* + /* * Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC. The * TK_THEME_WIN_CLASSIC could be set even when running under XP if the * windows classic theme was selected. */ + if ((os.dwPlatformId == VER_PLATFORM_WIN32_NT) && - (os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) { + (os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) { HKEY hKey; - LPCSTR szSubKey = TEXT("Control Panel\\Appearance"); + LPCSTR szSubKey = TEXT("Control Panel\\Appearance"); LPCSTR szCurrent = TEXT("Current"); DWORD dwSize = 200; char pBuffer[200]; memset(pBuffer, 0, dwSize); if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0L, - KEY_READ, &hKey) != ERROR_SUCCESS) { - tkWinTheme = TK_THEME_WIN_XP; + KEY_READ, &hKey) != ERROR_SUCCESS) { + tkWinTheme = TK_THEME_WIN_XP; } else { - RegQueryValueEx(hKey, szCurrent, NULL, NULL, pBuffer, &dwSize); - RegCloseKey(hKey); - if (strcmp(pBuffer, "Windows Standard") == 0) { - tkWinTheme = TK_THEME_WIN_CLASSIC; - } else { - tkWinTheme = TK_THEME_WIN_XP; - } + RegQueryValueEx(hKey, szCurrent, NULL, NULL, pBuffer, &dwSize); + RegCloseKey(hKey); + if (strcmp(pBuffer, "Windows Standard") == 0) { + tkWinTheme = TK_THEME_WIN_CLASSIC; + } else { + tkWinTheme = TK_THEME_WIN_XP; + } } } else { tkWinTheme = TK_THEME_WIN_CLASSIC; @@ -431,7 +434,7 @@ int TkWinGetPlatformTheme(void) { if (tkPlatformId == 0) { - TkWinGetPlatformId(); + TkWinGetPlatformId(); } return tkWinTheme; } @@ -587,8 +590,7 @@ TkpOpenDisplay( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->winDisplay != NULL) { - if (strcmp(tsdPtr->winDisplay->display->display_name, display_name) - == 0) { + if (!strcmp(tsdPtr->winDisplay->display->display_name, display_name)) { return tsdPtr->winDisplay; } else { return NULL; @@ -602,9 +604,9 @@ TkpOpenDisplay( strcpy(display->display_name, display_name); display->cursor_font = 1; - display->nscreens = 1; - display->request = 1; - display->qlen = 0; + display->nscreens = 1; + display->request = 1; + display->qlen = 0; screen = (Screen *) ckalloc(sizeof(Screen)); ZeroMemory(screen, sizeof(Screen)); @@ -629,7 +631,7 @@ TkpOpenDisplay( screen->white_pixel = RGB(255, 255, 255); screen->black_pixel = RGB(0, 0, 0); - screen->cmap = None; + screen->cmap = None; display->screens = screen; display->nscreens = 1; @@ -671,26 +673,26 @@ TkpCloseDisplay( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (dispPtr != tsdPtr->winDisplay) { - Tcl_Panic("TkpCloseDisplay: tried to call TkpCloseDisplay on another display"); - return; + Tcl_Panic("TkpCloseDisplay: tried to call TkpCloseDisplay on another display"); + return; /* not reached */ } tsdPtr->winDisplay = NULL; - if (display->display_name != (char *) NULL) { - ckfree(display->display_name); + if (display->display_name != NULL) { + ckfree(display->display_name); } - if (display->screens != (Screen *) NULL) { - if (display->screens->root_visual != NULL) { - ckfree((char *) display->screens->root_visual); - } - if (display->screens->root != None) { - ckfree((char *) display->screens->root); - } - if (display->screens->cmap != None) { - XFreeColormap(display, display->screens->cmap); - } - ckfree((char *) display->screens); + if (display->screens != NULL) { + if (display->screens->root_visual != NULL) { + ckfree((char *) display->screens->root_visual); + } + if (display->screens->root != None) { + ckfree((char *) display->screens->root); + } + if (display->screens->cmap != None) { + XFreeColormap(display, display->screens->cmap); + } + ckfree((char *) display->screens); } ckfree((char *) display); } @@ -1015,7 +1017,7 @@ GenerateXEvent( case WM_SETFOCUS: case WM_KILLFOCUS: { - TkWindow *otherWinPtr = (TkWindow *)Tk_HWNDToWindow((HWND) wParam); + TkWindow *otherWinPtr = (TkWindow *) Tk_HWNDToWindow((HWND) wParam); /* * Compare toplevel windows to avoid reporting focus changes within @@ -1139,7 +1141,7 @@ GenerateXEvent( case WM_SYSKEYDOWN: case WM_KEYDOWN: /* - * Check for translated characters in the event queue. Setting + * Check for translated characters in the event queue. Setting * xany.send_event to -1 indicates to the Windows implementation * of TkpGetString() that this event was generated by windows and * that the Windows extension xkey.trans_chars is filled with the @@ -1220,8 +1222,18 @@ GenerateXEvent( } default: + /* + * Don't know how to translate this event, so ignore it. (It probably + * should not have got here, but ignoring it should be harmless.) + */ + return; } + + /* + * Post the translated event to the main Tk event queue. + */ + Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } @@ -1336,35 +1348,35 @@ GetTranslatedKey( while ((xkey->nbytes < XMaxTransChars) && PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if ((msg.message == WM_CHAR) || (msg.message == WM_SYSCHAR)) { - GetMessage(&msg, NULL, 0, 0); + if ((msg.message != WM_CHAR) && (msg.message != WM_SYSCHAR)) { + break; + } + + GetMessage(&msg, NULL, 0, 0); + + /* + * If this is a normal character message, we may need to strip off the + * Alt modifier (e.g. Alt-digits). Note that we don't want to do this + * for system messages, because those were presumably generated as an + * Alt-char sequence (e.g. accelerator keys). + */ + if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) { + xkey->state = 0; + } + xkey->trans_chars[xkey->nbytes] = (char) msg.wParam; + xkey->nbytes++; + + if (((unsigned short) msg.wParam) > ((unsigned short) 0xff)) { /* - * If this is a normal character message, we may need to strip off - * the Alt modifier (e.g. Alt-digits). Note that we don't want to - * do this for system messages, because those were presumably - * generated as an Alt-char sequence (e.g. accelerator keys). + * Some "addon" input devices, such as the popular PenPower + * Chinese writing pad, generate 16 bit values in WM_CHAR messages + * (instead of passing them in two separate WM_CHAR messages + * containing two 8-bit values. */ - if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) { - xkey->state = 0; - } - xkey->trans_chars[xkey->nbytes] = (char) msg.wParam; - xkey->nbytes++; - - if (((unsigned short) msg.wParam) > ((unsigned short) 0xff)) { - /* - * Some "addon" input devices, such as the popular PenPower - * Chinese writing pad, generate 16 bit values in WM_CHAR - * messages (instead of passing them in two separate WM_CHAR - * messages containing two 8-bit values. - */ - - xkey->trans_chars[xkey->nbytes] = (char) (msg.wParam >> 8); - xkey->nbytes ++; - } - } else { - break; + xkey->trans_chars[xkey->nbytes] = (char) (msg.wParam >> 8); + xkey->nbytes ++; } } } @@ -1401,8 +1413,8 @@ UpdateInputLanguage( if (keyInputCharset == charset) { return; } - if (TranslateCharsetInfo((DWORD*)charset, &charsetInfo, TCI_SRCCHARSET) - == 0) { + if (TranslateCharsetInfo((DWORD*)charset, &charsetInfo, + TCI_SRCCHARSET) == 0) { /* * Some mysterious failure. */ @@ -1481,22 +1493,22 @@ TkWinGetUnicodeEncoding(void) * * HandleIMEComposition -- * - * This function works around a definciency in some versions of Windows - * 2000 to make it possible to entry multi-lingual characters under all - * versions of Windows 2000. + * This function works around a definciency in some versions of Windows + * 2000 to make it possible to entry multi-lingual characters under all + * versions of Windows 2000. * - * When an Input Method Editor (IME) is ready to send input characters to - * an application, it sends a WM_IME_COMPOSITION message with the - * GCS_RESULTSTR. However, The DefWindowProc() on English Windows 2000 - * arbitrarily converts all non-Latin-1 characters in the composition to - * "?". + * When an Input Method Editor (IME) is ready to send input characters to + * an application, it sends a WM_IME_COMPOSITION message with the + * GCS_RESULTSTR. However, The DefWindowProc() on English Windows 2000 + * arbitrarily converts all non-Latin-1 characters in the composition to + * "?". * - * This function correctly processes the composition data and sends the - * UNICODE values of the composed characters to TK's event queue. + * This function correctly processes the composition data and sends the + * UNICODE values of the composed characters to TK's event queue. * * Results: * If this function has processed the composition data, returns 1. - * Otherwise returns 0. + * Otherwise returns 0. * * Side effects: * Key events are put into the TK event queue. @@ -1510,104 +1522,104 @@ HandleIMEComposition( LPARAM lParam) /* Flags for the WM_IME_COMPOSITION message */ { HIMC hIMC; - int i, n; - XEvent event; - char * buff; - TkWindow *winPtr; - Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding(); + int n; BOOL isWinNT = (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT); if ((lParam & GCS_RESULTSTR) == 0) { - /* - * Composition is not finished yet. - */ + /* + * Composition is not finished yet. + */ - return 0; + return 0; } hIMC = ImmGetContext(hwnd); - if (hIMC) { + if (!hIMC) { + return 0; + } + + if (isWinNT) { + n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); + } else { + n = ImmGetCompositionStringA(hIMC, GCS_RESULTSTR, NULL, 0); + } + + if (n > 0) { + char *buff = ckalloc(n); + TkWindow *winPtr; + XEvent event; + int i; + if (isWinNT) { - n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); + n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n); } else { - n = ImmGetCompositionStringA(hIMC, GCS_RESULTSTR, NULL, 0); + Tcl_DString utfString, unicodeString; + Tcl_Encoding unicodeEncoding = TkWinGetUnicodeEncoding(); + + n = ImmGetCompositionStringA(hIMC, GCS_RESULTSTR, buff, n); + Tcl_DStringInit(&utfString); + Tcl_ExternalToUtfDString(keyInputEncoding, buff, n, &utfString); + Tcl_UtfToExternalDString(unicodeEncoding, + Tcl_DStringValue(&utfString), -1, &unicodeString); + i = Tcl_DStringLength(&unicodeString); + if (n < i) { + /* + * Only alloc more space if we need, otherwise just use what + * we've created. Don't realloc as that may copy data we no + * longer need. + */ + + ckfree((char *) buff); + buff = (char *) ckalloc(i); + } + n = i; + memcpy(buff, Tcl_DStringValue(&unicodeString), n); + Tcl_DStringFree(&utfString); + Tcl_DStringFree(&unicodeString); } - if ((n > 0) && ((buff = (char *) ckalloc(n)) != NULL)) { - if (isWinNT) { - n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n); - } else { - Tcl_DString utfString, unicodeString; - - n = ImmGetCompositionStringA(hIMC, GCS_RESULTSTR, buff, n); - Tcl_DStringInit(&utfString); - Tcl_ExternalToUtfDString(keyInputEncoding, buff, n, - &utfString); - Tcl_UtfToExternalDString(unicodeEncoding, - Tcl_DStringValue(&utfString), -1, &unicodeString); - i = Tcl_DStringLength(&unicodeString); - if (n < i) { - /* - * Only alloc more space if we need, otherwise just use - * what we've created. Don't realloc as that may copy data - * we no longer need. - */ - - ckfree((char *) buff); - buff = (char *) ckalloc(i); - } - n = i; - memcpy(buff, Tcl_DStringValue(&unicodeString), n); - Tcl_DStringFree(&utfString); - Tcl_DStringFree(&unicodeString); - } + /* + * Set up the fields pertinent to key event. + * + * We set send_event to the special value of -2, so that TkpGetString + * in tkWinKey.c knows that trans_chars[] already contains a UNICODE + * char and there's no need to do encoding conversion. + */ + winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); + + event.xkey.serial = winPtr->display->request++; + event.xkey.send_event = -2; + event.xkey.display = winPtr->display; + event.xkey.window = winPtr->window; + event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); + event.xkey.subwindow = None; + event.xkey.state = TkWinGetModifierState(); + event.xkey.time = TkpGetMS(); + event.xkey.same_screen = True; + event.xkey.keycode = 0; + event.xkey.nbytes = 2; + + for (i=0; idisplay->request++; - event.xkey.send_event = -2; - event.xkey.display = winPtr->display; - event.xkey.window = winPtr->window; - event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xkey.subwindow = None; - event.xkey.state = TkWinGetModifierState(); - event.xkey.time = TkpGetMS(); - event.xkey.same_screen = True; - event.xkey.keycode = 0; - event.xkey.nbytes = 2; - - for (i=0; itype == ButtonPress) { - switch (eventPtr->xbutton.button) { - case Button1: - msg = WM_LBUTTONDOWN; - wparam = MK_LBUTTON; - break; - case Button2: - msg = WM_MBUTTONDOWN; - wparam = MK_MBUTTON; - break; - case Button3: - msg = WM_RBUTTONDOWN; - wparam = MK_RBUTTON; - break; - default: - return 0; - } - if (eventPtr->xbutton.state & Button1Mask) { - wparam |= MK_LBUTTON; - } - if (eventPtr->xbutton.state & Button2Mask) { - wparam |= MK_MBUTTON; - } - if (eventPtr->xbutton.state & Button3Mask) { - wparam |= MK_RBUTTON; - } - if (eventPtr->xbutton.state & ShiftMask) { - wparam |= MK_SHIFT; - } - if (eventPtr->xbutton.state & ControlMask) { - wparam |= MK_CONTROL; - } - lparam = MAKELPARAM((short) eventPtr->xbutton.x, - (short) eventPtr->xbutton.y); - } else { + if (eventPtr->type != ButtonPress) { return 0; } + + switch (eventPtr->xbutton.button) { + case Button1: + msg = WM_LBUTTONDOWN; + wparam = MK_LBUTTON; + break; + case Button2: + msg = WM_MBUTTONDOWN; + wparam = MK_MBUTTON; + break; + case Button3: + msg = WM_RBUTTONDOWN; + wparam = MK_RBUTTON; + break; + default: + return 0; + } + + if (eventPtr->xbutton.state & Button1Mask) { + wparam |= MK_LBUTTON; + } + if (eventPtr->xbutton.state & Button2Mask) { + wparam |= MK_MBUTTON; + } + if (eventPtr->xbutton.state & Button3Mask) { + wparam |= MK_RBUTTON; + } + if (eventPtr->xbutton.state & ShiftMask) { + wparam |= MK_SHIFT; + } + if (eventPtr->xbutton.state & ControlMask) { + wparam |= MK_CONTROL; + } + lparam = MAKELPARAM((short) eventPtr->xbutton.x, + (short) eventPtr->xbutton.y); return CallWindowProc(wndproc, hwnd, msg, wparam, lparam); } @@ -1834,12 +1848,13 @@ Tk_SetCaretPos( * The IME composition window should be updated whenever the caret * position is changed because a clause of the composition string may * be converted to the final characters and the other clauses still - * stay on the composition window. -- yamamoto + * stay on the composition window. -- yamamoto */ hIMC = ImmGetContext(hwnd); if (hIMC) { COMPOSITIONFORM cform; + cform.dwStyle = CFS_POINT; cform.ptCurrentPos.x = x; cform.ptCurrentPos.y = y; @@ -1888,8 +1903,7 @@ Tk_GetUserInactiveTime( initinfo = 1; if (hMod){ - pfnGetLastInputInfo = - GetProcAddress(hMod, "GetLastInputInfo"); + pfnGetLastInputInfo = GetProcAddress(hMod, "GetLastInputInfo"); } } if (pfnGetLastInputInfo == NULL) { @@ -1930,12 +1944,12 @@ Tk_ResetUserInactiveTime( { INPUT inp; - inp.type = INPUT_MOUSE; - inp.mi.dx = 0; - inp.mi.dy = 0; - inp.mi.mouseData = 0; - inp.mi.dwFlags = MOUSEEVENTF_MOVE; - inp.mi.time = 0; + inp.type = INPUT_MOUSE; + inp.mi.dx = 0; + inp.mi.dy = 0; + inp.mi.mouseData = 0; + inp.mi.dwFlags = MOUSEEVENTF_MOVE; + inp.mi.time = 0; inp.mi.dwExtraInfo = (DWORD) NULL; SendInput(1, &inp, sizeof(inp)); -- cgit v0.12