tkMacWm.c
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:164k
- /*
- * tkMacWm.c --
- *
- * This module takes care of the interactions between a Tk-based
- * application and the window manager. Among other things, it
- * implements the "wm" command and passes geometry information
- * to the window manager.
- *
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkMacWm.c,v 1.24.2.1 2005/12/01 18:31:43 dgp Exp $
- */
- #include <Gestalt.h>
- #include <QDOffscreen.h>
- #include <Windows.h>
- #include <ToolUtils.h>
- #include <tclMac.h>
- #include "tkPort.h"
- #include "tkInt.h"
- #include "tkMacInt.h"
- #include <errno.h>
- #include "tkScrollbar.h"
- /*
- * We now require the Appearance headers. They come with CodeWarrior Pro,
- * and are on the SDK CD. However, we do not require the Appearance
- * extension
- */
- #include <Appearance.h>
- /*
- * A data structure of the following type holds information for
- * each window manager protocol (such as WM_DELETE_WINDOW) for
- * which a handler (i.e. a Tcl command) has been defined for a
- * particular top-level window.
- */
- typedef struct ProtocolHandler {
- Atom protocol; /* Identifies the protocol. */
- struct ProtocolHandler *nextPtr;
- /* Next in list of protocol handlers for
- * the same top-level window, or NULL for
- * end of list. */
- Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- char command[4]; /* Tcl command to invoke when a client
- * message for this protocol arrives.
- * The actual size of the structure varies
- * to accommodate the needs of the actual
- * command. THIS MUST BE THE LAST FIELD OF
- * THE STRUCTURE. */
- } ProtocolHandler;
- #define HANDLER_SIZE(cmdLength)
- ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
- /*
- * A data structure of the following type holds window-manager-related
- * information for each top-level window in an application.
- */
- typedef struct TkWmInfo {
- TkWindow *winPtr; /* Pointer to main Tk information for
- * this window. */
- Window reparent; /* If the window has been reparented, this
- * gives the ID of the ancestor of the window
- * that is a child of the root window (may
- * not be window's immediate parent). If
- * the window isn't reparented, this has the
- * value None. */
- char *title; /* Title to display in window caption. If
- * NULL, use name of widget. Malloced. */
- char *iconName; /* Name to display in icon. Malloced. */
- Window master; /* Master window for TRANSIENT_FOR property,
- * or None. */
- XWMHints hints; /* Various pieces of information for
- * window manager. */
- char *leaderName; /* Path name of leader of window group
- * (corresponds to hints.window_group).
- * Malloc-ed. Note: this field doesn't
- * get updated if leader is destroyed. */
- char *masterWindowName; /* Path name of window specified as master
- * in "wm transient" command, or NULL.
- * Malloc-ed. Note: this field doesn't
- * get updated if masterWindowName is
- * destroyed. */
- Tk_Window icon; /* Window to use as icon for this window,
- * or NULL. */
- Tk_Window iconFor; /* Window for which this window is icon, or
- * NULL if this isn't an icon for anyone. */
- /*
- * Information used to construct an XSizeHints structure for
- * the window manager:
- */
- int sizeHintsFlags; /* Flags word for XSizeHints structure.
- * If the PBaseSize flag is set then the
- * window is gridded; otherwise it isn't
- * gridded. */
- int minWidth, minHeight; /* Minimum dimensions of window, in
- * grid units, not pixels. */
- int maxWidth, maxHeight; /* Maximum dimensions of window, in
- * grid units, not pixels. */
- Tk_Window gridWin; /* Identifies the window that controls
- * gridding for this top-level, or NULL if
- * the top-level isn't currently gridded. */
- int widthInc, heightInc; /* Increments for size changes (# pixels
- * per step). */
- struct {
- int x; /* numerator */
- int y; /* denominator */
- } minAspect, maxAspect; /* Min/max aspect ratios for window. */
- int reqGridWidth, reqGridHeight;
- /* The dimensions of the window (in
- * grid units) requested through
- * the geometry manager. */
- int gravity; /* Desired window gravity. */
- /*
- * Information used to manage the size and location of a window.
- */
- int width, height; /* Desired dimensions of window, specified
- * in grid units. These values are
- * set by the "wm geometry" command and by
- * ConfigureNotify events (for when wm
- * resizes window). -1 means user hasn't
- * requested dimensions. */
- int x, y; /* Desired X and Y coordinates for window.
- * These values are set by "wm geometry",
- * plus by ConfigureNotify events (when wm
- * moves window). These numbers are
- * different than the numbers stored in
- * winPtr->changes because (a) they could be
- * measured from the right or bottom edge
- * of the screen (see WM_NEGATIVE_X and
- * WM_NEGATIVE_Y flags) and (b) if the window
- * has been reparented then they refer to the
- * parent rather than the window itself. */
- int parentWidth, parentHeight;
- /* Width and height of reparent, in pixels
- * *including border*. If window hasn't been
- * reparented then these will be the outer
- * dimensions of the window, including
- * border. */
- int xInParent, yInParent; /* Offset of window within reparent, measured
- * from upper-left outer corner of parent's
- * border to upper-left outer corner of child's
- * border. If not reparented then these are
- * zero. */
- int configWidth, configHeight;
- /* Dimensions passed to last request that we
- * issued to change geometry of window. Used
- * to eliminate redundant resize operations. */
- /*
- * Information about the virtual root window for this top-level,
- * if there is one.
- */
- Window vRoot; /* Virtual root window for this top-level,
- * or None if there is no virtual root
- * window (i.e. just use the screen's root). */
- int vRootX, vRootY; /* Position of the virtual root inside the
- * root window. If the WM_VROOT_OFFSET_STALE
- * flag is set then this information may be
- * incorrect and needs to be refreshed from
- * the X server. If vRoot is None then these
- * values are both 0. */
- unsigned int vRootWidth, vRootHeight;
- /* Dimensions of the virtual root window.
- * If vRoot is None, gives the dimensions
- * of the containing screen. This information
- * is never stale, even though vRootX and
- * vRootY can be. */
- /*
- * List of children of the toplevel which have private colormaps.
- */
- TkWindow **cmapList; /* Array of window with private colormaps. */
- int cmapCount; /* Number of windows in array. */
- /*
- * Miscellaneous information.
- */
- ProtocolHandler *protPtr; /* First in list of protocol handlers for
- * this window (NULL means none). */
- int cmdArgc; /* Number of elements in cmdArgv below. */
- CONST char **cmdArgv; /* Array of strings to store in the
- * WM_COMMAND property. NULL means nothing
- * available. */
- char *clientMachine; /* String to store in WM_CLIENT_MACHINE
- * property, or NULL. */
- int flags; /* Miscellaneous flags, defined below. */
- /*
- * Macintosh information.
- */
- int style; /* Native window style. */
- int macClass;
- int attributes;
- TkWindow *scrollWinPtr; /* Ptr to scrollbar handling grow widget. */
- } WmInfo;
- /*
- * Flag values for WmInfo structures:
- *
- * WM_NEVER_MAPPED - non-zero means window has never been
- * mapped; need to update all info when
- * window is first mapped.
- * WM_UPDATE_PENDING - non-zero means a call to UpdateGeometryInfo
- * has already been scheduled for this
- * window; no need to schedule another one.
- * WM_NEGATIVE_X - non-zero means x-coordinate is measured in
- * pixels from right edge of screen, rather
- * than from left edge.
- * WM_NEGATIVE_Y - non-zero means y-coordinate is measured in
- * pixels up from bottom of screen, rather than
- * down from top.
- * WM_UPDATE_SIZE_HINTS - non-zero means that new size hints need to be
- * propagated to window manager.
- * WM_SYNC_PENDING - set to non-zero while waiting for the window
- * manager to respond to some state change.
- * WM_VROOT_OFFSET_STALE - non-zero means that (x,y) offset information
- * about the virtual root window is stale and
- * needs to be fetched fresh from the X server.
- * WM_ABOUT_TO_MAP - non-zero means that the window is about to
- * be mapped by TkWmMapWindow. This is used
- * by UpdateGeometryInfo to modify its behavior.
- * WM_MOVE_PENDING - non-zero means the application has requested
- * a new position for the window, but it hasn't
- * been reflected through the window manager
- * yet.
- * WM_COLORMAPS_EXPLICIT - non-zero means the colormap windows were
- * set explicitly via "wm colormapwindows".
- * WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows"
- * was called the top-level itself wasn't
- * specified, so we added it implicitly at
- * the end of the list.
- * WM_WIDTH_NOT_RESIZABLE - non-zero means that we're not supposed to
- * allow the user to change the width of the
- * window (controlled by "wm resizable"
- * command).
- * WM_HEIGHT_NOT_RESIZABLE - non-zero means that we're not supposed to
- * allow the user to change the height of the
- * window (controlled by "wm resizable"
- * command).
- */
- #define WM_NEVER_MAPPED 1
- #define WM_UPDATE_PENDING 2
- #define WM_NEGATIVE_X 4
- #define WM_NEGATIVE_Y 8
- #define WM_UPDATE_SIZE_HINTS 0x10
- #define WM_SYNC_PENDING 0x20
- #define WM_VROOT_OFFSET_STALE 0x40
- #define WM_ABOUT_TO_MAP 0x100
- #define WM_MOVE_PENDING 0x200
- #define WM_COLORMAPS_EXPLICIT 0x400
- #define WM_ADDED_TOPLEVEL_COLORMAP 0x800
- #define WM_WIDTH_NOT_RESIZABLE 0x1000
- #define WM_HEIGHT_NOT_RESIZABLE 0x2000
- /*
- * This is a list of all of the toplevels that have been mapped so far. It is
- * used by the menu code to inval windows that were damaged by menus, and will
- * eventually also be used to keep track of floating windows.
- */
- TkMacWindowList *tkMacWindowListPtr = NULL;
- /*
- * The variable below is 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.
- */
- static int wmTracing = 0;
- /*
- * The following structure is the official type record for geometry
- * management of top-level windows.
- */
- static void TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
- Tk_Window tkwin));
- static Tk_GeomMgr wmMgrType = {
- "wm", /* name */
- TopLevelReqProc, /* requestProc */
- (Tk_GeomLostSlaveProc *) NULL, /* lostSlaveProc */
- };
- /*
- * Hash table for Mac Window -> TkWindow mapping.
- */
- static Tcl_HashTable windowTable;
- static int windowHashInit = false;
- void tkMacMoveWindow(WindowRef window, int x, int y);
- /*
- * Forward declarations for procedures defined in this file:
- */
- static void InitialWindowBounds _ANSI_ARGS_((TkWindow *winPtr,
- Rect *geometry));
- static int ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, TkWindow *winPtr));
- static void TopLevelEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
- static void TkWmStackorderToplevelWrapperMap _ANSI_ARGS_((
- TkWindow *winPtr,
- Tcl_HashTable *reparentTable));
- static void TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
- Tk_Window tkwin));
- static void UpdateGeometryInfo _ANSI_ARGS_((
- ClientData clientData));
- static void UpdateSizeHints _ANSI_ARGS_((TkWindow *winPtr));
- static void UpdateVRootGeometry _ANSI_ARGS_((WmInfo *wmPtr));
- static int WmAspectCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmAttributesCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmClientCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmColormapwindowsCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmCommandCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmDeiconifyCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmFocusmodelCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmFrameCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmGeometryCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmGridCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmGroupCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmIconbitmapCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmIconifyCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmIconmaskCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmIconnameCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmIconpositionCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmIconwindowCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmMaxsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmMinsizeCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmOverrideredirectCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmPositionfromCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmProtocolCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmResizableCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmSizefromCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmStackorderCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmStateCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmTitleCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmTransientCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static int WmWithdrawCmd _ANSI_ARGS_((Tk_Window tkwin,
- TkWindow *winPtr, Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
- static void WmUpdateGeom _ANSI_ARGS_((WmInfo *wmPtr,
- TkWindow *winPtr));
- /*
- *--------------------------------------------------------------
- *
- * TkWmNewWindow --
- *
- * This procedure is invoked whenever a new top-level
- * window is created. Its job is to initialize the WmInfo
- * structure for the window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A WmInfo structure gets allocated and initialized.
- *
- *--------------------------------------------------------------
- */
- void
- TkWmNewWindow(
- TkWindow *winPtr) /* Newly-created top-level window. */
- {
- register WmInfo *wmPtr;
- wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo));
- wmPtr->winPtr = winPtr;
- wmPtr->reparent = None;
- wmPtr->title = NULL;
- wmPtr->iconName = NULL;
- wmPtr->master = None;
- wmPtr->hints.flags = InputHint | StateHint;
- wmPtr->hints.input = True;
- wmPtr->hints.initial_state = NormalState;
- wmPtr->hints.icon_pixmap = None;
- wmPtr->hints.icon_window = None;
- wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0;
- wmPtr->hints.icon_mask = None;
- wmPtr->hints.window_group = None;
- wmPtr->leaderName = NULL;
- wmPtr->masterWindowName = NULL;
- wmPtr->icon = NULL;
- wmPtr->iconFor = NULL;
- wmPtr->sizeHintsFlags = 0;
- wmPtr->minWidth = wmPtr->minHeight = 1;
- /*
- * Default the maximum dimensions to the size of the display, minus
- * a guess about how space is needed for window manager decorations.
- */
- wmPtr->maxWidth = DisplayWidth(winPtr->display, winPtr->screenNum) - 15;
- wmPtr->maxHeight = DisplayHeight(winPtr->display, winPtr->screenNum) - 30;
- wmPtr->gridWin = NULL;
- wmPtr->widthInc = wmPtr->heightInc = 1;
- wmPtr->minAspect.x = wmPtr->minAspect.y = 1;
- wmPtr->maxAspect.x = wmPtr->maxAspect.y = 1;
- wmPtr->reqGridWidth = wmPtr->reqGridHeight = -1;
- 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 = 0;
- wmPtr->yInParent = 0;
- wmPtr->cmapList = NULL;
- wmPtr->cmapCount = 0;
- wmPtr->configWidth = -1;
- wmPtr->configHeight = -1;
- wmPtr->vRoot = None;
- wmPtr->protPtr = NULL;
- wmPtr->cmdArgv = NULL;
- wmPtr->clientMachine = NULL;
- wmPtr->flags = WM_NEVER_MAPPED;
- if (TkMacHaveAppearance() >= 0x110) {
- wmPtr->style = -1;
- } else {
- wmPtr->style = documentProc;
- }
- wmPtr->macClass = kDocumentWindowClass;
- wmPtr->attributes = kWindowStandardDocumentAttributes;
- wmPtr->scrollWinPtr = NULL;
- winPtr->wmInfoPtr = wmPtr;
- UpdateVRootGeometry(wmPtr);
- /*
- * Tk must monitor structure events for top-level windows, in order
- * to detect size and position changes caused by window managers.
- */
- Tk_CreateEventHandler((Tk_Window) winPtr, StructureNotifyMask,
- TopLevelEventProc, (ClientData) winPtr);
- /*
- * 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).
- *
- *--------------------------------------------------------------
- */
- void
- TkWmMapWindow(
- TkWindow *winPtr) /* Top-level window that's about to
- * be mapped. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- Point where = {0, 0};
- int xOffset, yOffset;
- int firstMap = false;
- MacDrawable *macWin;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- wmPtr->flags &= ~WM_NEVER_MAPPED;
- firstMap = true;
- /*
- * Create the underlying Mac window for this Tk window.
- */
- macWin = (MacDrawable *) winPtr->window;
- if (!TkMacHostToplevelExists(winPtr)) {
- TkMacMakeRealWindowExist(winPtr);
- }
- /*
- * Generate configure event when we first map the window.
- */
- LocalToGlobal(&where);
- TkMacWindowOffset((WindowRef) TkMacGetDrawablePort((Drawable) macWin),
- &xOffset, &yOffset);
- where.h -= xOffset;
- where.v -= yOffset;
- TkGenWMConfigureEvent((Tk_Window) winPtr,
- where.h, where.v, -1, -1, TK_LOCATION_CHANGED);
- /*
- * This is the first time this window has ever been mapped.
- * Store all the window-manager-related information for the
- * window.
- */
- if (!Tk_IsEmbedded(winPtr)) {
- TkSetWMName(winPtr, ((wmPtr->title != NULL) ?
- wmPtr->title : winPtr->nameUid));
- }
- TkWmSetClass(winPtr);
- if (wmPtr->iconName != NULL) {
- XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
- }
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- }
- if (wmPtr->hints.initial_state == WithdrawnState) {
- return;
- }
- /*
- * TODO: we need to display a window if it's iconic on creation.
- */
- if (wmPtr->hints.initial_state == IconicState) {
- return;
- }
- /*
- * Update geometry information.
- */
- wmPtr->flags |= WM_ABOUT_TO_MAP;
- if (wmPtr->flags & WM_UPDATE_PENDING) {
- Tk_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
- }
- UpdateGeometryInfo((ClientData) winPtr);
- wmPtr->flags &= ~WM_ABOUT_TO_MAP;
- /*
- * Map the window.
- */
- XMapWindow(winPtr->display, winPtr->window);
- /*
- * Now that the window is visable we can determine the offset
- * from the window's content orgin to the window's decorative
- * orgin (structure orgin).
- */
- TkMacWindowOffset((WindowRef) TkMacGetDrawablePort(Tk_WindowId(winPtr)),
- &wmPtr->xInParent, &wmPtr->yInParent);
- }
- /*
- *--------------------------------------------------------------
- *
- * TkWmUnmapWindow --
- *
- * This procedure is invoked to unmap a top-level window.
- * On the Macintosh all we do is call XUnmapWindow.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Unmaps the window.
- *
- *--------------------------------------------------------------
- */
- void
- TkWmUnmapWindow(
- TkWindow *winPtr) /* Top-level window that's about to
- * be mapped. */
- {
- XUnmapWindow(winPtr->display, winPtr->window);
- }
- /*
- *--------------------------------------------------------------
- *
- * 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.
- *
- *--------------------------------------------------------------
- */
- void
- TkWmDeadWindow(winPtr)
- TkWindow *winPtr; /* Top-level window that's being deleted. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- WmInfo *wmPtr2;
- if (wmPtr == NULL) {
- return;
- }
- 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;
- }
- if (wmPtr->iconFor != NULL) {
- wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr;
- wmPtr2->icon = NULL;
- wmPtr2->hints.flags &= ~IconWindowHint;
- }
- 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) {
- Tk_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.
- *
- *--------------------------------------------------------------
- */
- void
- TkWmSetClass(
- TkWindow *winPtr) /* Newly-created top-level window. */
- {
- return;
- }
- /*
- *----------------------------------------------------------------------
- *
- * Tk_WmObjCmd --
- *
- * 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 */
- int
- Tk_WmObjCmd(
- ClientData clientData, /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
- {
- Tk_Window tkwin = (Tk_Window) clientData;
- static CONST char *optionStrings[] = {
- "aspect", "attributes", "client", "colormapwindows",
- "command", "deiconify", "focusmodel", "frame",
- "geometry", "grid", "group", "iconbitmap",
- "iconify", "iconmask", "iconname", "iconposition",
- "iconwindow", "maxsize", "minsize", "overrideredirect",
- "positionfrom", "protocol", "resizable", "sizefrom",
- "stackorder", "state", "title", "transient",
- "withdraw", (char *) NULL };
- enum options {
- 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_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_WITHDRAW };
- int index, length;
- char *argv1;
- TkWindow *winPtr;
- TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (objc < 2) {
- wrongNumArgs:
- Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?");
- return TCL_ERROR;
- }
- argv1 = Tcl_GetStringFromObj(objv[1], &length);
- if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0)
- && (length >= 3)) {
- if ((objc != 2) && (objc != 3)) {
- Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
- return TCL_ERROR;
- }
- if (objc == 2) {
- Tcl_SetResult(interp, ((wmTracing) ? "on" : "off"), TCL_STATIC);
- return TCL_OK;
- }
- return Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing);
- }
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if (objc < 3) {
- goto wrongNumArgs;
- }
- if (TkGetWindowFromObj(interp, tkwin, objv[2], (Tk_Window *) &winPtr)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (!Tk_IsTopLevel(winPtr)) {
- Tcl_AppendResult(interp, "window "", winPtr->pathName,
- "" isn't a top-level window", (char *) NULL);
- return TCL_ERROR;
- }
- switch ((enum options) index) {
- case WMOPT_ASPECT:
- return WmAspectCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ATTRIBUTES:
- return WmAttributesCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_CLIENT:
- return WmClientCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_COLORMAPWINDOWS:
- return WmColormapwindowsCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_COMMAND:
- return WmCommandCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_DEICONIFY:
- return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_FOCUSMODEL:
- return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_FRAME:
- return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_GEOMETRY:
- return WmGeometryCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_GRID:
- return WmGridCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_GROUP:
- return WmGroupCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONBITMAP:
- return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONIFY:
- return WmIconifyCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONMASK:
- return WmIconmaskCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONNAME:
- return WmIconnameCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONPOSITION:
- return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_ICONWINDOW:
- return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_MAXSIZE:
- return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_MINSIZE:
- return WmMinsizeCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_OVERRIDEREDIRECT:
- return WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_POSITIONFROM:
- return WmPositionfromCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_PROTOCOL:
- return WmProtocolCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_RESIZABLE:
- return WmResizableCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_SIZEFROM:
- return WmSizefromCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_STACKORDER:
- return WmStackorderCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_STATE:
- return WmStateCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_TITLE:
- return WmTitleCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_TRANSIENT:
- return WmTransientCmd(tkwin, winPtr, interp, objc, objv);
- case WMOPT_WITHDRAW:
- return WmWithdrawCmd(tkwin, winPtr, interp, objc, objv);
- }
- /* This should not happen */
- return TCL_ERROR;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmAspectCmd --
- *
- * This procedure is invoked to process the "wm aspect" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmAspectCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int numer1, denom1, numer2, denom2;
- if ((objc != 3) && (objc != 7)) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "window ?minNumer minDenom maxNumer maxDenom?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->sizeHintsFlags & PAspect) {
- char buf[TCL_INTEGER_SPACE * 4];
- sprintf(buf, "%d %d %d %d", wmPtr->minAspect.x,
- wmPtr->minAspect.y, wmPtr->maxAspect.x,
- wmPtr->maxAspect.y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- }
- return TCL_OK;
- }
- if (*Tcl_GetString(objv[3]) == ' ') {
- wmPtr->sizeHintsFlags &= ~PAspect;
- } else {
- if ((Tcl_GetIntFromObj(interp, objv[3], &numer1) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &denom1) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[5], &numer2) != TCL_OK)
- || (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);
- return TCL_ERROR;
- }
- wmPtr->minAspect.x = numer1;
- wmPtr->minAspect.y = denom1;
- wmPtr->maxAspect.x = numer2;
- wmPtr->maxAspect.y = denom2;
- wmPtr->sizeHintsFlags |= PAspect;
- }
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmAttributesCmd --
- *
- * This procedure is invoked to process the "wm attributes" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmClientCmd --
- *
- * This procedure is invoked to process the "wm client" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmClientCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
- int length;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->clientMachine != NULL) {
- Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC);
- }
- return TCL_OK;
- }
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- if (argv3[0] == 0) {
- if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
- wmPtr->clientMachine = NULL;
- }
- return TCL_OK;
- }
- if (wmPtr->clientMachine != NULL) {
- ckfree((char *) wmPtr->clientMachine);
- }
- wmPtr->clientMachine = (char *)
- ckalloc((unsigned) (length + 1));
- strcpy(wmPtr->clientMachine, argv3);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmColormapwindowsCmd --
- *
- * This procedure is invoked to process the "wm colormapwindows"
- * Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmColormapwindowsCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- TkWindow **cmapList;
- TkWindow *winPtr2;
- int i, windowObjc, gotToplevel = 0;
- Tcl_Obj **windowObjv;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- Tk_MakeWindowExist((Tk_Window) winPtr);
- for (i = 0; i < wmPtr->cmapCount; i++) {
- if ((i == (wmPtr->cmapCount-1))
- && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) {
- break;
- }
- Tcl_AppendElement(interp, wmPtr->cmapList[i]->pathName);
- }
- return TCL_OK;
- }
- if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv)
- != TCL_OK) {
- return TCL_ERROR;
- }
- cmapList = (TkWindow **) ckalloc((unsigned)
- ((windowObjc+1)*sizeof(TkWindow*)));
- for (i = 0; i < windowObjc; i++) {
- if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
- (Tk_Window *) &winPtr2) != TCL_OK)
- {
- ckfree((char *) cmapList);
- return TCL_ERROR;
- }
- if (winPtr2 == winPtr) {
- gotToplevel = 1;
- }
- if (winPtr2->window == None) {
- Tk_MakeWindowExist((Tk_Window) winPtr2);
- }
- cmapList[i] = winPtr2;
- }
- if (!gotToplevel) {
- wmPtr->flags |= WM_ADDED_TOPLEVEL_COLORMAP;
- cmapList[windowObjc] = winPtr;
- windowObjc++;
- } else {
- wmPtr->flags &= ~WM_ADDED_TOPLEVEL_COLORMAP;
- }
- wmPtr->flags |= WM_COLORMAPS_EXPLICIT;
- if (wmPtr->cmapList != NULL) {
- ckfree((char *)wmPtr->cmapList);
- }
- wmPtr->cmapList = cmapList;
- wmPtr->cmapCount = windowObjc;
- /*
- * On the Macintosh all of this is just an excercise
- * in compatability as we don't support colormaps. If
- * we did they would be installed here.
- */
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmCommandCmd --
- *
- * This procedure is invoked to process the "wm command" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmCommandCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
- int cmdArgc;
- CONST char **cmdArgv;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->cmdArgv != NULL) {
- Tcl_SetResult(interp,
- Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv),
- TCL_DYNAMIC);
- }
- return TCL_OK;
- }
- argv3 = Tcl_GetString(objv[3]);
- if (argv3[0] == 0) {
- if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
- wmPtr->cmdArgv = NULL;
- }
- return TCL_OK;
- }
- if (Tcl_SplitList(interp, argv3, &cmdArgc, &cmdArgv) != TCL_OK) {
- return TCL_ERROR;
- }
- if (wmPtr->cmdArgv != NULL) {
- ckfree((char *) wmPtr->cmdArgv);
- }
- wmPtr->cmdArgc = cmdArgc;
- wmPtr->cmdArgv = cmdArgv;
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmDeiconifyCmd --
- *
- * This procedure is invoked to process the "wm deiconify" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't deiconify ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
- if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't deiconify ", winPtr->pathName,
- ": it is an embedded window", (char *) NULL);
- return TCL_ERROR;
- }
- /*
- * TODO: may not want to call this function - look at Map events gened.
- */
- TkpWmSetState(winPtr, NormalState);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmFocusmodelCmd --
- *
- * This procedure is invoked to process the "wm focusmodel" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
- "active", "passive", (char *) NULL };
- enum options {
- OPT_ACTIVE, OPT_PASSIVE };
- int index;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- Tcl_SetResult(interp, (wmPtr->hints.input ? "passive" : "active"),
- TCL_STATIC);
- return TCL_OK;
- }
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if (index == OPT_ACTIVE) {
- wmPtr->hints.input = False;
- } else { /* OPT_PASSIVE */
- wmPtr->hints.input = True;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmFrameCmd --
- *
- * This procedure is invoked to process the "wm frame" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmFrameCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- Window window;
- char buf[TCL_INTEGER_SPACE];
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- window = wmPtr->reparent;
- if (window == None) {
- window = Tk_WindowId((Tk_Window) winPtr);
- }
- sprintf(buf, "0x%x", (unsigned int) window);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmGeometryCmd --
- *
- * This procedure is invoked to process the "wm geometry" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmGeometryCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char xSign, ySign;
- int width, height;
- char *argv3;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- char buf[16 + TCL_INTEGER_SPACE * 4];
- xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+';
- ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+';
- if (wmPtr->gridWin != NULL) {
- width = wmPtr->reqGridWidth + (winPtr->changes.width
- - winPtr->reqWidth)/wmPtr->widthInc;
- height = wmPtr->reqGridHeight + (winPtr->changes.height
- - winPtr->reqHeight)/wmPtr->heightInc;
- } else {
- width = winPtr->changes.width;
- height = winPtr->changes.height;
- }
- sprintf(buf, "%dx%d%c%d%c%d", width, height, xSign, wmPtr->x,
- ySign, wmPtr->y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return TCL_OK;
- }
- argv3 = Tcl_GetString(objv[3]);
- if (*argv3 == ' ') {
- wmPtr->width = -1;
- wmPtr->height = -1;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- return ParseGeometry(interp, argv3, winPtr);
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmGridCmd --
- *
- * This procedure is invoked to process the "wm grid" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmGridCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int reqWidth, reqHeight, widthInc, heightInc;
- if ((objc != 3) && (objc != 7)) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "window ?baseWidth baseHeight widthInc heightInc?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->sizeHintsFlags & PBaseSize) {
- char buf[TCL_INTEGER_SPACE * 4];
- sprintf(buf, "%d %d %d %d", wmPtr->reqGridWidth,
- wmPtr->reqGridHeight, wmPtr->widthInc,
- wmPtr->heightInc);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- }
- return TCL_OK;
- }
- if (*Tcl_GetString(objv[3]) == ' ') {
- /*
- * Turn off gridding and reset the width and height
- * to make sense as ungridded numbers.
- */
- wmPtr->sizeHintsFlags &= ~(PBaseSize|PResizeInc);
- if (wmPtr->width != -1) {
- wmPtr->width = winPtr->reqWidth + (wmPtr->width
- - wmPtr->reqGridWidth)*wmPtr->widthInc;
- wmPtr->height = winPtr->reqHeight + (wmPtr->height
- - wmPtr->reqGridHeight)*wmPtr->heightInc;
- }
- wmPtr->widthInc = 1;
- wmPtr->heightInc = 1;
- } else {
- if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[6], &heightInc) != TCL_OK)) {
- return TCL_ERROR;
- }
- if (reqWidth < 0) {
- Tcl_SetResult(interp, "baseWidth can't be < 0", TCL_STATIC);
- return TCL_ERROR;
- }
- if (reqHeight < 0) {
- Tcl_SetResult(interp, "baseHeight can't be < 0", TCL_STATIC);
- return TCL_ERROR;
- }
- if (widthInc <= 0) {
- Tcl_SetResult(interp, "widthInc can't be <= 0", TCL_STATIC);
- return TCL_ERROR;
- }
- if (heightInc <= 0) {
- Tcl_SetResult(interp, "heightInc can't be <= 0", TCL_STATIC);
- return TCL_ERROR;
- }
- Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
- heightInc);
- }
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmGroupCmd --
- *
- * This procedure is invoked to process the "wm group" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmGroupCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- Tk_Window tkwin2;
- char *argv3;
- int length;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->hints.flags & WindowGroupHint) {
- Tcl_SetResult(interp, wmPtr->leaderName, TCL_STATIC);
- }
- return TCL_OK;
- }
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- if (*argv3 == ' ') {
- wmPtr->hints.flags &= ~WindowGroupHint;
- if (wmPtr->leaderName != NULL) {
- ckfree(wmPtr->leaderName);
- }
- wmPtr->leaderName = NULL;
- } else {
- if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) {
- return TCL_ERROR;
- }
- Tk_MakeWindowExist(tkwin2);
- if (wmPtr->leaderName != NULL) {
- ckfree(wmPtr->leaderName);
- }
- wmPtr->hints.window_group = Tk_WindowId(tkwin2);
- wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc((unsigned) (length + 1));
- strcpy(wmPtr->leaderName, argv3);
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmIconbitmapCmd --
- *
- * This procedure is invoked to process the "wm iconbitmap" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
- Pixmap pixmap;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->hints.flags & IconPixmapHint) {
- Tcl_SetResult(interp, (char *)
- Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),
- TCL_STATIC);
- }
- return TCL_OK;
- }
- argv3 = Tcl_GetString(objv[3]);
- if (*argv3 == ' ') {
- if (wmPtr->hints.icon_pixmap != None) {
- Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
- wmPtr->hints.icon_pixmap = None;
- }
- wmPtr->hints.flags &= ~IconPixmapHint;
- } else {
- pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, argv3);
- if (pixmap == None) {
- return TCL_ERROR;
- }
- wmPtr->hints.icon_pixmap = pixmap;
- wmPtr->hints.flags |= IconPixmapHint;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmIconifyCmd --
- *
- * This procedure is invoked to process the "wm iconify" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmIconifyCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify "", winPtr->pathName,
- "": override-redirect flag is set", (char *) NULL);
- return TCL_ERROR;
- }
- if (wmPtr->master != None) {
- Tcl_AppendResult(interp, "can't iconify "", winPtr->pathName,
- "": it is a transient", (char *) NULL);
- return TCL_ERROR;
- }
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
- if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an embedded window", (char *) NULL);
- return TCL_ERROR;
- }
- TkpWmSetState(winPtr, IconicState);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmIconmaskCmd --
- *
- * This procedure is invoked to process the "wm iconmask" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmIconmaskCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- Pixmap pixmap;
- char *argv3;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->hints.flags & IconMaskHint) {
- Tcl_SetResult(interp, (char *)
- Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask),
- TCL_STATIC);
- }
- return TCL_OK;
- }
- argv3 = Tcl_GetString(objv[3]);
- if (*argv3 == ' ') {
- if (wmPtr->hints.icon_mask != None) {
- Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask);
- }
- wmPtr->hints.flags &= ~IconMaskHint;
- } else {
- pixmap = Tk_GetBitmap(interp, tkwin, argv3);
- if (pixmap == None) {
- return TCL_ERROR;
- }
- wmPtr->hints.icon_mask = pixmap;
- wmPtr->hints.flags |= IconMaskHint;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmIconnameCmd --
- *
- * This procedure is invoked to process the "wm iconname" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmIconnameCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
- int length;
- if (objc > 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- Tcl_SetResult(interp,
- ((wmPtr->iconName != NULL) ? wmPtr->iconName : ""),
- TCL_STATIC);
- return TCL_OK;
- } else {
- if (wmPtr->iconName != NULL) {
- ckfree((char *) wmPtr->iconName);
- }
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->iconName = ckalloc((unsigned) (length + 1));
- strcpy(wmPtr->iconName, argv3);
- if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
- XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
- }
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmIconpositionCmd --
- *
- * This procedure is invoked to process the "wm iconposition"
- * Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmIconpositionCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int x, y;
- if ((objc != 3) && (objc != 5)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->hints.flags & IconPositionHint) {
- char buf[TCL_INTEGER_SPACE * 2];
- sprintf(buf, "%d %d", wmPtr->hints.icon_x,
- wmPtr->hints.icon_y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- }
- return TCL_OK;
- }
- if (*Tcl_GetString(objv[3]) == ' ') {
- wmPtr->hints.flags &= ~IconPositionHint;
- } else {
- if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){
- return TCL_ERROR;
- }
- wmPtr->hints.icon_x = x;
- wmPtr->hints.icon_y = y;
- wmPtr->hints.flags |= IconPositionHint;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmIconwindowCmd --
- *
- * This procedure is invoked to process the "wm iconwindow" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmIconwindowCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- Tk_Window tkwin2;
- WmInfo *wmPtr2;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->icon != NULL) {
- Tcl_SetResult(interp, Tk_PathName(wmPtr->icon), TCL_STATIC);
- }
- return TCL_OK;
- }
- if (*Tcl_GetString(objv[3]) == ' ') {
- wmPtr->hints.flags &= ~IconWindowHint;
- if (wmPtr->icon != NULL) {
- wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;
- wmPtr2->iconFor = NULL;
- wmPtr2->hints.initial_state = WithdrawnState;
- }
- wmPtr->icon = NULL;
- } else {
- if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) {
- return TCL_ERROR;
- }
- if (!Tk_IsTopLevel(tkwin2)) {
- Tcl_AppendResult(interp, "can't use ", Tcl_GetString(objv[3]),
- " as icon window: not at top level", (char *) NULL);
- return TCL_ERROR;
- }
- wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
- if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, Tcl_GetString(objv[3]),
- " is already an icon for ",
- Tk_PathName(wmPtr2->iconFor), (char *) NULL);
- return TCL_ERROR;
- }
- if (wmPtr->icon != NULL) {
- WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;
- wmPtr3->iconFor = NULL;
- }
- Tk_MakeWindowExist(tkwin2);
- wmPtr->hints.icon_window = Tk_WindowId(tkwin2);
- wmPtr->hints.flags |= IconWindowHint;
- wmPtr->icon = tkwin2;
- wmPtr2->iconFor = (Tk_Window) winPtr;
- if (!(wmPtr2->flags & WM_NEVER_MAPPED)) {
- /*
- * Don't have iconwindows on the Mac. We just withdraw.
- */
- Tk_UnmapWindow(tkwin2);
- }
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmMaxsizeCmd --
- *
- * This procedure is invoked to process the "wm maxsize" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int width, height;
- if ((objc != 3) && (objc != 5)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
- sprintf(buf, "%d %d", wmPtr->maxWidth, wmPtr->maxHeight);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return TCL_OK;
- }
- if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) {
- return TCL_ERROR;
- }
- wmPtr->maxWidth = width;
- wmPtr->maxHeight = height;
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmMinsizeCmd --
- *
- * This procedure is invoked to process the "wm minsize" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmMinsizeCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int width, height;
- if ((objc != 3) && (objc != 5)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
- sprintf(buf, "%d %d", wmPtr->minWidth, wmPtr->minHeight);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return TCL_OK;
- }
- if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) {
- return TCL_ERROR;
- }
- wmPtr->minWidth = width;
- wmPtr->minHeight = height;
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmOverrideredirectCmd --
- *
- * This procedure is invoked to process the "wm overrideredirect"
- * Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int boolean;
- XSetWindowAttributes atts;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- Tcl_SetBooleanObj(Tcl_GetObjResult(interp),
- Tk_Attributes((Tk_Window) winPtr)->override_redirect);
- return TCL_OK;
- }
- if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) {
- return TCL_ERROR;
- }
- atts.override_redirect = (boolean) ? True : False;
- Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect,
- &atts);
- wmPtr->style = (boolean) ? plainDBox : documentProc;
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmPositionfromCmd --
- *
- * This procedure is invoked to process the "wm positionfrom"
- * Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmPositionfromCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
- "program", "user", (char *) NULL };
- enum options {
- OPT_PROGRAM, OPT_USER };
- int index;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->sizeHintsFlags & USPosition) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
- } else if (wmPtr->sizeHintsFlags & PPosition) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
- }
- return TCL_OK;
- }
- if (*Tcl_GetString(objv[3]) == ' ') {
- wmPtr->sizeHintsFlags &= ~(USPosition|PPosition);
- } else {
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if (index == OPT_USER) {
- wmPtr->sizeHintsFlags &= ~PPosition;
- wmPtr->sizeHintsFlags |= USPosition;
- } else {
- wmPtr->sizeHintsFlags &= ~USPosition;
- wmPtr->sizeHintsFlags |= PPosition;
- }
- }
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmProtocolCmd --
- *
- * This procedure is invoked to process the "wm protocol" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmProtocolCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- register ProtocolHandler *protPtr, *prevPtr;
- Atom protocol;
- char *cmd;
- int cmdLength;
- if ((objc < 3) || (objc > 5)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- /*
- * Return a list of all defined protocols for the window.
- */
- for (protPtr = wmPtr->protPtr; protPtr != NULL;
- protPtr = protPtr->nextPtr) {
- Tcl_AppendElement(interp,
- Tk_GetAtomName((Tk_Window) winPtr, protPtr->protocol));
- }
- return TCL_OK;
- }
- protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3]));
- if (objc == 4) {
- /*
- * Return the command to handle a given protocol.
- */
- for (protPtr = wmPtr->protPtr; protPtr != NULL;
- protPtr = protPtr->nextPtr) {
- if (protPtr->protocol == protocol) {
- Tcl_SetResult(interp, protPtr->command, TCL_STATIC);
- return TCL_OK;
- }
- }
- return TCL_OK;
- }
- /*
- * Delete any current protocol handler, then create a new
- * one with the specified command, unless the command is
- * empty.
- */
- for (protPtr = wmPtr->protPtr, prevPtr = NULL; protPtr != NULL;
- prevPtr = protPtr, protPtr = protPtr->nextPtr) {
- if (protPtr->protocol == protocol) {
- if (prevPtr == NULL) {
- wmPtr->protPtr = protPtr->nextPtr;
- } else {
- prevPtr->nextPtr = protPtr->nextPtr;
- }
- Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);
- break;
- }
- }
- cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
- if (cmdLength > 0) {
- protPtr = (ProtocolHandler *) ckalloc(HANDLER_SIZE(cmdLength));
- protPtr->protocol = protocol;
- protPtr->nextPtr = wmPtr->protPtr;
- wmPtr->protPtr = protPtr;
- protPtr->interp = interp;
- strcpy(protPtr->command, cmd);
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmResizableCmd --
- *
- * This procedure is invoked to process the "wm resizable" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmResizableCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- int width, height;
- if ((objc != 3) && (objc != 5)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- 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);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return TCL_OK;
- }
- if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK)
- || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) {
- return TCL_ERROR;
- }
- if (width) {
- wmPtr->flags &= ~WM_WIDTH_NOT_RESIZABLE;
- } else {
- wmPtr->flags |= WM_WIDTH_NOT_RESIZABLE;
- }
- if (height) {
- wmPtr->flags &= ~WM_HEIGHT_NOT_RESIZABLE;
- } else {
- wmPtr->flags |= WM_HEIGHT_NOT_RESIZABLE;
- }
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- if (wmPtr->scrollWinPtr != NULL) {
- TkScrollbarEventuallyRedraw(
- (TkScrollbar *) wmPtr->scrollWinPtr->instanceData);
- }
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmSizefromCmd --
- *
- * This procedure is invoked to process the "wm sizefrom" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmSizefromCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
- "program", "user", (char *) NULL };
- enum options {
- OPT_PROGRAM, OPT_USER };
- int index;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->sizeHintsFlags & USSize) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
- } else if (wmPtr->sizeHintsFlags & PSize) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
- }
- return TCL_OK;
- }
- if (*Tcl_GetString(objv[3]) == ' ') {
- wmPtr->sizeHintsFlags &= ~(USSize|PSize);
- } else {
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if (index == OPT_USER) {
- wmPtr->sizeHintsFlags &= ~PSize;
- wmPtr->sizeHintsFlags |= USSize;
- } else { /* OPT_PROGRAM */
- wmPtr->sizeHintsFlags &= ~USSize;
- wmPtr->sizeHintsFlags |= PSize;
- }
- }
- wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
- WmUpdateGeom(wmPtr, winPtr);
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmStackorderCmd --
- *
- * This procedure is invoked to process the "wm stackorder" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmStackorderCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- TkWindow **windows, **window_ptr;
- static CONST char *optionStrings[] = {
- "isabove", "isbelow", (char *) NULL };
- enum options {
- OPT_ISABOVE, OPT_ISBELOW };
- int index;
- if ((objc != 3) && (objc != 5)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- windows = TkWmStackorderToplevel(winPtr);
- if (windows == NULL) {
- panic("TkWmStackorderToplevel failed");
- } else {
- for (window_ptr = windows; *window_ptr ; window_ptr++) {
- Tcl_AppendElement(interp, (*window_ptr)->pathName);
- }
- ckfree((char *) windows);
- return TCL_OK;
- }
- } else {
- TkWindow *winPtr2;
- int index1=-1, index2=-1, result;
- if (TkGetWindowFromObj(interp, tkwin, objv[4], (Tk_Window *) &winPtr2)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (!Tk_IsTopLevel(winPtr2)) {
- Tcl_AppendResult(interp, "window "", winPtr2->pathName,
- "" isn't a top-level window", (char *) NULL);
- return TCL_ERROR;
- }
- if (!Tk_IsMapped(winPtr)) {
- Tcl_AppendResult(interp, "window "", winPtr->pathName,
- "" isn't mapped", (char *) NULL);
- return TCL_ERROR;
- }
- if (!Tk_IsMapped(winPtr2)) {
- Tcl_AppendResult(interp, "window "", winPtr2->pathName,
- "" isn't mapped", (char *) NULL);
- return TCL_ERROR;
- }
- /*
- * Lookup stacking order of all toplevels that are children
- * of "." and find the position of winPtr and winPtr2
- * in the stacking order.
- */
- windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr);
- if (windows == NULL) {
- Tcl_AppendResult(interp, "TkWmStackorderToplevel failed",
- (char *) NULL);
- return TCL_ERROR;
- } else {
- for (window_ptr = windows; *window_ptr ; window_ptr++) {
- if (*window_ptr == winPtr)
- index1 = (window_ptr - windows);
- if (*window_ptr == winPtr2)
- index2 = (window_ptr - windows);
- }
- if (index1 == -1)
- panic("winPtr window not found");
- if (index2 == -1)
- panic("winPtr2 window not found");
- ckfree((char *) windows);
- }
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if (index == OPT_ISABOVE) {
- result = index1 > index2;
- } else { /* OPT_ISBELOW */
- result = index1 < index2;
- }
- Tcl_SetIntObj(Tcl_GetObjResult(interp), result);
- return TCL_OK;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmStateCmd --
- *
- * This procedure is invoked to process the "wm state" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmStateCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- static CONST char *optionStrings[] = {
- "normal", "iconic", "withdrawn", "zoomed", (char *) NULL };
- enum options {
- OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED };
- int index;
- if ((objc < 3) || (objc > 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
- return TCL_ERROR;
- }
- if (objc == 4) {
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't change state of ",
- Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
- if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't change state of ",
- winPtr->pathName, ": it is an embedded window",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if (index == OPT_NORMAL) {
- TkpWmSetState(winPtr, NormalState);
- /*
- * This varies from 'wm deiconify' because it does not
- * force the window to be raised and receive focus
- */
- } 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",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (wmPtr->master != NULL) {
- Tcl_AppendResult(interp, "can't iconify "",
- winPtr->pathName,
- "": it is a transient", (char *) NULL);
- return TCL_ERROR;
- }
- TkpWmSetState(winPtr, IconicState);
- } else if (index == OPT_WITHDRAWN) {
- TkpWmSetState(winPtr, WithdrawnState);
- } else { /* OPT_ZOOMED */
- TkpWmSetState(winPtr, ZoomState);
- }
- } else {
- if (wmPtr->iconFor != NULL) {
- Tcl_SetResult(interp, "icon", TCL_STATIC);
- } else {
- switch (wmPtr->hints.initial_state) {
- case NormalState:
- Tcl_SetResult(interp, "normal", TCL_STATIC);
- break;
- case IconicState:
- Tcl_SetResult(interp, "iconic", TCL_STATIC);
- break;
- case WithdrawnState:
- Tcl_SetResult(interp, "withdrawn", TCL_STATIC);
- break;
- case ZoomState:
- Tcl_SetResult(interp, "zoomed", TCL_STATIC);
- break;
- }
- }
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmTitleCmd --
- *
- * This procedure is invoked to process the "wm title" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmTitleCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
- int length;
- if (objc > 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- Tcl_SetResult(interp, (char *)
- ((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid),
- TCL_STATIC);
- return TCL_OK;
- } else {
- if (wmPtr->title != NULL) {
- ckfree((char *) wmPtr->title);
- }
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->title = ckalloc((unsigned) (length + 1));
- strcpy(wmPtr->title, argv3);
- if (!(wmPtr->flags & WM_NEVER_MAPPED) && !Tk_IsEmbedded(winPtr)) {
- TkSetWMName(winPtr, wmPtr->title);
- }
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmTransientCmd --
- *
- * This procedure is invoked to process the "wm transient" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmTransientCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- Tk_Window master;
- WmInfo *wmPtr2;
- char *argv3;
- int length;
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?master?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- if (wmPtr->master != None) {
- Tcl_SetResult(interp, wmPtr->masterWindowName, TCL_STATIC);
- }
- return TCL_OK;
- }
- if (Tcl_GetString(objv[3])[0] == ' ') {
- wmPtr->master = None;
- if (wmPtr->masterWindowName != NULL) {
- ckfree(wmPtr->masterWindowName);
- }
- wmPtr->masterWindowName = NULL;
- wmPtr->style = documentProc;
- } else {
- if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) {
- return TCL_ERROR;
- }
- Tk_MakeWindowExist(master);
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make "",
- Tcl_GetString(objv[2]),
- "" a transient: it is an icon for ",
- Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
- wmPtr2 = ((TkWindow *) master)->wmInfoPtr;
- if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make "",
- Tcl_GetString(objv[3]),
- "" a master: it is an icon for ",
- Tk_PathName(wmPtr2->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
- argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->master = Tk_WindowId(master);
- wmPtr->masterWindowName = ckalloc((unsigned) length+1);
- strcpy(wmPtr->masterWindowName, argv3);
- wmPtr->style = plainDBox;
- }
- return TCL_OK;
- }
- /*
- *----------------------------------------------------------------------
- *
- * WmWithdrawCmd --
- *
- * This procedure is invoked to process the "wm withdraw" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
- static int
- WmWithdrawCmd(tkwin, winPtr, interp, objc, objv)
- Tk_Window tkwin; /* Main window of the application. */
- TkWindow *winPtr; /* Toplevel to work with */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
- {
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't withdraw ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
- TkpWmSetState(winPtr, WithdrawnState);
- return TCL_OK;
- }
- /*
- * Invoked by those wm subcommands that affect geometry.
- * Schedules a geometry update.
- */
- static void
- WmUpdateGeom(wmPtr, winPtr)
- WmInfo *wmPtr;
- TkWindow *winPtr;
- {
- if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
- wmPtr->flags |= WM_UPDATE_PENDING;
- }
- }
- /*
- *----------------------------------------------------------------------
- *
- * Tk_SetGrid --
- *
- * This procedure is invoked by a widget when it wishes to set a grid
- * coordinate system that controls the size of a top-level window.
- * It provides a C interface equivalent to the "wm grid" command and
- * is usually asscoiated with the -setgrid option.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Grid-related information will be passed to the window manager, so
- * that the top-level window associated with tkwin will resize on
- * even grid units. If some other window already controls gridding
- * for the top-level window then this procedure call has no effect.
- *
- *----------------------------------------------------------------------
- */
- void
- Tk_SetGrid(
- Tk_Window tkwin, /* Token for window. New window mgr info
- * will be posted for the top-level window
- * associated with this window. */
- int reqWidth, /* Width (in grid units) corresponding to
- * the requested geometry for tkwin. */
- int reqHeight, /* Height (in grid units) corresponding to
- * the requested geometry for tkwin. */
- int widthInc, int heightInc)/* Pixel increments corresponding to a
- * change of one grid unit. */
- {
- TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
- /*
- * Find the top-level window for tkwin, plus the window manager
- * information.
- */
- while (!(winPtr->flags & TK_TOP_HIERARCHY)) {
- winPtr = winPtr->parentPtr;
- }
- wmPtr = winPtr->wmInfoPtr;
- if (wmPtr == NULL) {
- return;
- }
- if ((wmPtr->gridWin != NULL) && (wmPtr->gridWin != tkwin)) {
- return;
- }
- if ((wmPtr->reqGridWidth == reqWidth)
- && (wmPtr->reqGridHeight == reqHeight)
- && (wmPtr->widthInc == widthInc)
- && (wmPtr->heightInc == heightInc)
- && ((wmPtr->sizeHintsFlags & (PBaseSize|PResizeInc))
- == (PBaseSize|PResizeInc))) {
- return;
- }
- /*
- * If gridding was previously off, then forget about any window
- * size requests made by the user or via "wm geometry": these are
- * in pixel units and there's no easy way to translate them to
- * grid units since the new requested size of the top-level window in
- * pixels may not yet have been registered yet (it may filter up
- * the hierarchy in DoWhenIdle handlers). However, if the window
- * has never been mapped yet then just leave the window size alone:
- * assume that it is intended to be in grid units but just happened
- * to have been specified before this procedure was called.
- */
- if ((wmPtr->gridWin == NULL) && !(wmPtr->flags & WM_NEVER_MAPPED)) {
- wmPtr->width = -1;
- wmPtr->height = -1;
- }
- /*
- * Set the new gridding information, and start the process of passing
- * all of this information to the window manager.
- */
- wmPtr->gridWin = tkwin;
- wmPtr->reqGridWidth = reqWidth;
- wmPtr->reqGridHeight = reqHeight;
- wmPtr->widthInc = widthInc;
- wmPtr->heightInc = heightInc;