📄 tkunixwm.c
字号:
wmPtr->gravity = NorthWestGravity; wmPtr->width = -1; wmPtr->height = -1; wmPtr->x = winPtr->changes.x; wmPtr->y = winPtr->changes.y; wmPtr->parentWidth = winPtr->changes.width + 2*winPtr->changes.border_width; wmPtr->parentHeight = winPtr->changes.height + 2*winPtr->changes.border_width; wmPtr->xInParent = wmPtr->yInParent = 0; wmPtr->configWidth = -1; wmPtr->configHeight = -1; wmPtr->vRoot = None; wmPtr->protPtr = NULL; wmPtr->cmdArgv = NULL; wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; wmPtr->nextPtr = firstWmPtr; firstWmPtr = wmPtr; winPtr->wmInfoPtr = wmPtr; UpdateVRootGeometry(wmPtr); /* * Arrange for geometry requests to be reflected from the window * to the window manager. */ Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0);}/* *-------------------------------------------------------------- * * TkWmMapWindow -- * * This procedure is invoked to map a top-level window. This * module gets a chance to update all window-manager-related * information in properties before the window manager sees * the map event and checks the properties. It also gets to * decide whether or not to even map the window after all. * * Results: * None. * * Side effects: * Properties of winPtr may get updated to provide up-to-date * information to the window manager. The window may also get * mapped, but it may not be if this procedure decides that * isn't appropriate (e.g. because the window is withdrawn). * *-------------------------------------------------------------- */voidTkWmMapWindow(winPtr) TkWindow *winPtr; /* Top-level window that's about to * be mapped. */{ register WmInfo *wmPtr = winPtr->wmInfoPtr; XTextProperty textProp; char *string; if (wmPtr->flags & WM_NEVER_MAPPED) { wmPtr->flags &= ~WM_NEVER_MAPPED; /* * This is the first time this window has ever been mapped. * First create the wrapper window that provides space for a * menubar. */ if (wmPtr->wrapperPtr == NULL) { CreateWrapper(wmPtr); } /* * Store all the window-manager-related information for the * window. */ string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid; if (XStringListToTextProperty(&string, 1, &textProp) != 0) { XSetWMName(winPtr->display, wmPtr->wrapperPtr->window, &textProp); XFree((char *) textProp.value); } TkWmSetClass(winPtr); if (wmPtr->iconName != NULL) { XSetIconName(winPtr->display, wmPtr->wrapperPtr->window, wmPtr->iconName); } if (wmPtr->master != None) { XSetTransientForHint(winPtr->display, wmPtr->wrapperPtr->window, wmPtr->master); } wmPtr->flags |= WM_UPDATE_SIZE_HINTS; UpdateHints(winPtr); UpdateWmProtocols(wmPtr); if (wmPtr->cmdArgv != NULL) { XSetCommand(winPtr->display, wmPtr->wrapperPtr->window, wmPtr->cmdArgv, wmPtr->cmdArgc); } if (wmPtr->clientMachine != NULL) { if (XStringListToTextProperty(&wmPtr->clientMachine, 1, &textProp) != 0) { XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window, &textProp); XFree((char *) textProp.value); } } } if (wmPtr->hints.initial_state == WithdrawnState) { return; } if (wmPtr->iconFor != NULL) { /* * This window is an icon for somebody else. Make sure that * the geometry is up-to-date, then return without mapping * the window. */ if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); } UpdateGeometryInfo((ClientData) winPtr); return; } wmPtr->flags |= WM_ABOUT_TO_MAP; if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); } UpdateGeometryInfo((ClientData) winPtr); wmPtr->flags &= ~WM_ABOUT_TO_MAP; /* * Map the window, then wait to be sure that the window manager has * processed the map operation. */ XMapWindow(winPtr->display, wmPtr->wrapperPtr->window); if (wmPtr->hints.initial_state == NormalState) { WaitForMapNotify(winPtr, 1); }}/* *-------------------------------------------------------------- * * TkWmUnmapWindow -- * * This procedure is invoked to unmap a top-level window. The * only thing it does special is to wait for the window actually * to be unmapped. * * Results: * None. * * Side effects: * Unmaps the window. * *-------------------------------------------------------------- */voidTkWmUnmapWindow(winPtr) TkWindow *winPtr; /* Top-level window that's about to * be mapped. */{ /* * It seems to be important to wait after unmapping a top-level * window until the window really gets unmapped. I don't completely * understand all the interactions with the window manager, but if * we go on without waiting, and if the window is then mapped again * quickly, events seem to get lost so that we think the window isn't * mapped when in fact it is mapped. I suspect that this has something * to do with the window manager filtering Map events (and possily not * filtering Unmap events?). */ XUnmapWindow(winPtr->display, winPtr->wmInfoPtr->wrapperPtr->window); WaitForMapNotify(winPtr, 0);}/* *-------------------------------------------------------------- * * TkWmDeadWindow -- * * This procedure is invoked when a top-level window is * about to be deleted. It cleans up the wm-related data * structures for the window. * * Results: * None. * * Side effects: * The WmInfo structure for winPtr gets freed up. * *-------------------------------------------------------------- */voidTkWmDeadWindow(winPtr) TkWindow *winPtr; /* Top-level window that's being deleted. */{ register WmInfo *wmPtr = winPtr->wmInfoPtr; WmInfo *wmPtr2; if (wmPtr == NULL) { return; } if (firstWmPtr == wmPtr) { firstWmPtr = wmPtr->nextPtr; } else { register WmInfo *prevPtr; for (prevPtr = firstWmPtr; ; prevPtr = prevPtr->nextPtr) { if (prevPtr == NULL) { panic("couldn't unlink window in TkWmDeadWindow"); } if (prevPtr->nextPtr == wmPtr) { prevPtr->nextPtr = wmPtr->nextPtr; break; } } } if (wmPtr->title != NULL) { ckfree(wmPtr->title); } if (wmPtr->iconName != NULL) { ckfree(wmPtr->iconName); } if (wmPtr->hints.flags & IconPixmapHint) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); } if (wmPtr->hints.flags & IconMaskHint) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); } if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } if (wmPtr->icon != NULL) { wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr2->iconFor = NULL; wmPtr2->withdrawn = 1; } if (wmPtr->iconFor != NULL) { wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr; wmPtr2->icon = NULL; wmPtr2->hints.flags &= ~IconWindowHint; UpdateHints((TkWindow *) wmPtr->iconFor); } if (wmPtr->menubar != NULL) { Tk_DestroyWindow(wmPtr->menubar); } if (wmPtr->wrapperPtr != NULL) { /* * The rest of Tk doesn't know that we reparent the toplevel * inside the wrapper, so reparent it back out again before * deleting the wrapper; otherwise the toplevel will get deleted * twice (once implicitly by the deletion of the wrapper). */ XUnmapWindow(winPtr->display, winPtr->window); XReparentWindow(winPtr->display, winPtr->window, XRootWindow(winPtr->display, winPtr->screenNum), 0, 0); Tk_DestroyWindow((Tk_Window) wmPtr->wrapperPtr); } while (wmPtr->protPtr != NULL) { ProtocolHandler *protPtr; protPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr->nextPtr; Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC); } if (wmPtr->cmdArgv != NULL) { ckfree((char *) wmPtr->cmdArgv); } if (wmPtr->clientMachine != NULL) { ckfree((char *) wmPtr->clientMachine); } if (wmPtr->flags & WM_UPDATE_PENDING) { Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); } ckfree((char *) wmPtr); winPtr->wmInfoPtr = NULL;}/* *-------------------------------------------------------------- * * TkWmSetClass -- * * This procedure is invoked whenever a top-level window's * class is changed. If the window has been mapped then this * procedure updates the window manager property for the * class. If the window hasn't been mapped, the update is * deferred until just before the first mapping. * * Results: * None. * * Side effects: * A window property may get updated. * *-------------------------------------------------------------- */voidTkWmSetClass(winPtr) TkWindow *winPtr; /* Newly-created top-level window. */{ if (winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { return; } if (winPtr->classUid != NULL) { XClassHint *classPtr; classPtr = XAllocClassHint(); classPtr->res_name = winPtr->nameUid; classPtr->res_class = winPtr->classUid; XSetClassHint(winPtr->display, winPtr->wmInfoPtr->wrapperPtr->window, classPtr); XFree((char *) classPtr); }}/* *---------------------------------------------------------------------- * * Tk_WmCmd -- * * This procedure is invoked to process the "wm" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */intTk_WmCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ char **argv; /* Argument strings. */{ Tk_Window tkwin = (Tk_Window) clientData; TkWindow *winPtr; register WmInfo *wmPtr; int c; size_t length; if (argc < 2) { wrongNumArgs: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option window ?arg ...?\"", (char *) NULL); return TCL_ERROR; } c = argv[1][0]; length = strlen(argv[1]); if ((c == 't') && (strncmp(argv[1], "tracing", length) == 0) && (length >= 3)) { if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # arguments: must be \"", argv[0], " tracing ?boolean?\"", (char *) NULL); return TCL_ERROR; } if (argc == 2) { interp->result = (wmTracing) ? "on" : "off"; return TCL_OK; } return Tcl_GetBoolean(interp, argv[2], &wmTracing); } if (argc < 3) { goto wrongNumArgs; } winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin); if (winPtr == NULL) { return TCL_ERROR; } if (!(winPtr->flags & TK_TOP_LEVEL)) { Tcl_AppendResult(interp, "window \"", winPtr->pathName, "\" isn't a top-level window", (char *) NULL); return TCL_ERROR; } wmPtr = winPtr->wmInfoPtr; if ((c == 'a') && (strncmp(argv[1], "aspect", length) == 0)) { int numer1, denom1, numer2, denom2; if ((argc != 3) && (argc != 7)) { Tcl_AppendResult(interp, "wrong # arguments: must be \"", argv[0], " aspect window ?minNumer minDenom ", "maxNumer maxDenom?\"", (char *) NULL); return TCL_ERROR; } if (argc == 3) { if (wmPtr->sizeHintsFlags & PAspect) { sprintf(interp->result, "%d %d %d %d", wmPtr->minAspect.x, wmPtr->minAspect.y, wmPtr->maxAspect.x, wmPtr->maxAspect.y); } return TCL_OK;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -