From b9551536f704910727aa738f8a6e3aac1219c67f Mon Sep 17 00:00:00 2001 From: hobbs Date: Sat, 15 Jun 2002 01:54:47 +0000 Subject: * generic/tkInt.h: * generic/tkCmds.c (Tk_WmObjCmd): * unix/tkUnixWm.c (Tk_WmCmd): * win/tkWinWm.c (Tk_WmCmd): changed wmTracing from being an int to just a bit in the flags variable (TK_DISPLAY_WM_TRACING) --- ChangeLog | 8 +++- generic/tkCmds.c | 16 +++++-- generic/tkInt.h | 12 ++--- unix/tkUnixWm.c | 44 ++++++++++------- win/tkWinWm.c | 141 +++++++++++++++++++++++++++++++++++++++++-------------- 5 files changed, 158 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6027891..57d0554 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,15 @@ 2002-06-14 Jeff Hobbs + * generic/tkInt.h: + * generic/tkCmds.c (Tk_WmObjCmd): + * unix/tkUnixWm.c (Tk_WmCmd): + * win/tkWinWm.c (Tk_WmCmd): changed wmTracing from being an int to + just a bit in the flags variable (TK_DISPLAY_WM_TRACING) + * generic/tkEvent.c (Tk_HandleEvent): * unix/tkUnixEvent.c (OpenIM): * unix/tkUnixKey.c (TkpGetString): - * generic/tkInt.h: added TK_USE_XIM_SPOT flag bit for TkDisplay + * generic/tkInt.h: added TK_DISPLAY_XIM_SPOT flag bit for TkDisplay and used this to allow a runtime check to see if over-the-spot XIM is possible. If not it will try and fallback to the old-style input context, which handles things like dead keys input. diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 1ef3361..16739c2 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.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: tkCmds.c,v 1.24 2002/06/14 22:25:12 jenglish Exp $ + * RCS: @(#) $Id: tkCmds.c,v 1.25 2002/06/15 01:54:47 hobbs Exp $ */ #include "tkPort.h" @@ -1629,6 +1629,7 @@ Tk_WmObjCmd(clientData, interp, objc, objv) } if (index == TKWM_TRACING) { + int wmTracing; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; if ((objc != 2) && (objc != 3)) { @@ -1636,10 +1637,19 @@ Tk_WmObjCmd(clientData, interp, objc, objv) return TCL_ERROR; } if (objc == 2) { - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(dispPtr->wmTracing)); + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj(dispPtr->flags & TK_DISPLAY_WM_TRACING)); return TCL_OK; } - return Tcl_GetBooleanFromObj(interp, objv[2], &dispPtr->wmTracing); + if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) { + return TCL_ERROR; + } + if (wmTracing) { + dispPtr->flags |= TK_DISPLAY_WM_TRACING; + } else { + dispPtr->flags &= ~TK_DISPLAY_WM_TRACING; + } + return TCL_OK; } if (objc < 3) { diff --git a/generic/tkInt.h b/generic/tkInt.h index f0c80a3..f7b260a 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -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: tkInt.h,v 1.46 2002/06/15 01:09:36 hobbs Exp $ + * RCS: $Id: tkInt.h,v 1.47 2002/06/15 01:54:47 hobbs Exp $ */ #ifndef _TKINT @@ -432,11 +432,6 @@ typedef struct TkDisplay { * Information used by tkUnixWm.c and tkWinWm.c only: */ - int wmTracing; /* Used to enable or disable tracing in - * this module. If tracing is enabled, - * then information is printed on - * standard output about interesting - * interactions with the window manager. */ struct TkWmInfo *firstWmPtr; /* Points to first top-level window. */ struct TkWmInfo *foregroundWmPtr; /* Points to the foreground window. */ @@ -501,12 +496,13 @@ typedef struct TkDisplay { * Flag values for TkDisplay flags. * TK_DISPLAY_COLLAPSE_MOTION_EVENTS: (default on) * Indicates that we should collapse motion events on this display - * TK_USE_INPUT_METHODS: (default off) + * TK_DISPLAY_XIM_SPOT: (default off) * Indicates that we should use over-the-spot XIM on this display */ #define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) -#define TK_USE_XIM_SPOT (1 << 1) +#define TK_DISPLAY_XIM_SPOT (1 << 1) +#define TK_DISPLAY_WM_TRACING (1 << 2) /* * One of the following structures exists for each error handler diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index ad0b662..55f8c4d 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.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: tkUnixWm.c,v 1.22 2002/06/14 22:25:12 jenglish Exp $ + * RCS: @(#) $Id: tkUnixWm.c,v 1.23 2002/06/15 01:54:47 hobbs Exp $ */ #include "tkPort.h" @@ -886,17 +886,27 @@ Tk_WmCmd(clientData, interp, argc, argv) length = strlen(argv[1]); if ((c == 't') && (strncmp(argv[1], "tracing", length) == 0) && (length >= 3)) { + int wmTracing; if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # arguments: must be \"", argv[0], " tracing ?boolean?\"", (char *) NULL); return TCL_ERROR; } if (argc == 2) { - Tcl_SetResult(interp, ((dispPtr->wmTracing) ? "on" : "off"), + Tcl_SetResult(interp, + ((dispPtr->flags & TK_DISPLAY_WM_TRACING) ? "on" : "off"), TCL_STATIC); return TCL_OK; } - return Tcl_GetBoolean(interp, argv[2], &dispPtr->wmTracing); + if (Tcl_GetBoolean(interp, argv[2], &wmTracing) != TCL_OK) { + return TCL_ERROR; + } + if (wmTracing) { + dispPtr->flags |= TK_DISPLAY_WM_TRACING; + } else { + dispPtr->flags &= ~TK_DISPLAY_WM_TRACING; + } + return TCL_OK; } if (argc < 3) { @@ -2403,7 +2413,7 @@ ConfigureEvent(wmPtr, configEventPtr) if (((wrapperPtr->changes.width != configEventPtr->width) || (wrapperPtr->changes.height != configEventPtr->height)) && !(wmPtr->flags & WM_SYNC_PENDING)){ - if (dispPtr->wmTracing) { + if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("TopLevelEventProc: user changed %s size to %dx%d\n", winPtr->pathName, configEventPtr->width, configEventPtr->height); @@ -2467,7 +2477,7 @@ ConfigureEvent(wmPtr, configEventPtr) wmPtr->configHeight = configEventPtr->height; } - if (dispPtr->wmTracing) { + if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("ConfigureEvent: %s x = %d y = %d, width = %d, height = %d\n", winPtr->pathName, configEventPtr->x, configEventPtr->y, configEventPtr->width, configEventPtr->height); @@ -2497,7 +2507,7 @@ ConfigureEvent(wmPtr, configEventPtr) * there is a parent shrink-wrapped around the window. */ - if (dispPtr->wmTracing) { + if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf(" %s parent == %p, above %p\n", winPtr->pathName, (void *) wmPtr->reparent, (void *) configEventPtr->above); @@ -2606,7 +2616,7 @@ ReparentEvent(wmPtr, reparentEventPtr) && (actualType == XA_WINDOW))) { if ((actualFormat == 32) && (numItems == 1)) { vRoot = wmPtr->vRoot = *virtualRootPtr; - } else if (dispPtr->wmTracing) { + } else if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("%s format %d numItems %ld\n", "ReparentEvent got bogus VROOT property:", actualFormat, numItems); @@ -2615,7 +2625,7 @@ ReparentEvent(wmPtr, reparentEventPtr) } Tk_DeleteErrorHandler(handler); - if (dispPtr->wmTracing) { + if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("ReparentEvent: %s (%p) reparented to 0x%x, vRoot = 0x%x\n", wmPtr->winPtr->pathName, wmPtr->winPtr, (unsigned int) reparentEventPtr->parent, (unsigned int) vRoot); @@ -2781,7 +2791,7 @@ ComputeReparentGeometry(wmPtr) wrapperPtr->changes.x = x + wmPtr->xInParent; wrapperPtr->changes.y = y + wmPtr->yInParent; - if (dispPtr->wmTracing) { + if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("wrapperPtr %p coords %d,%d\n", wrapperPtr, wrapperPtr->changes.x, wrapperPtr->changes.y); printf(" wmPtr %p coords %d,%d, offsets %d %d\n", @@ -2835,7 +2845,7 @@ WrapperEventProc(clientData, eventPtr) Tk_DestroyWindow((Tk_Window) wmPtr->winPtr); Tk_DeleteErrorHandler(handler); } - if (dispPtr->wmTracing) { + if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("TopLevelEventProc: %s deleted\n", wmPtr->winPtr->pathName); } } else if (eventPtr->type == ConfigureNotify) { @@ -3099,7 +3109,7 @@ UpdateGeometryInfo(clientData) } wmPtr->configWidth = width; wmPtr->configHeight = height; - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("UpdateGeometryInfo moving to %d %d, resizing to %d x %d,\n", x, y, width, height); } @@ -3120,7 +3130,7 @@ UpdateGeometryInfo(clientData) } wmPtr->configWidth = width; wmPtr->configHeight = height; - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("UpdateGeometryInfo resizing %p to %d x %d\n", (void *)wmPtr->wrapperPtr->window, width, height); } @@ -3321,7 +3331,7 @@ WaitForConfigureNotify(winPtr, serial) code = WaitForEvent(winPtr->display, wmPtr, ConfigureNotify, &event); wmPtr->flags &= ~WM_SYNC_PENDING; if (code != TCL_OK) { - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("WaitForConfigureNotify giving up on %s\n", winPtr->pathName); } @@ -3333,7 +3343,7 @@ WaitForConfigureNotify(winPtr, serial) } } wmPtr->flags &= ~WM_MOVE_PENDING; - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("WaitForConfigureNotify finished with %s, serial %ld\n", winPtr->pathName, serial); } @@ -3510,14 +3520,14 @@ WaitForMapNotify(winPtr, mapped) * just quit. */ - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("WaitForMapNotify giving up on %s\n", winPtr->pathName); } break; } } wmPtr->flags &= ~WM_MOVE_PENDING; - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("WaitForMapNotify finished with %s (winPtr %p, wmPtr %p)\n", winPtr->pathName, winPtr, wmPtr); } @@ -4039,7 +4049,7 @@ UpdateVRootGeometry(wmPtr) (unsigned int *) &wmPtr->vRootWidth, (unsigned int *) &wmPtr->vRootHeight, (unsigned int *) &bd, &dummy); - if (winPtr->dispPtr->wmTracing) { + if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { printf("UpdateVRootGeometry: x = %d, y = %d, width = %d, ", wmPtr->vRootX, wmPtr->vRootY, wmPtr->vRootWidth); printf("height = %d, status = %d\n", wmPtr->vRootHeight, status); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 46390da..0858d10 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.40 2002/06/14 22:25:12 jenglish Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.41 2002/06/15 01:54:48 hobbs Exp $ */ #include "tkWinInt.h" @@ -103,10 +103,10 @@ typedef struct { DWORD dwImageOffset; /* where in the file is this image */ } ICONDIRENTRY, *LPICONDIRENTRY; typedef struct { - WORD idReserved; /* Reserved */ - WORD idType; /* resource type (1 for icons) */ - WORD idCount; /* how many images? */ - ICONDIRENTRY idEntries[1]; /* the entries for each image */ + WORD idReserved; /* Reserved */ + WORD idType; /* resource type (1 for icons) */ + WORD idCount; /* how many images? */ + ICONDIRENTRY idEntries[1]; /* the entries for each image */ } ICONDIR, *LPICONDIR; /* @@ -225,6 +225,8 @@ typedef struct TkWmInfo { * to eliminate redundant resize operations. */ HMENU hMenu; /* the hMenu associated with this menu */ DWORD style, exStyle; /* Style flags for the wrapper window. */ + LONG styleConfig; /* Extra user requested style bits */ + LONG exStyleConfig; /* Extra user requested extended style bits */ /* * List of children of the toplevel which have private colormaps. @@ -1398,12 +1400,13 @@ TkWmNewWindow(winPtr) register WmInfo *wmPtr; wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo)); + + /* + * Initialize full structure, then set what isn't NULL + */ + ZeroMemory(wmPtr, sizeof(WmInfo)); winPtr->wmInfoPtr = wmPtr; wmPtr->winPtr = winPtr; - wmPtr->wrapper = NULL; - wmPtr->titleUid = NULL; - wmPtr->iconName = NULL; - wmPtr->masterPtr = NULL; wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; @@ -1412,23 +1415,16 @@ TkWmNewWindow(winPtr) wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; wmPtr->hints.icon_mask = None; wmPtr->hints.window_group = None; - wmPtr->leaderName = NULL; - wmPtr->icon = NULL; - wmPtr->iconFor = NULL; - wmPtr->sizeHintsFlags = 0; /* * Default the maximum dimensions to the size of the display. */ wmPtr->defMinWidth = wmPtr->defMinHeight = 0; - wmPtr->defMaxWidth = DisplayWidth(winPtr->display, - winPtr->screenNum); - wmPtr->defMaxHeight = DisplayHeight(winPtr->display, - winPtr->screenNum); + wmPtr->defMaxWidth = DisplayWidth(winPtr->display, winPtr->screenNum); + wmPtr->defMaxHeight = DisplayHeight(winPtr->display, winPtr->screenNum); wmPtr->minWidth = wmPtr->minHeight = 1; wmPtr->maxWidth = wmPtr->maxHeight = 0; - wmPtr->gridWin = NULL; wmPtr->widthInc = wmPtr->heightInc = 1; wmPtr->minAspect.x = wmPtr->minAspect.y = 1; wmPtr->maxAspect.x = wmPtr->maxAspect.y = 1; @@ -1436,23 +1432,12 @@ TkWmNewWindow(winPtr) wmPtr->gravity = NorthWestGravity; wmPtr->width = -1; wmPtr->height = -1; - wmPtr->hMenu = NULL; wmPtr->x = winPtr->changes.x; wmPtr->y = winPtr->changes.y; - wmPtr->borderWidth = 0; - wmPtr->borderHeight = 0; - - wmPtr->cmapList = NULL; - wmPtr->cmapCount = 0; - wmPtr->numTransients = 0; wmPtr->configWidth = -1; wmPtr->configHeight = -1; - wmPtr->protPtr = NULL; - wmPtr->cmdArgv = NULL; - wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; - wmPtr->iconPtr = NULL; wmPtr->nextPtr = winPtr->dispPtr->firstWmPtr; winPtr->dispPtr->firstWmPtr = wmPtr; @@ -1553,6 +1538,9 @@ UpdateWrapper(winPtr) wmPtr->exStyle = EX_TOPLEVEL_STYLE; } + wmPtr->style |= wmPtr->styleConfig; + wmPtr->exStyle |= wmPtr->exStyleConfig; + if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { wmPtr->style &= ~ (WS_MAXIMIZEBOX | WS_SIZEBOX); @@ -2110,17 +2098,27 @@ Tk_WmCmd(clientData, interp, argc, argv) length = strlen(argv[1]); if ((c == 't') && (strncmp(argv[1], "tracing", length) == 0) && (length >= 3)) { + int wmTracing; if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # arguments: must be \"", argv[0], " tracing ?boolean?\"", (char *) NULL); return TCL_ERROR; } if (argc == 2) { - Tcl_SetResult(interp, ((dispPtr->wmTracing) ? "on" : "off"), + Tcl_SetResult(interp, + ((dispPtr->flags & TK_DISPLAY_WM_TRACING) ? "on" : "off"), TCL_STATIC); return TCL_OK; } - return Tcl_GetBoolean(interp, argv[2], &dispPtr->wmTracing); + if (Tcl_GetBoolean(interp, argv[2], &wmTracing) != TCL_OK) { + return TCL_ERROR; + } + if (wmTracing) { + dispPtr->flags |= TK_DISPLAY_WM_TRACING; + } else { + dispPtr->flags &= ~TK_DISPLAY_WM_TRACING; + } + return TCL_OK; } if (argc < 3) { @@ -2136,7 +2134,81 @@ Tk_WmCmd(clientData, interp, argc, argv) return TCL_ERROR; } wmPtr = winPtr->wmInfoPtr; - if ((c == 'a') && (strncmp(argv[1], "aspect", length) == 0)) { + if ((c == 'a') && (strncmp(argv[1], "attributes", length) == 0) + && (length >= 2)) { + LONG style, exStyle, styleBit, *stylePtr; + char buf[TCL_INTEGER_SPACE]; + int i, boolean; + + if (argc < 3) { + configArgs: + Tcl_AppendResult(interp, "wrong # arguments: must be \"", + argv[0], " attributes window", + " ?-disabled ?bool??", + " ?-toolwindow ?bool??", + " ?-topmost ?bool??\"", + (char *) NULL); + return TCL_ERROR; + } + exStyle = wmPtr->exStyleConfig; + style = wmPtr->styleConfig; + if (argc == 3) { + sprintf(buf, "%d", ((style & WS_DISABLED) != 0)); + Tcl_AppendResult(interp, "-disabled ", buf, (char *) NULL); + sprintf(buf, "%d", ((exStyle & WS_EX_TOOLWINDOW) != 0)); + Tcl_AppendResult(interp, " -toolwindow ", buf, (char *) NULL); + sprintf(buf, "%d", ((exStyle & WS_EX_TOPMOST) != 0)); + Tcl_AppendResult(interp, " -topmost ", buf, (char *) NULL); + return TCL_OK; + } + for (i = 3; i < argc; i += 2) { + length = strlen(argv[i]); + if ((length < 2) || (argv[i][0] != '-')) { + goto configArgs; + } + if ((i < argc-1) && + (Tcl_GetBoolean(interp, argv[i+1], &boolean) != TCL_OK)) { + return TCL_ERROR; + } + if (strncmp(argv[i], "-disabled", length) == 0) { + stylePtr = &style; + styleBit = WS_DISABLED; + } else if ((strncmp(argv[i], "-toolwindow", length) == 0) + && (length >= 3)) { + stylePtr = &exStyle; + styleBit = WS_EX_TOOLWINDOW; + } else if ((strncmp(argv[i], "-topmost", length) == 0) + && (length >= 3)) { + stylePtr = &exStyle; + styleBit = WS_EX_TOPMOST; + if ((i < argc-1) && + (winPtr->flags & TK_EMBEDDED)) { + Tcl_AppendResult(interp, "can't set topmost flag on ", + winPtr->pathName, ": it is an embedded window", + (char *) NULL); + return TCL_ERROR; + } + } else { + goto configArgs; + } + if (i == argc-1) { + Tcl_SetIntObj(Tcl_GetObjResult(interp), + ((*stylePtr & styleBit) != 0)); + } else if (boolean) { + *stylePtr |= styleBit; + } else { + *stylePtr &= ~styleBit; + } + } + if ((wmPtr->styleConfig != style) || + (wmPtr->exStyleConfig != exStyle)) { + wmPtr->styleConfig = style; + wmPtr->exStyleConfig = exStyle; + UpdateWrapper(winPtr); + } + return TCL_OK; + } else if ((c == 'a') && (strncmp(argv[1], "aspect", length) == 0) + && (length >= 2)) { int numer1, denom1, numer2, denom2; if ((argc != 3) && (argc != 7)) { @@ -3675,7 +3747,7 @@ TopLevelReqProc(dummy, tkwin) WmInfo *wmPtr; wmPtr = winPtr->wmInfoPtr; - if (winPtr->flags & TK_EMBEDDED) { + if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) { SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin), Tk_ReqHeight(tkwin)); } @@ -3726,7 +3798,8 @@ UpdateGeometryInfo(clientData) * state of the window changes. */ - if (IsIconic(wmPtr->wrapper) || IsZoomed(wmPtr->wrapper)) { + if ((wmPtr->wrapper == NULL) + || IsIconic(wmPtr->wrapper) || IsZoomed(wmPtr->wrapper)) { return; } -- cgit v0.12