1/*
2 * tkMacOSXWm.h --
3 *
4 *	Declarations of Macintosh specific window manager structures.
5 *
6 * Copyright 2001-2009, Apple Inc.
7 * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
8 *
9 * See the file "license.terms" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 *
12 * RCS: @(#) $Id$
13 */
14
15#ifndef _TKMACWM
16#define _TKMACWM
17
18#include "tkMacOSXInt.h"
19#include "tkMenu.h"
20
21/*
22 * A data structure of the following type holds information for
23 * each window manager protocol (such as WM_DELETE_WINDOW) for
24 * which a handler (i.e. a Tcl command) has been defined for a
25 * particular top-level window.
26 */
27
28typedef struct ProtocolHandler {
29    Atom protocol;		/* Identifies the protocol. */
30    struct ProtocolHandler *nextPtr;
31				/* Next in list of protocol handlers for
32				 * the same top-level window, or NULL for
33				 * end of list. */
34    Tcl_Interp *interp;		/* Interpreter in which to invoke command. */
35    char command[4];		/* Tcl command to invoke when a client
36				 * message for this protocol arrives.
37				 * The actual size of the structure varies
38				 * to accommodate the needs of the actual
39				 * command. THIS MUST BE THE LAST FIELD OF
40				 * THE STRUCTURE. */
41} ProtocolHandler;
42
43#define HANDLER_SIZE(cmdLength) \
44((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
45
46/*
47 * A data structure of the following type holds window-manager-related
48 * information for each top-level window in an application.
49 */
50
51typedef struct TkWmInfo {
52    TkWindow *winPtr;		/* Pointer to main Tk information for
53				 * this window. */
54    Window reparent;		/* If the window has been reparented, this
55				 * gives the ID of the ancestor of the window
56				 * that is a child of the root window (may
57				 * not be window's immediate parent). If
58				 * the window isn't reparented, this has the
59				 * value None. */
60    Tk_Uid titleUid;		/* Title to display in window caption. If
61				 * NULL, use name of widget. */
62    char *iconName;		/* Name to display in icon. */
63    Window master;		/* Master window for TRANSIENT_FOR property,
64				 * or None. */
65    XWMHints hints;		/* Various pieces of information for
66				 * window manager. */
67    char *leaderName;		/* Path name of leader of window group
68				 * (corresponds to hints.window_group).
69				 * Malloc-ed. Note:  this field doesn't
70				 * get updated if leader is destroyed. */
71    char *masterWindowName;	/* Path name of window specified as master
72				 * in "wm transient" command, or NULL.
73				 * Malloc-ed. Note:  this field doesn't
74				 * get updated if masterWindowName is
75				 * destroyed. */
76    Tk_Window icon;		/* Window to use as icon for this window,
77				 * or NULL. */
78    Tk_Window iconFor;		/* Window for which this window is icon, or
79				 * NULL if this isn't an icon for anyone. */
80
81    /*
82     * Information used to construct an XSizeHints structure for
83     * the window manager:
84     */
85
86    int sizeHintsFlags;		/* Flags word for XSizeHints structure.
87				 * If the PBaseSize flag is set then the
88				 * window is gridded; otherwise it isn't
89				 * gridded. */
90    int minWidth, minHeight;	/* Minimum dimensions of window, in
91				 * grid units, not pixels. */
92    int maxWidth, maxHeight;	/* Maximum dimensions of window, in
93				 * grid units, not pixels. */
94    Tk_Window gridWin;		/* Identifies the window that controls
95				 * gridding for this top-level, or NULL if
96				 * the top-level isn't currently gridded. */
97    int widthInc, heightInc;	/* Increments for size changes (# pixels
98				 * per step). */
99    struct {
100	int x;			/* numerator */
101	int y;			/* denominator */
102    } minAspect, maxAspect;	/* Min/max aspect ratios for window. */
103    int reqGridWidth, reqGridHeight;
104				/* The dimensions of the window (in
105				 * grid units) requested through
106				 * the geometry manager. */
107    int gravity;		/* Desired window gravity. */
108
109    /*
110     * Information used to manage the size and location of a window.
111     */
112
113    int width, height;		/* Desired dimensions of window, specified
114				 * in grid units. These values are
115				 * set by the "wm geometry" command and by
116				 * ConfigureNotify events (for when wm
117				 * resizes window). -1 means user hasn't
118				 * requested dimensions. */
119    int x, y;			/* Desired X and Y coordinates for window.
120				 * These values are set by "wm geometry",
121				 * plus by ConfigureNotify events (when wm
122				 * moves window). These numbers are
123				 * different than the numbers stored in
124				 * winPtr->changes because (a) they could be
125				 * measured from the right or bottom edge
126				 * of the screen (see WM_NEGATIVE_X and
127				 * WM_NEGATIVE_Y flags) and (b) if the window
128				 * has been reparented then they refer to the
129				 * parent rather than the window itself. */
130    int parentWidth, parentHeight;
131				/* Width and height of reparent, in pixels
132				 * *including border*. If window hasn't been
133				 * reparented then these will be the outer
134				 * dimensions of the window, including
135				 * border. */
136    int xInParent, yInParent;	/* Offset of window within reparent, measured
137				 * from upper-left outer corner of parent's
138				 * border to upper-left outer corner of child's
139				 * border. If not reparented then these are
140				 * zero. */
141    int configX, configY;	/* x,y position of toplevel when window is
142				 * switched into fullscreen state, */
143    int configWidth, configHeight;
144				/* Dimensions passed to last request that we
145				 * issued to change geometry of window. Used
146				 * to eliminate redundant resize operations. */
147
148    /*
149     * Information about the virtual root window for this top-level,
150     * if there is one.
151     */
152
153    Window vRoot;		/* Virtual root window for this top-level,
154				 * or None if there is no virtual root
155				 * window (i.e. just use the screen's root). */
156    int vRootX, vRootY;		/* Position of the virtual root inside the
157				 * root window. If the WM_VROOT_OFFSET_STALE
158				 * flag is set then this information may be
159				 * incorrect and needs to be refreshed from
160				 * the X server. If vRoot is None then these
161				 * values are both 0. */
162    unsigned int vRootWidth, vRootHeight;
163				/* Dimensions of the virtual root window.
164				 * If vRoot is None, gives the dimensions
165				 * of the containing screen. This information
166				 * is never stale, even though vRootX and
167				 * vRootY can be. */
168
169    /*
170     * List of children of the toplevel which have private colormaps.
171     */
172
173    TkWindow **cmapList;	/* Array of window with private colormaps. */
174    int cmapCount;		/* Number of windows in array. */
175
176    /*
177     * Miscellaneous information.
178     */
179
180    ProtocolHandler *protPtr;	/* First in list of protocol handlers for
181				 * this window (NULL means none). */
182    int cmdArgc;		/* Number of elements in cmdArgv below. */
183    const char **cmdArgv;		/* Array of strings to store in the
184				 * WM_COMMAND property. NULL means nothing
185				 * available. */
186    char *clientMachine;	/* String to store in WM_CLIENT_MACHINE
187				 * property, or NULL. */
188    int flags;			/* Miscellaneous flags, defined below. */
189
190    /*
191     * Macintosh information.
192     */
193    WindowClass macClass;
194    UInt64 attributes, configAttributes;
195    TkWindow *scrollWinPtr;	/* Ptr to scrollbar handling grow widget. */
196    TkMenu *menuPtr;
197    NSWindow *window;
198} WmInfo;
199
200
201/*
202 * Flag values for WmInfo structures:
203 *
204 * WM_NEVER_MAPPED -		non-zero means window has never been
205 *				mapped; need to update all info when
206 *				window is first mapped.
207 * WM_UPDATE_PENDING -		non-zero means a call to UpdateGeometryInfo
208 *				has already been scheduled for this
209 *				window; no need to schedule another one.
210 * WM_NEGATIVE_X -		non-zero means x-coordinate is measured in
211 *				pixels from right edge of screen, rather
212 *				than from left edge.
213 * WM_NEGATIVE_Y -		non-zero means y-coordinate is measured in
214 *				pixels up from bottom of screen, rather than
215 *				down from top.
216 * WM_UPDATE_SIZE_HINTS -	non-zero means that new size hints need to be
217 *				propagated to window manager.
218 * WM_SYNC_PENDING -		set to non-zero while waiting for the window
219 *				manager to respond to some state change.
220 * WM_VROOT_OFFSET_STALE -	non-zero means that (x,y) offset information
221 *				about the virtual root window is stale and
222 *				needs to be fetched fresh from the X server.
223 * WM_ABOUT_TO_MAP -		non-zero means that the window is about to
224 *				be mapped by TkWmMapWindow. This is used
225 *				by UpdateGeometryInfo to modify its behavior.
226 * WM_MOVE_PENDING -		non-zero means the application has requested
227 *				a new position for the window, but it hasn't
228 *				been reflected through the window manager
229 *				yet.
230 * WM_COLORMAPS_EXPLICIT -	non-zero means the colormap windows were
231 *				set explicitly via "wm colormapwindows".
232 * WM_ADDED_TOPLEVEL_COLORMAP - non-zero means that when "wm colormapwindows"
233 *				was called the top-level itself wasn't
234 *				specified, so we added it implicitly at
235 *				the end of the list.
236 * WM_WIDTH_NOT_RESIZABLE -	non-zero means that we're not supposed to
237 *				allow the user to change the width of the
238 *				window (controlled by "wm resizable"
239 *				command).
240 * WM_HEIGHT_NOT_RESIZABLE -	non-zero means that we're not supposed to
241 *				allow the user to change the height of the
242 *				window (controlled by "wm resizable"
243 *				command).
244 */
245
246#define WM_NEVER_MAPPED			0x0001
247#define WM_UPDATE_PENDING		0x0002
248#define WM_NEGATIVE_X			0x0004
249#define WM_NEGATIVE_Y			0x0008
250#define WM_UPDATE_SIZE_HINTS		0x0010
251#define WM_SYNC_PENDING			0x0020
252#define WM_VROOT_OFFSET_STALE		0x0040
253#define WM_ABOUT_TO_MAP			0x0080
254#define WM_MOVE_PENDING			0x0100
255#define WM_COLORMAPS_EXPLICIT		0x0200
256#define WM_ADDED_TOPLEVEL_COLORMAP	0x0400
257#define WM_WIDTH_NOT_RESIZABLE		0x0800
258#define WM_HEIGHT_NOT_RESIZABLE		0x1000
259#define WM_TOPMOST			0x2000
260#define WM_FULLSCREEN			0x4000
261#define WM_TRANSPARENT			0x8000
262
263#endif
264
265