2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
31 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
40 #include "WmResNames.h"
42 #define MWM_NEED_ICONBOX
43 #include "WmIBitmap.h"
49 #define makemult(a, b) ((b==1) ? (a) : (((int)((a) / (b))) * (b)) )
52 * include extern functions
54 #include "WmWinInfo.h"
61 #include "WmIconBox.h"
66 #include "WmProperty.h"
67 #include "WmResource.h"
68 #include "WmWrkspace.h"
69 #include "WmWinList.h"
70 #include "WmPresence.h"
72 #include "WmMultiHead.h"
74 static void AdjustSlideOutGeometry (ClientData *pCD);
75 static void FixSubpanelEmbeddedClientGeometry (ClientData *pCD);
77 #ifndef NO_MESSAGE_CATALOG
78 # define LOCALE_MSG GETMESSAGE(70, 7, "[XmbTextPropertyToTextList]:\n Locale (%.100s) not supported. (Check $LANG).")
80 # define LOCALE_MSG "[XmbTextPropertyToTextList]:\n Locale (%.100s) not supported. (Check $LANG)."
86 WmWorkspaceData *pIconBoxInitialWS;
90 /*************************************<->*************************************
92 * GetClientInfo (pSD, clientWindow, manageFlags)
97 * This function is used to initialize client window data based on the
98 * contents of client window properties and the client window configuration.
103 * pSD = pointer to screen data for screen that client lives in
105 * clientWindow = window id for the client window that is to be managed
107 * manageFlags = flags that indicate wm state info
112 * Return = pointer to an initialized client data structure for the
113 * specified client window
115 *************************************<->***********************************/
118 GetClientInfo (WmScreenData *pSD, Window clientWindow, long manageFlags)
122 XSetWindowAttributes sAttributes;
126 * Allocate and initialize a client data structure:
129 if (!(pCD = (ClientData *)XtMalloc (sizeof (ClientData))))
131 /* unable to allocate space */
132 Warning (((char *)GETMESSAGE(70, 1, "Insufficient memory for client data")));
138 * Initialize the data structure:
141 pCD->client = clientWindow;
142 pCD->clientID = ++(pSD->clientCounter);
143 pCD->clientFlags = WM_INITIALIZATION;
145 pCD->thisIconBox = NULL;
149 pCD->wmUnmapCount = 0;
150 pCD->transientFor = (Window)0L;
151 pCD->transientLeader = NULL;
152 pCD->transientChildren = NULL;
153 pCD->transientSiblings = NULL;
154 pCD->primaryStackPosition = 0;
155 pCD->fullModalCount = 0;
156 pCD->primaryModalCount = 0;
157 pCD->focusPriority = 0;
158 pCD->focusAutoRaiseDisabled = False;
159 pCD->focusAutoRaiseDisablePending = False;
161 pCD->clientClass = NULL;
162 pCD->clientName = NULL;
163 pCD->clientFrameWin = (Window)0L;
164 pCD->iconWindow = (Window)0L;
165 pCD->iconPixmap = (Pixmap)0L;
166 pCD->clientProtocols = NULL;
167 pCD->clientProtocolCount = 0;
168 pCD->mwmMessages = NULL;
169 pCD->mwmMessagesCount = 0;
170 pCD->clientCmapCount = 0;
171 pCD->clientCmapIndex = 0;
172 pCD->clientCmapFlagsInitialized = FALSE;
173 pCD->systemMenuSpec = NULL;
174 pCD->putInAll = False;
175 pCD->pWorkspaceHints = NULL;
176 pCD->numInhabited = 0;
178 pCD->dtwmFunctions = DtWM_FUNCTION_OCCUPY_WS;
179 pCD->dtwmBehaviors = 0L;
180 pCD->paInitialProperties = NULL;
181 pCD->numInitialProperties = 0;
183 pCD->decorFlags = 0L;
184 pCD->pTitleGadgets = NULL;
185 pCD->cTitleGadgets = 0;
186 pCD->pResizeGadgets = NULL;
187 pCD->clientTitleWin = (Window)0L;
188 pCD->pclientTopShadows = NULL;
189 pCD->pclientBottomShadows = NULL;
190 pCD->pclientTitleTopShadows = NULL;
191 pCD->pclientTitleBottomShadows = NULL;
192 pCD->pclientMatteTopShadows = NULL;
193 pCD->pclientMatteBottomShadows = NULL;
194 pCD->piconTopShadows = NULL;
195 pCD->piconBottomShadows = NULL;
196 pCD->internalBevel = (wmGD.frameStyle == WmSLAB) ? 0 :
197 FRAME_INTERNAL_SHADOW_WIDTH;
199 pCD->bPseudoTransient = False;
200 #endif /* NO_OL_COMPAT */
202 pCD->maxWidth = pCD->maxWidthLimit = BIGSIZE;
203 pCD->maxHeight = pCD->maxHeightLimit = BIGSIZE;
204 pCD->maxConfig = FALSE;
206 pCD->dataType = CLIENT_DATA_TYPE;
207 pCD->window_status = 0L;
209 pCD->clientEntry.nextSibling = NULL;
210 pCD->clientEntry.prevSibling = NULL;
211 pCD->clientEntry.pCD = NULL;
213 pCD->smClientID = (String)NULL;
216 * Do special processing for client windows that are controlled by
217 * the window manager.
220 if (manageFlags & MANAGEW_WM_CLIENTS)
222 WmWorkspaceData *pWS;
224 if (manageFlags & MANAGEW_ICON_BOX)
226 pWS = pIconBoxInitialWS;
230 pWS = pSD->pActiveWS;
232 return (GetWmClientInfo (pWS, pCD, manageFlags));
237 * Register the client window to facilitate event handling:
240 XSaveContext (DISPLAY, clientWindow, wmGD.windowContextType, (caddr_t)pCD);
244 * Listen for property change events on the window so that we keep
245 * in sync with the hints.
247 sAttributes.event_mask = (PropertyChangeMask | ColormapChangeMask);
248 XChangeWindowAttributes (DISPLAY, pCD->client, CWEventMask,
252 * Get window configuration attributes. WmGetWindowAttributes sets
253 * up the global window attributes cache with the client window
257 if (!WmGetWindowAttributes (clientWindow))
260 * Cannot get window attributes. Do not manage window.
261 * (error message within WmGetWindowAttributes)
264 UnManageWindow (pCD);
267 pCD->xBorderWidth = wmGD.windowAttributes.border_width;
270 * Get the initial list of properties on this window.
271 * Save it to optimize subsequent property fetching.
273 GetInitialPropertyList (pCD);
276 * Retrieve and process WM_CLASS hints client window property info:
279 ProcessWmClass (pCD);
283 * Retrieve and process WM_TRANSIENT_FOR client window property info:
286 ProcessWmTransientFor (pCD);
289 * Get client window resource data (from resources, .mwmrc):
290 * Moved prior to GetClientWorkspaceInfo() because the
291 * ignoreWMSaveHints resource may affect that function.
294 ProcessClientResources (pCD);
297 * Retreive and process SM_CLIENT_ID client window property info
298 * and WMSAVE_HINT client window property info:
299 * must be done prior to calling GetClientWorkspaceInfo().
301 ProcessSmClientID (pCD);
302 ProcessWmSaveHint (pCD);
305 * Set client's workspace information. NOTE: this also may
306 * set the geometry, initial state, etc. For Sm-aware clients,
307 * this info will be in private DB; for older clients, it will
308 * be contained in the screen's pDtSessionItems.
310 if (!GetClientWorkspaceInfo (pCD, manageFlags))
312 XtFree ((char *)pCD);
317 * Restore client's per-workspace icon information.
319 LoadClientIconPositions(pCD);
322 * Retrieve and process _DT_WM_HINTS client window property
323 * (results are used in ProcessMwmHints)
325 ProcessDtWmHints (pCD);
328 * Retrieve and process M_CLIENT_DECOR client window property info:
331 ProcessMwmHints (pCD);
335 * Retrieve and process WM_HINTS client window property info:
338 ProcessWmHints (pCD, True /*first time*/);
342 * Set offset from frame of client window
345 SetClientOffset (pCD);
349 * Retrieve and process WM_NORMAL_HINTS client window property info:
353 ProcessWmNormalHints (pCD, True /*first time*/, manageFlags);
357 * Retrieve and process WM_NAME client window property info (this
358 * property contains the window title NOT the window resource name):
361 ProcessWmWindowTitle (pCD, TRUE);
365 * Retrieve and process WM_ICON_NAME client window property info:
368 ProcessWmIconTitle (pCD, TRUE);
372 * Retrieve and process the WM_PROTOCOLS property.
375 ProcessWmProtocols (pCD);
379 * If necessary retrieve and process the _MWM_MESSAGES property.
382 if (pCD->protocolFlags & PROTOCOL_MWM_MESSAGES)
384 ProcessMwmMessages (pCD);
389 * Make or find a system menu for the client.
394 MakeSystemMenu (pCD);
398 pCD->systemMenuSpec = NULL;
403 * Setup the colormap data for the client window. This includes
404 * retrieving and processing client window properties that deal with
405 * subwindow colormaps.
408 InitCColormapData (pCD);
411 /* successful return */
416 } /* END OF FUNCTION GetClientInfo */
420 /*************************************<->*************************************
422 * GetWmClientInfo (pWS, pCD, manageFlags)
427 * This function is used to initialize client window data for a window
428 * that is controlled by the window manager (e.g., the icon box). The
429 * client window may get made in the process.
434 * pWS = pointer to workspace data
436 * pCD = pointer to client window data structure
438 * manageFlags = flags that indicate wm state info
443 * Return = pointer to an initialized client data structure or NULL
444 * if the client data could not be initialized
446 *************************************<->***********************************/
448 GetWmClientInfo (WmWorkspaceData *pWS,
457 * Set up the client class and name for resource retrieval.
458 * Get client specific resource data (from resources, .mwmrc).
461 if (manageFlags & MANAGEW_ICON_BOX)
463 SetIconBoxInfo (pWS, pCD);
465 else if (manageFlags & MANAGEW_CONFIRM_BOX)
467 pCD->clientClass = WmCConfirmbox;
468 pCD->clientName = WmNconfirmbox;
469 pCD->iconImage = NULL;
470 pCD->useClientIcon = False;
471 pCD->focusAutoRaise = True;
472 pCD->internalBevel = (wmGD.frameStyle == WmSLAB) ? 0 :
473 FRAME_INTERNAL_SHADOW_WIDTH;
475 pCD->maximumClientSize.width = 0;
476 pCD->maximumClientSize.height = 0;
477 pCD->systemMenu = NULL;
482 * Set up transient for data.
485 if (manageFlags & MANAGEW_ICON_BOX)
491 * Set up WM_HINTS type information.
494 pCD->inputFocusModel = True;
495 pCD->clientState = NORMAL_STATE;
497 if (ICON_DECORATION(pCD) & ICON_IMAGE_PART)
499 if (manageFlags & MANAGEW_ICON_BOX)
501 pCD->clientFlags |= ICON_BOX;
504 if (!pCD->useClientIcon && pCD->iconImage)
507 * Make a client supplied icon image.
508 * Do not use the default icon image if iconImage is not found.
511 pCD->iconPixmap = MakeNamedIconPixmap (pCD, pCD->iconImage);
514 if (!pCD->iconPixmap)
517 * Use a built-in icon image for the window manager client.
518 * The image may differ from the default icon image, depending on
519 * the particular client (eg the iconbox).
522 if (manageFlags & MANAGEW_ICON_BOX)
525 * Make a default iconBox icon image.
528 iconBitmap = XCreateBitmapFromData (DISPLAY,
529 ROOT_FOR_CLIENT(pCD), (char *)iconBox_bits,
530 iconBox_width, iconBox_height);
532 pCD->iconPixmap = MakeIconPixmap (pCD,
533 iconBitmap, (Pixmap)0L,
534 iconBox_width, iconBox_height, 1);
541 * Allocate initial workspace ID list
544 if ((pCD->pWsList = (WsClientData *)
545 XtMalloc(pCD->pSD->numWorkspaces * sizeof(WsClientData))) == NULL)
547 Warning (((char *)GETMESSAGE(70, 2, "Insufficient memory for client data")));
550 pCD->sizeWsList = pCD->pSD->numWorkspaces;
551 for (i = 0; i < pCD->pSD->numWorkspaces; i++)
553 pCD->pWsList[i].wsID = 0L;
554 pCD->pWsList[i].iconPlace = NO_ICON_PLACE;
555 pCD->pWsList[i].iconX = 0;
556 pCD->pWsList[i].iconY = 0;
557 pCD->pWsList[i].iconFrameWin = (Window)0L;
558 pCD->pWsList[i].pIconBox = NULL;
561 * Internally managed clients must be specifically inserted
562 * into workspaces the first time by calling
563 * PutClientIntoWorkspace.
565 pCD->numInhabited = 0;
566 pCD->windowGroup = 0L;
568 pCD->bPseudoTransient = False;
569 #endif /* NO_OL_COMPAT */
573 * Set up _MWM_HINTS data.
576 * Fix the client functions and decorations fields if they have
577 * default resource values.
581 if (manageFlags & MANAGEW_CONFIRM_BOX)
583 pCD->clientFunctions = WM_FUNC_NONE;
584 pCD->clientDecoration = WM_DECOR_BORDER;
588 if (pCD->clientFunctions & WM_FUNC_DEFAULT)
590 pCD->clientFunctions = WM_FUNC_ALL;
593 if (pCD->clientDecoration & WM_DECOR_DEFAULT)
595 pCD->clientDecoration = WM_DECOR_ALL;
598 if (manageFlags & MANAGEW_ICON_BOX)
600 pCD->clientFunctions &= ICON_BOX_FUNCTIONS;
601 pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
602 if (wmGD.useFrontPanel && pCD->pSD->iconBoxControl)
605 * If there's a front panel button for the icon
606 * box, then use it to "hide" the box on "close"
608 pCD->clientFunctions &= ~MWM_FUNC_MINIMIZE;
609 pCD->clientFunctions |= MWM_FUNC_CLOSE;
614 if (!(pCD->clientFunctions & MWM_FUNC_RESIZE))
616 pCD->clientDecoration &= ~MWM_DECOR_RESIZEH;
619 if (!(pCD->clientFunctions & MWM_FUNC_MINIMIZE))
621 pCD->clientDecoration &= ~MWM_DECOR_MINIMIZE;
624 if (!(pCD->clientFunctions & MWM_FUNC_MAXIMIZE))
626 pCD->clientDecoration &= ~MWM_DECOR_MAXIMIZE;
630 pCD->decor = pCD->clientDecoration;
632 if (manageFlags & MANAGEW_ICON_BOX)
634 pCD->inputMode = MWM_INPUT_MODELESS;
636 else if (manageFlags & MANAGEW_CONFIRM_BOX)
638 pCD->inputMode = MWM_INPUT_SYSTEM_MODAL;
642 * Set up WM_NORMAL_HINTS data.
645 pCD->icccVersion = ICCC_CURRENT;
646 pCD->sizeFlags = US_POSITION | US_SIZE;
649 * Any calls to create Window Manager clients should
650 * return with the values for the following fields set.
651 * If it fails, it should free any space allocated and
657 * pCD->clientHeight =
667 * pCD->oldMaxHeight =
669 * AND PROBABLY SHOULD SET
670 * pCD->client = THE_WINDOW_THE_FUNCTION_CREATES
673 pCD->windowGravity = NorthWestGravity;
676 * Create IconBox window
679 if (manageFlags & MANAGEW_ICON_BOX)
681 if (!MakeIconBox (pWS, pCD))
684 * May want a more verbose message here
687 Warning (((char *)GETMESSAGE(70, 3, "Couldn't make icon box")));
690 PutClientIntoWorkspace (pWS, pCD);
692 else if (manageFlags & MANAGEW_CONFIRM_BOX)
695 unsigned int cbWidth, cbHeight;
698 XGetGeometry (DISPLAY, pCD->client, &root,
699 &(pCD->clientX), &(pCD->clientY),
701 (unsigned int*)&(pCD->xBorderWidth), &depth);
703 pCD->clientWidth = cbWidth;
704 pCD->clientHeight = cbHeight;
705 pCD->minWidth = pCD->baseWidth = pCD->maxWidth = pCD->clientWidth;
706 pCD->minHeight = pCD->baseHeight = pCD->maxHeight = pCD->clientHeight;
707 pCD->oldMaxWidth = pCD->maxWidth;
708 pCD->oldMaxHeight = pCD->maxHeight;
711 pCD->clientFlags |= CONFIRM_BOX;
712 PutClientIntoWorkspace (ACTIVE_WS, pCD);
716 * Set offset from frame of client window (need client size information).
723 * Register the client window to facilitate event handling.
726 XSaveContext (DISPLAY, pCD->client, wmGD.windowContextType, (caddr_t)pCD);
730 * Set up WM_PROTOCOLS data.
733 pCD->clientProtocolCount = 0;
734 pCD->protocolFlags = 0;
738 * Make the system menu.
741 if (manageFlags & MANAGEW_ICON_BOX)
743 pCD->systemMenuSpec =
744 MAKE_MENU (PSD_FOR_CLIENT(pCD), pCD, pCD->systemMenu,
745 F_CONTEXT_WINDOW, F_CONTEXT_WINDOW|F_CONTEXT_ICON,
746 GetIconBoxMenuItems(PSD_FOR_CLIENT(pCD)),
753 * Setup the colormap data.
756 pCD->clientColormap = PSD_FOR_CLIENT(pCD)->workspaceColormap;
760 * Return the pointer to the client data.
766 } /* END OF FUNCTION GetWmClientInfo */
770 /*************************************<->*************************************
772 * ProcessWmClass (pCD)
777 * This function retrieves the contents of the WM_CLASS property on the
778 * cient window. The resource class and the resource name are saved in
779 * the ClientData structure (note that the space for the strings is
780 * allocated using Xmalloc).
785 * pCD - pointer to client data
794 *************************************<->***********************************/
797 ProcessWmClass (ClientData *pCD)
799 XClassHint classHint;
803 classHint.res_class = "";
804 classHint.res_name = "";
805 XGetClassHint (DISPLAY, pCD->client, &classHint);
807 if ((HasProperty (pCD, XA_WM_CLASS)) &&
808 (XGetClassHint (DISPLAY, pCD->client, &classHint)))
811 /* the WM_CLASS property exists for the client window */
812 pCD->clientClass = classHint.res_class;
813 pCD->clientName = classHint.res_name;
815 /* else no WM_CLASS property; assume clientClass, clientName are NULL */
817 } /* END OF FUNCTION ProcessWmClass */
821 /*************************************<->*************************************
823 * ProcessSmClientID (pCD)
828 * This function retrieves the contents of the SM_CLIENT_ID property on the
829 * cient window. The value is saved in the ClientData structure
830 * (note that the space for the strings is allocated using Xmalloc).
835 * pCD - pointer to client data
844 *************************************<->***********************************/
847 ProcessSmClientID (ClientData *pCD)
851 unsigned long nitems, leftover;
854 if (pCD->smClientID != (String)NULL)
856 XFree(pCD->smClientID);
857 pCD->smClientID = (String)NULL;
860 if ((XGetWindowProperty(DISPLAY, pCD->client, wmGD.xa_SM_CLIENT_ID,
861 0L, (long)1000000, False, AnyPropertyType,
862 &actualType, &actualFormat, &nitems,
863 &leftover, (unsigned char **)&clientID)
865 (actualType != None) && (actualFormat == 8))
867 /* the SM_CLIENT_ID property exists for the client window */
868 pCD->smClientID = clientID;
871 } /* END OF FUNCTION ProcessSmClientID */
875 /*************************************<->*************************************
877 * ProcessWmSaveHint (pCD)
882 * This function retrieves the contents of the WMSAVE_HINT property on the
883 * cient window. The value is saved in the ClientData structure.
888 * pCD - pointer to client data
897 *************************************<->***********************************/
900 ProcessWmSaveHint (ClientData *pCD)
904 unsigned long nitems, leftover;
905 BITS32 *saveHintFlags = (BITS32 *)NULL;
907 if ((XGetWindowProperty(DISPLAY, pCD->client, wmGD.xa_WMSAVE_HINT,
908 0L, (long)1000000, False, AnyPropertyType,
909 &actualType, &actualFormat, &nitems,
910 &leftover, (unsigned char **)&saveHintFlags)
912 (actualType != None) && (actualFormat == 32))
914 /* the WMSAVE_HINT property exists for the client window */
915 pCD->wmSaveHintFlags = (int)*saveHintFlags;
917 else pCD->wmSaveHintFlags = 0;
920 XFree(saveHintFlags);
922 } /* END OF FUNCTION ProcessWmSaveHint */
925 /*************************************<->*************************************
927 * ProcessWmHints (pCD, firstTime)
932 * This function retrieves the contents of the WM_HINTS property on the
938 * pCD = pointer to client data for the window with the property
940 * firstTime = if True this is the first time the property has been processed
945 * pCD = initialize various WM_HINTS related fields
951 *************************************<->***********************************/
954 ProcessWmHints (ClientData *pCD, Boolean firstTime)
960 WmWorkspaceData *pWsTmp;
963 int tmpIconX, tmpIconY;
967 * If the WM_HINTS property does not exist the flags field will be
968 * set to 0. If flags is 0 don't reference the WMHints structure
969 * since they may be none.
972 if (firstTime && !HasProperty (pCD, XA_WM_HINTS))
975 pXWMHints = XGetWMHints (DISPLAY, pCD->client);
979 flags = pXWMHints->flags;
988 * Parse the WM_HINTS information. If this is the first time the hints
989 * have been processed then parse all fields and set defaults where hint
990 * fields are not set. If this is not the first time do selective
999 unsigned int numIDs = 0;
1002 * Save the window group.
1005 if (flags & WindowGroupHint)
1007 pCD->windowGroup = pXWMHints->window_group;
1009 * Pretend this is a transient window
1011 if ((pCD->bPseudoTransient) &&
1012 (pCD->transientFor == (Window)0L))
1014 pCD->clientFlags |= CLIENT_TRANSIENT;
1017 * Treat this like a transient window. This is transient
1018 * for the window group window.
1021 if ((pCD->client != pCD->windowGroup) &&
1022 !XFindContext (DISPLAY, pCD->windowGroup,
1023 wmGD.windowContextType, (caddr_t *)&leader))
1025 pCD->transientFor = pCD->windowGroup;
1026 pCD->transientLeader = leader;
1029 * Insure it is in the same set of workspaces
1032 if (pCD->transientLeader &&
1033 GetLeaderPresence(pCD, &pIDs, &numIDs))
1035 ProcessWorkspaceHintList (pCD, pIDs, numIDs);
1042 pCD->windowGroup = 0L;
1044 #endif /* NO_OL_COMPAT */
1046 * The window manger does not do anything with the input hint. Input
1047 * always goes to the selected window.
1050 if (flags & InputHint)
1052 pCD->inputFocusModel = pXWMHints->input;
1056 pCD->inputFocusModel = True;
1061 * The default state is NORMAL_STATE. States other than iconic
1062 * (e.g., ZoomState from the R2 ICCC) indicate to the window manager
1063 * that the NORMAL_STATE is to be used.
1066 if (pCD->clientFlags & SM_CLIENT_STATE)
1068 if ((pCD->clientState == MINIMIZED_STATE) &&
1069 (!(pCD->clientFunctions & MWM_FUNC_MINIMIZE)))
1071 pCD->clientState = NORMAL_STATE;
1075 if ((flags & StateHint) && (pXWMHints->initial_state == IconicState) &&
1076 (pCD->clientFunctions & MWM_FUNC_MINIMIZE))
1078 pCD->clientState = MINIMIZED_STATE;
1083 * States other than iconic are treated as normal.
1085 pCD->clientState = NORMAL_STATE;
1089 if (!ClientInWorkspace (PSD_FOR_CLIENT(pCD)->pActiveWS, pCD))
1091 pCD->clientState |= UNSEEN_STATE;
1096 * If an icon is to be made for the client then ...
1097 * save the icon image if useClientIcon is True or there is no
1098 * user specified icon image. A client supplied image may be a
1099 * pixmap or a window (a client icon window takes precedence over
1103 if ((pCD->clientFunctions & MWM_FUNC_MINIMIZE) &&
1104 (pCD->transientLeader == NULL))
1106 if ((ICON_DECORATION(pCD) & ICON_IMAGE_PART) &&
1107 (pCD->useClientIcon || !pCD->iconImage))
1109 if ((flags & IconWindowHint) &&
1110 (pXWMHints->icon_window != pCD->client))
1113 * An icon window has been supplied that is different from
1114 * the client window. Check out the window and get it
1115 * ready to be reparented to the window manager supplied
1119 if (!SetupClientIconWindow (pCD, pXWMHints->icon_window))
1122 * Cannot use the client supplied icon window. Use
1123 * an icon image if specified or a default image.
1127 if (!pCD->iconWindow && (flags & IconPixmapHint))
1129 iconMask = (flags & IconMaskHint) ?
1130 pXWMHints->icon_mask : (Pixmap) NULL;
1132 * A client supplied icon window is NOT
1133 * available so use the client supplied icon image.
1136 if ((pCD->iconPixmap =
1137 MakeClientIconPixmap (pCD,
1138 pXWMHints->icon_pixmap, iconMask)) != None)
1141 * Indicate that a client supplied icon image is being
1145 pCD->iconFlags |= ICON_HINTS_PIXMAP;
1150 * Cannot make a client supplied image. Use a user
1151 * specified icon image if it is available or a default
1158 if ((ICON_DECORATION(pCD) & ICON_IMAGE_PART) && !pCD->iconPixmap)
1161 * Use a user supplied icon image if it is available or a
1162 * default icon image.
1168 * Try to make a user specified icon image.
1172 MakeNamedIconPixmap (pCD, pCD->iconImage);
1175 if (!pCD->iconPixmap)
1178 * The icon image was not provided or not available.
1179 * Use the default icon image.
1182 pCD->iconPixmap = MakeNamedIconPixmap (pCD, NULL);
1188 * Save the client (user?) supplied icon position:
1191 if ((flags & IconPositionHint) ||
1192 (pCD->clientFlags & (SM_ICON_X | SM_ICON_Y)))
1194 pCD->iconFlags |= ICON_HINTS_POSITION;
1195 if (wmGD.iconAutoPlace)
1198 * Initialize icon placement data in all inhabited
1201 for (iws = 0; iws< pCD->numInhabited; iws++)
1203 pWsc = &(pCD->pWsList[iws]);
1204 if ((pWsTmp=GetWorkspaceData(pCD->pSD, pWsc->wsID)))
1206 tmpIconX = (pCD->clientFlags & SM_ICON_X) ?
1207 pWsc->iconX : pXWMHints->icon_x;
1208 tmpIconY = (pCD->clientFlags & SM_ICON_Y) ?
1209 pWsc->iconY : pXWMHints->icon_y;
1211 FindIconPlace (pCD, &(pWsTmp->IPData),
1212 tmpIconX, tmpIconY);
1213 if (pWsc->iconPlace != NO_ICON_PLACE)
1215 CvtIconPlaceToPosition ( &(pWsTmp->IPData),
1225 for (iws = 0; iws< pCD->numInhabited; iws++)
1227 pWsc = &(pCD->pWsList[iws]);
1228 if ((pWsTmp=GetWorkspaceData(pCD->pSD, pWsc->wsID)))
1230 if (!(pCD->clientFlags & SM_ICON_X))
1231 pWsc->iconX = pXWMHints->icon_x;
1232 if (!(pCD->clientFlags & SM_ICON_Y))
1233 pWsc->iconY = pXWMHints->icon_y;
1240 if (wmGD.iconAutoPlace)
1243 * Initialize icon placement data in all inhabited
1246 for (iws = 0; iws< pCD->numInhabited; iws++)
1248 pWsc = &(pCD->pWsList[iws]);
1249 pWsc->iconPlace = NO_ICON_PLACE;
1259 * Save the window group.
1262 if (flags & WindowGroupHint)
1264 pCD->windowGroup = pXWMHints->window_group;
1268 pCD->windowGroup = 0L;
1270 #endif /* NO_OL_COMPAT */
1272 else /* not the first time the hints are processed */
1274 if (flags & IconPixmapHint)
1277 * Process an icon image change if the icon image was initially
1278 * set up with a client supplied icon image OR, if the client
1279 * now wants to supply an image.
1281 iconMask = (flags & IconMaskHint)?
1282 pXWMHints->icon_mask : (Pixmap) NULL;
1285 MakeClientIconPixmap (pCD, pXWMHints->icon_pixmap,
1289 * Made new icon image; free up the old image and display
1292 if (pCD->iconFlags & ICON_HINTS_PIXMAP)
1295 * ICON_HINTS_PIXMAP was set either initally or
1296 * below because a new pixmap was made for the client.
1297 * It is now safe to free the previous pixmap since it
1298 * is not the shared default iconPixmap
1300 if (pCD->iconPixmap)
1302 XFreePixmap (DISPLAY, pCD->iconPixmap);
1307 pCD->iconFlags |= ICON_HINTS_PIXMAP;
1310 pCD->iconPixmap = iconPixmap;
1313 * Display new icon image if the icon is showing:
1316 if (((pCD->clientState == MINIMIZED_STATE) ||
1317 ((pCD->pSD->useIconBox) && (P_ICON_BOX(pCD)))) &&
1318 ICON_FRAME_WIN(pCD))
1320 IconExposureProc (pCD, True);
1328 XFree ((char*)pXWMHints);
1332 } /* END OF FUNCTION ProcessWmHints */
1336 /*************************************<->*************************************
1338 * ProcessWmNormalHints (pCD, firstTime, manageFlags)
1343 * This function retrieves the contents of the WM_NORMAL_HINTS property on
1344 * the cient window. There are several versions of the property that must be
1345 * handled (currently R2 and CURRENT).
1350 * pCD = pointer to client data for the window with the property
1352 * firstTime = if True this is the first time the property has been processed
1354 * manageFlags = flags that indicate wm state information
1359 * pCD = client location and size fields set
1364 * If the hints are being reprocessed (!firstTime) the configuration values
1365 * will be ignored. The size constraint values will be processed but the
1366 * client configuration will not be changed even if it is not in line with
1367 * the new values. Reconfigurations subsequent to the hints changes will
1368 * be done with the new constraints.
1370 *************************************<->***********************************/
1373 ProcessWmNormalHints (ClientData *pCD, Boolean firstTime, long manageFlags)
1375 SizeHints *pNormalHints;
1378 unsigned long decoration;
1379 unsigned int boxdim, tmpMin;
1380 unsigned int oldWidthInc, oldHeightInc;
1381 unsigned int oldBaseWidth, oldBaseHeight;
1382 unsigned int incWidth, incHeight;
1385 * Use a custom verion of the Xlib routine to get WM_NORMAL_HINTS.
1386 * A custom version is necessary to handle the different versions
1387 * of WM_NORMAL_HINTS that may be encountered. If the WM_NORMAL_HINTS
1388 * property does not exist the flags field will be set to 0.
1391 pNormalHints = GetNormalHints (pCD);
1393 pCD->icccVersion = pNormalHints->icccVersion;
1397 * Parse the WM_NORMAL_HINTS information:
1400 if (((flags = pNormalHints->flags) == 0) && !firstTime)
1407 * Process the size only if this is the first time the hints are
1408 * being processed for the window.
1414 * Process client window size flags and information:
1417 pCD->sizeFlags = flags & (US_POSITION | US_SIZE | P_POSITION | P_SIZE);
1420 * The R2 conventions and Xlib manual indicate that the window size
1421 * and position should be taken out of the WM_NORMAL_HINTS property
1422 * if they are specified there. The current conventions indicate that
1423 * the size and position information should be gotten from the window
1424 * configuration. Mwm 1.1 always uses the current conventions.
1429 * Maintain R2 compatiblity code for CND product xnm
1431 if ((pNormalHints->icccVersion == ICCC_R2) &&
1432 (flags & (US_POSITION | P_POSITION)) &&
1433 !(manageFlags & MANAGEW_WM_RESTART))
1435 if (!(pCD->clientFlags & SM_X))
1436 pCD->clientX = pNormalHints->x;
1437 if (!(pCD->clientFlags & SM_Y))
1438 pCD->clientY = pNormalHints->y;
1442 if (!(pCD->clientFlags & SM_X))
1443 pCD->clientX = wmGD.windowAttributes.x;
1444 if (!(pCD->clientFlags & SM_Y))
1445 pCD->clientY = wmGD.windowAttributes.y;
1447 #else /* R2_COMPAT */
1448 if (!(pCD->clientFlags & SM_X))
1449 pCD->clientX = wmGD.windowAttributes.x;
1450 if (!(pCD->clientFlags & SM_Y))
1451 pCD->clientY = wmGD.windowAttributes.y;
1452 #endif /* R2_COMPAT */
1455 * Use current conventions for initial window dimensions.
1460 * Maintain R2 compatiblity code for CND product xnm
1462 if ((pNormalHints->icccVersion == ICCC_R2) &&
1463 (flags & (US_SIZE | P_SIZE)) &&
1464 !(manageFlags & MANAGEW_WM_RESTART))
1466 if (!(pCD->clientFlags & SM_WIDTH))
1467 pCD->clientWidth = pNormalHints->width;
1468 if (!(pCD->clientFlags & SM_HEIGHT))
1469 pCD->clientHeight = pNormalHints->height;
1473 if (!(pCD->clientFlags & SM_WIDTH))
1474 pCD->clientWidth = wmGD.windowAttributes.width;
1475 if (!(pCD->clientFlags & SM_HEIGHT))
1476 pCD->clientHeight = wmGD.windowAttributes.height;
1478 #else /* R2_COMPAT */
1479 if (!(pCD->clientFlags & SM_WIDTH))
1480 pCD->clientWidth = wmGD.windowAttributes.width;
1481 if (!(pCD->clientFlags & SM_HEIGHT))
1482 pCD->clientHeight = wmGD.windowAttributes.height;
1483 #endif /* R2_COMPAT */
1487 * Process the minimum size:
1490 if (flags & P_MIN_SIZE)
1493 (pNormalHints->min_width < 0) ? 0 : pNormalHints->min_width;
1495 (pNormalHints->min_height < 0) ? 0 : pNormalHints->min_height;
1496 if (pCD->minWidth > MAX_MAX_SIZE(pCD).width)
1498 pCD->minWidth = MAX_MAX_SIZE(pCD).width;
1500 if (pCD->minHeight > MAX_MAX_SIZE(pCD).height)
1502 pCD->minHeight = MAX_MAX_SIZE(pCD).height;
1513 * Process the resizing increments:
1518 oldWidthInc = (pCD->widthInc == 0) ? 1 : pCD->widthInc;
1519 oldHeightInc = (pCD->heightInc == 0) ? 1 : pCD->heightInc;
1522 if (flags & P_RESIZE_INC)
1525 (pNormalHints->width_inc < 1) ? 1 : pNormalHints->width_inc;
1527 (pNormalHints->height_inc < 1) ? 1 : pNormalHints->height_inc;
1537 * Process the base size:
1542 oldBaseWidth = pCD->baseWidth;
1543 oldBaseHeight = pCD->baseHeight;
1546 if (flags & P_BASE_SIZE)
1549 (pNormalHints->base_width < 0) ? 0 : pNormalHints->base_width;
1551 (pNormalHints->base_height < 0) ? 0 : pNormalHints->base_height;
1553 else if ((pNormalHints->icccVersion == ICCC_R2) &&
1555 (!firstTime && (flags & P_MIN_SIZE))))
1558 * In this version of the hints the minimum size was effectively
1561 pCD->baseWidth = pCD->minWidth;
1562 pCD->baseHeight = pCD->minHeight;
1566 if (flags & P_MIN_SIZE)
1568 pCD->baseWidth = pCD->minWidth;
1569 pCD->baseHeight = pCD->minHeight;
1574 pCD->baseHeight = 0;
1580 if (pCD->clientFlags & SM_WIDTH)
1582 pCD->clientWidth = ((pCD->clientWidth * pCD->widthInc) +
1585 if (pCD->clientFlags & SM_HEIGHT)
1587 pCD->clientHeight =((pCD->clientHeight * pCD->heightInc) +
1593 * Process the maximum width. NOTE: maximumClientSize.width
1594 * and maximumClientSize.height will be set to BIGSIZE if
1595 * maximumClientSize is either set to 'horizontal' or 'vertical'.
1598 pCD->oldMaxWidth = pCD->maxWidth;
1599 if (pCD->maximumClientSize.width)
1601 /* If maximumClientSize is full 'horizontal' */
1602 if (IS_MAXIMIZE_HORIZONTAL(pCD))
1604 /* go to min (full screen width, max maximum width) */
1605 pCD->maxWidth = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD)) -
1606 (2 * pCD->clientOffset.x);
1609 * Hack to set max client to the current client height, maxHeight
1610 * will be kept up to date whenever the window is reconfigured
1612 pCD->maxHeight = pCD->clientHeight;
1617 pCD->maxWidth = (pCD->maximumClientSize.width *
1618 pCD->widthInc) + pCD->baseWidth;
1623 if (flags & P_MAX_SIZE)
1625 if (pNormalHints->max_width < 0)
1627 /* go to min (full screen width, max maximum width) */
1628 pCD->maxWidth = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD)) -
1629 (2 * pCD->clientOffset.x);
1633 pCD->maxWidth = pNormalHints->max_width;
1636 /* Don't reset maxWidth if it has been set earlier */
1637 else if (!IS_MAXIMIZE_VERTICAL(pCD))
1641 /* go to min (full screen width, max maximum width) */
1642 pCD->maxWidth = DisplayWidth (DISPLAY,
1643 SCREEN_FOR_CLIENT(pCD)) -
1644 (2 * pCD->clientOffset.x);
1648 /* reset the maxHeight before further processing */
1649 pCD->maxWidth = pCD->maxWidthLimit;
1655 * If the hints changed we need to adjust the maximum
1656 * size (if not specified in the hints).
1659 ((oldBaseWidth != pCD->baseWidth) ||
1660 (oldWidthInc != pCD->widthInc)))
1662 incWidth = (pCD->maxWidth - oldBaseWidth) / oldWidthInc;
1664 (incWidth * pCD->widthInc) + pCD->baseWidth;
1668 /* reset the maxHeight before further processing */
1669 pCD->maxWidth = pCD->maxWidthLimit;
1672 if (pCD->maxWidth > MAX_MAX_SIZE(pCD).width)
1674 pCD->maxWidth = MAX_MAX_SIZE(pCD).width;
1681 * Process the maximum height.
1684 pCD->oldMaxHeight = pCD->maxHeight;
1685 if (pCD->maximumClientSize.height)
1687 /* If maximumClientSize is full 'vertical' */
1688 if (IS_MAXIMIZE_VERTICAL(pCD))
1690 /* go to min (full screen height, max maximum height) */
1691 pCD->maxHeight = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT(pCD)) -
1692 (pCD->clientOffset.x +
1693 pCD->clientOffset.y);
1695 * Hack to set max client to the current client width, maxWidth
1696 * will be kept up to date whenever the window is reconfigured
1698 pCD->maxWidth = pCD->clientWidth;
1703 pCD->maxHeight = (pCD->maximumClientSize.height *
1704 pCD->heightInc) + pCD->baseHeight;
1709 if (flags & P_MAX_SIZE)
1711 if (pNormalHints->max_height < 0)
1713 /* go to min (full screen height, max maximum height) */
1714 pCD->maxHeight = DisplayHeight (
1715 DISPLAY, SCREEN_FOR_CLIENT(pCD)) -
1716 (pCD->clientOffset.x +
1717 pCD->clientOffset.y);
1721 pCD->maxHeight = pNormalHints->max_height;
1724 /* Don't reset maxHeight if it has been set above */
1725 else if (!IS_MAXIMIZE_HORIZONTAL(pCD))
1729 /* go to min (full screen height, max maximum height) */
1730 pCD->maxHeight = DisplayHeight (DISPLAY,
1731 SCREEN_FOR_CLIENT(pCD)) -
1732 (pCD->clientOffset.x +
1733 pCD->clientOffset.y);
1737 /* reset the maxHeight before further processing */
1738 pCD->maxHeight = pCD->maxHeightLimit;
1744 * If the hints changed we need to adjust the maximum
1745 * size (if not specified in the hints).
1748 ((oldBaseHeight != pCD->baseHeight) ||
1749 (oldHeightInc != pCD->heightInc)))
1751 incHeight = (pCD->maxHeight - oldBaseHeight) / oldHeightInc;
1753 (incHeight * pCD->heightInc) + pCD->baseHeight;
1757 /* reset the maxHeight before further processing */
1758 pCD->maxHeight = pCD->maxHeightLimit;
1761 if (pCD->maxHeight > MAX_MAX_SIZE(pCD).height)
1763 pCD->maxHeight = MAX_MAX_SIZE(pCD).height;
1768 * Make sure not to exceed the maximumMaximumSize (width and height)
1771 if (pCD->maxWidth > MAX_MAX_SIZE(pCD).width)
1773 pCD->maxWidth = MAX_MAX_SIZE(pCD).width;
1776 if (pCD->maxHeight > MAX_MAX_SIZE(pCD).height)
1778 pCD->maxHeight = MAX_MAX_SIZE(pCD).height;
1782 * Get the initial aspect ratios, if available. Only use them if:
1786 * 0 <= minAspect.x / minAspect.y <= maxAspect.x / maxAspect.y
1789 if (flags & P_ASPECT)
1791 pCD->minAspect.x = pNormalHints->min_aspect.x;
1792 pCD->minAspect.y = pNormalHints->min_aspect.y;
1793 pCD->maxAspect.x = pNormalHints->max_aspect.x;
1794 pCD->maxAspect.y = pNormalHints->max_aspect.y;
1796 if (pCD->minAspect.y > 0 &&
1797 pCD->maxAspect.y > 0 &&
1798 pCD->minAspect.x > 0 &&
1799 pCD->maxAspect.x > 0 &&
1800 (pCD->minAspect.x * pCD->maxAspect.y <=
1801 pCD->maxAspect.x * pCD->minAspect.y))
1803 pCD->sizeFlags |= P_ASPECT;
1807 pCD->sizeFlags &= ~P_ASPECT;
1811 /* compute for minimum frame size */
1812 if ((decoration = pCD->decor) & MWM_DECOR_TITLE)
1814 boxdim = TitleBarHeight(pCD);
1816 ((decoration & MWM_DECOR_MENU) ? boxdim : 0) +
1817 ((decoration & MWM_DECOR_MINIMIZE) ? boxdim : 0) +
1818 ((decoration & MWM_DECOR_MAXIMIZE) ? boxdim : 0) -
1819 2*(pCD->matteWidth);
1827 * Process the window gravity (for positioning):
1830 if (flags & P_WIN_GRAVITY)
1832 pCD->windowGravity = pNormalHints->win_gravity;
1836 if (pNormalHints->icccVersion == ICCC_R2)
1838 pCD->windowGravity = wmGD.windowAttributes.win_gravity;
1842 pCD->windowGravity = NorthWestGravity;
1848 * Make sure that all the window sizing constraints are compatible:
1854 * minWidth >= tmpMin
1855 * minWidth >= max (baseWidth, widthInc) > 0
1856 * & an integral number of widthInc from baseWidth.
1857 * minHeight >= max (baseHeight, heightInc) > 0
1858 * & an integral number of heightInc from baseHeight.
1861 if (pCD->minWidth < tmpMin)
1863 if ((diff = ((tmpMin - pCD->baseWidth)%pCD->widthInc)) != 0)
1865 pCD->minWidth = tmpMin + pCD->widthInc - diff;
1869 pCD->minWidth = tmpMin;
1873 if (pCD->minWidth < pCD->baseWidth)
1875 pCD->minWidth = pCD->baseWidth;
1878 if (pCD->minWidth == 0)
1880 pCD->minWidth = pCD->widthInc;
1882 else if ((diff = ((pCD->minWidth - pCD->baseWidth)%pCD->widthInc)) != 0)
1884 pCD->minWidth += pCD->widthInc - diff;
1887 if (pCD->minHeight < pCD->baseHeight)
1889 pCD->minHeight = pCD->baseHeight;
1892 if (pCD->minHeight == 0)
1894 pCD->minHeight = pCD->heightInc;
1896 else if ((diff = ((pCD->minHeight - pCD->baseHeight) % pCD->heightInc)) !=0)
1898 pCD->minHeight += pCD->heightInc - diff;
1904 * maxWidth >= minWidth
1905 * & an integral number of widthInc from baseWidth.
1906 * maxHeight >= minHeight
1907 * & an integral number of heightInc from baseHeight.
1910 if (pCD->maxWidth < pCD->minWidth)
1912 pCD->maxWidth = pCD->minWidth;
1916 * Hack to use maxWidthLimit as the real maxWidth when maximumClientSize
1917 * set to 'vertical'.
1919 if (IS_MAXIMIZE_VERTICAL(pCD))
1921 /* go to min (full screen width, max maximum width) */
1922 pCD->maxWidthLimit = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD)) -
1923 (2 * pCD->clientOffset.x);
1927 pCD->maxWidthLimit = pCD->maxWidth;
1930 pCD->maxWidth -= ((pCD->maxWidth - pCD->baseWidth) % pCD->widthInc);
1934 pCD->oldMaxWidth = pCD->maxWidth;
1937 if (pCD->maxHeight < pCD->minHeight)
1939 pCD->maxHeight = pCD->minHeight;
1943 * Hack to use maxHeightLimit as the real maxHeight when maximumClientSize
1944 * set to 'horizontal'.
1946 if (IS_MAXIMIZE_HORIZONTAL(pCD))
1948 /* go to min (full screen height, max maximum height) */
1949 pCD->maxHeightLimit = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT(pCD)) -
1950 (pCD->clientOffset.x +
1951 pCD->clientOffset.y);
1955 pCD->maxHeightLimit = pCD->maxHeight;
1958 pCD->maxHeight -= ((pCD->maxHeight - pCD->baseHeight) % pCD->heightInc);
1962 pCD->oldMaxHeight = pCD->maxHeight;
1965 if (!firstTime && pCD->maxConfig)
1968 * If the hints changed while we were maximized then
1969 * we may need to adjust the normalized size of the window.
1972 ((oldBaseWidth != pCD->baseWidth) ||
1973 (oldBaseHeight != pCD->baseHeight) ||
1974 (oldWidthInc != pCD->widthInc) ||
1975 (oldHeightInc != pCD->heightInc)))
1977 incWidth = (pCD->clientWidth - oldBaseWidth) / oldWidthInc;
1978 incHeight = (pCD->clientHeight - oldBaseHeight) / oldHeightInc;
1980 (incWidth * pCD->widthInc) + pCD->baseWidth;
1982 (incHeight * pCD->heightInc) + pCD->baseHeight;
1987 * If using aspect ratios, make:
1989 * minWidth / maxHeight <= minAspect.x / minAspect.y
1990 * <= maxAspect.x / maxAspect.y
1991 * <= maxWidth / minHeight
1994 if (pCD->sizeFlags & P_ASPECT)
1996 if (pCD->minWidth * pCD->minAspect.y >
1997 pCD->minAspect.x * pCD->maxHeight)
1999 pCD->minAspect.x = pCD->minWidth;
2000 pCD->minAspect.y = pCD->maxHeight;
2003 if (pCD->maxAspect.x * pCD->minHeight >
2004 pCD->maxWidth * pCD->maxAspect.y)
2006 pCD->maxAspect.x = pCD->maxWidth;
2007 pCD->maxAspect.y = pCD->minHeight;
2010 FixWindowSize (pCD, (unsigned int *) &(pCD->maxWidth),
2011 (unsigned int *) &(pCD->maxHeight),
2012 (unsigned int) (pCD->widthInc),
2013 (unsigned int) (pCD->heightInc));
2017 * If this is the first time, make sure the client dimensions are within
2018 * range and that they satisfy any aspect ratio constraints:
2020 * 0 < minWidth <= clientWidth <= maxWidth
2021 * 0 < minHeight <= clientHeight <= maxHeight
2023 * minAspect.x / minAspect.y <= clientWidth / clientHeight
2024 * <= maxAspect.x / maxAspect.y
2026 * Initial max width/height are set to max of max size or normal
2027 * client size unless a maximumClientSize was specified.
2032 if (!pCD->maximumClientSize.width)
2034 if (pCD->clientWidth > pCD->pSD->maximumMaximumSize.width)
2036 pCD->clientWidth = pCD->pSD->maximumMaximumSize.width;
2040 if (!pCD->maximumClientSize.height)
2042 if (pCD->clientHeight > pCD->pSD->maximumMaximumSize.height)
2044 pCD->clientHeight = pCD->pSD->maximumMaximumSize.height;
2048 FixWindowSize (pCD, (unsigned int *) &(pCD->clientWidth),
2049 (unsigned int *) &(pCD->clientHeight),
2050 (unsigned int) (pCD->widthInc),
2051 (unsigned int) (pCD->heightInc));
2054 } /* END OF FUNCTION ProcessWmNormalHints */
2057 /*************************************<->*************************************
2059 * WmICCCMToXmString (wmNameProp)
2064 * This function uses a property (WM_NAME or WM_ICON_NAME) that was
2065 * retrieved from the window, and converts it to XmString.
2069 * wmNameProp - the text property
2073 * Return = new XmString, or NULL if the property didn't have a value.
2075 *************************************<->***********************************/
2078 WmICCCMToXmString (XTextProperty *wmNameProp)
2081 XmString xms_return;
2082 XmStringTable xmsTable;
2083 int i, nStrings = -1;
2086 if (wmNameProp->value == 0 || strlen((char *)wmNameProp->value) == 0)
2088 return (XmString)NULL;
2091 if (((status = XmCvtTextPropertyToXmStringTable(DISPLAY, wmNameProp,
2092 &xmsTable, &nStrings))
2093 != Success) || (nStrings <= 0))
2097 case XConverterNotFound:
2098 sprintf(msg, GETMESSAGE (70,5,
2099 "Window manager cannot convert property %.100s as clientTitle/iconTitle: XmbTextPropertyToTextList"),
2100 XGetAtomName (DISPLAY,wmNameProp->encoding));
2105 sprintf(msg, GETMESSAGE (70, 6,
2106 "insufficient memory to convert property %.100s as clientTitle/iconTitle: XmbTextPropertyToTextList"),
2107 XGetAtomName(DISPLAY,wmNameProp->encoding));
2111 case XLocaleNotSupported:
2112 if ((wmNameProp->encoding == XA_STRING) ||
2113 (wmNameProp->encoding == wmGD.xa_COMPOUND_TEXT))
2115 sprintf(msg, LOCALE_MSG, setlocale(LC_ALL, NULL));
2119 /* Atom was neither STRING nor COMPOUND_TEXT */
2120 sprintf(msg, GETMESSAGE(70, 8,
2121 "Window manager received unknown property as clientTitle/iconTitle: %.100s. Property ignored."),
2122 XGetAtomName(DISPLAY, wmNameProp->encoding));
2128 /* Couldn't convert using Xm; apply a default */
2129 return XmCvtCTToXmString((char*)wmNameProp->value);
2132 xms_return = xmsTable[0];
2133 for (i = 1; i < nStrings; i++)
2135 #ifdef CONCAT_TEXTLIST
2136 xms_return = XmStringConcatAndFree(xms_return, xmsTable[i]);
2138 XmStringFree(xmsTable[i]);
2139 #endif /* CONCAT_TEXTLIST */
2141 XtFree((char *)xmsTable);
2147 /*************************************<->*************************************
2149 * ProcessWmWindowTitle (pCD, firstTime)
2154 * This function retrieves the contents of the WM_NAME property on the
2155 * cient window. A default name is set if the property does not exist.
2160 * pCD - pointer to client data structure
2161 * firstTime - false if the window is already managed and the title
2167 * pCD - clientTitle, iconTitle
2169 *************************************<->***********************************/
2172 ProcessWmWindowTitle (ClientData *pCD, Boolean firstTime)
2174 XTextProperty wmNameProp;
2175 XmString title_xms = NULL;
2177 if ((pCD->clientDecoration & MWM_DECOR_TITLE) &&
2178 (!firstTime || HasProperty (pCD, XA_WM_NAME)) &&
2179 XGetWMName(DISPLAY, pCD->client, &wmNameProp))
2181 title_xms = WmICCCMToXmString(&wmNameProp);
2182 if (wmNameProp.value)
2183 XFree ((char*)wmNameProp.value);
2188 if (!firstTime && (pCD->iconTitle == pCD->clientTitle))
2191 * The client window title is being used for the icon title so
2192 * change the icon title with the window title.
2194 pCD->iconTitle = title_xms;
2195 RedisplayIconTitle (pCD);
2198 if ((pCD->clientFlags & CLIENT_HINTS_TITLE) &&
2199 pCD->clientTitle != wmGD.clientDefaultTitle)
2201 XmStringFree (pCD->clientTitle);
2204 pCD->clientTitle = title_xms;
2205 pCD->clientFlags |= CLIENT_HINTS_TITLE;
2209 DrawWindowTitle (pCD, True);
2213 * The client frame does not have a place to put the title or the WM_NAME
2214 * property does not exist or there was some error in getting
2215 * the property information, so use a default value.
2219 if (pCD->clientName)
2221 pCD->clientTitle = XmStringCreateLocalized(pCD->clientName);
2225 pCD->clientTitle = wmGD.clientDefaultTitle;
2230 * If this is a tear-off menu, then make sure title text is not clipped
2233 if ((pCD->window_status & MWM_TEAROFF_WINDOW) ||
2234 (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL))
2236 unsigned int boxdim = TitleBarHeight (pCD);
2237 unsigned long decor = pCD->decor;
2238 XmFontList fontList;
2241 if (DECOUPLE_TITLE_APPEARANCE(pCD))
2242 fontList = CLIENT_TITLE_APPEARANCE(pCD).fontList;
2244 fontList = CLIENT_APPEARANCE(pCD).fontList;
2247 * Calculations derived from GetTextBox() and GetFramePartInfo()
2249 minWidth = XmStringWidth(fontList, pCD->clientTitle) +
2250 ((pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL) ? 4 : 0) +
2251 ((decor & MWM_DECOR_MENU) ? boxdim : 0) +
2252 ((decor & MWM_DECOR_MINIMIZE) ? boxdim : 0) +
2253 ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0) +
2254 WM_TOP_TITLE_SHADOW + WM_BOTTOM_TITLE_SHADOW +
2255 WM_TOP_TITLE_PADDING + WM_BOTTOM_TITLE_PADDING;
2257 if (minWidth > pCD->minWidth)
2259 pCD->minWidth = minWidth;
2261 if ((pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL) &&
2262 (pCD->clientWidth < pCD->minWidth))
2264 FixSubpanelEmbeddedClientGeometry (pCD);
2268 } /* END OF FUNCTION ProcessWmWindowTitle */
2270 /*************************************<->*************************************
2272 * FixSubpanelEmbeddedClientGeometry ( pCD )
2277 * This function adjusts the embedded clients in a subpanel if the
2278 * geometry of the subpanel is adjusted.
2283 * pCD - pointer to client data structure
2291 * Only handles change in width right now.
2293 *************************************<->***********************************/
2296 FixSubpanelEmbeddedClientGeometry (ClientData *pCD)
2298 WmScreenData *pSD = PSD_FOR_CLIENT(pCD);
2304 * Get the widget for the subpanel
2306 wSubpanel = WmPanelistWindowToSubpanel (DISPLAY1, pCD->client);
2308 if (pSD->wPanelist && wSubpanel)
2310 WmFpEmbeddedClientData *pECD;
2314 * set new shell width to minimum width
2316 if (pCD->clientWidth < pCD->minWidth)
2319 XtSetArg (al[ac], XmNwidth, pCD->minWidth); ac++;
2320 XtSetValues (wSubpanel, al, ac);
2324 * Cause update of client geometries.
2326 /* WmPanelistSetClientGeometry (pSD->wPanelist); */
2329 * Update all affected reparented controls.
2332 for (i=0; i<pSD->numEmbeddedClients; i++)
2334 pECD = &(((WmFpEmbeddedClientData *) pSD->pECD)[i]);
2338 ClientData *pCD2 = pECD->pCD;
2340 if ((pCD2->clientWidth != pECD->width) ||
2341 (pCD2->clientHeight != pECD->height) ||
2342 (pCD2->clientX != pECD->x) ||
2343 (pCD2->clientY != pECD->y))
2345 pCD2->clientX = pECD->x;
2346 pCD2->clientY = pECD->y;
2347 pCD2->clientWidth = pECD->width;
2348 pCD2->clientHeight = pECD->height;
2350 XMoveResizeWindow (DISPLAY1, pCD2->client,
2351 pECD->x, pECD->y, pECD->width, pECD->height);
2356 } /* END OF FUNCTION FixEmbeddedClientGeometry */
2359 /*************************************<->*************************************
2361 * ProcessWmIconTitle (pCD, firstTime)
2366 * This function retrieves the contents of the WM_ICON_NAME property on the
2367 * cient window. The value of the property is a string that is used for the
2368 * icon title. A default title is set if the property does not exist.
2373 * pCD - pointer to client data structure
2375 * firstTime - false if the window is already managed and the title
2383 *************************************<->***********************************/
2386 ProcessWmIconTitle (ClientData *pCD, Boolean firstTime)
2388 XTextProperty wmIconNameProp;
2389 XmString icon_xms = NULL;
2391 if ((pCD->clientFunctions & MWM_FUNC_MINIMIZE) &&
2392 (pCD->transientLeader == NULL) &&
2393 (!firstTime || HasProperty(pCD, XA_WM_ICON_NAME)) &&
2394 XGetWMIconName (DISPLAY, pCD->client, &wmIconNameProp))
2396 icon_xms = WmICCCMToXmString(&wmIconNameProp);
2397 if (wmIconNameProp.value)
2398 XFree ((char*)wmIconNameProp.value);
2403 if ((pCD->iconFlags & ICON_HINTS_TITLE) &&
2404 pCD->iconTitle != wmGD.iconDefaultTitle)
2406 XmStringFree (pCD->iconTitle);
2409 pCD->iconTitle = icon_xms;
2410 pCD->iconFlags |= ICON_HINTS_TITLE;
2414 RedisplayIconTitle (pCD);
2418 * The WM_ICON_NAME property does not exist (or there was some error
2419 * in getting * the property information), so use a default value.
2423 if (pCD->clientTitle && (pCD->clientTitle != wmGD.clientDefaultTitle))
2425 pCD->iconTitle = pCD->clientTitle;
2429 pCD->iconTitle = wmGD.iconDefaultTitle;
2433 } /* END OF FUNCTION ProcessWmIconTitle */
2437 /*************************************<->*************************************
2439 * ProcessWmTransientFor (pCD)
2444 * This function retrieves the contents of the WM_TRANSIENT_FOR property on
2450 * pCD = pointer to the client data structure for the window with the property
2455 * pCD.transientFor = if tranient then this is the associated main window
2457 * pCD.clientFlags = indicate that this is a transient window
2459 *************************************<->***********************************/
2462 ProcessWmTransientFor (ClientData *pCD)
2468 if ((HasProperty (pCD, XA_WM_TRANSIENT_FOR)) &&
2469 (XGetTransientForHint (DISPLAY, pCD->client, &window)))
2471 pCD->clientFlags |= CLIENT_TRANSIENT;
2474 * Only save the (leader) transientFor window if it is NOT the
2475 * client window and it is already managed by the window manager.
2478 if ((pCD->client != window) &&
2479 !XFindContext (DISPLAY, window, wmGD.windowContextType,
2480 (caddr_t *)&leader))
2482 pCD->transientFor = window;
2483 pCD->transientLeader = leader;
2486 else { /* else this is not a transient window */
2487 pCD->clientFlags &= ~CLIENT_TRANSIENT;
2488 pCD->transientFor = (Window)0L;
2489 pCD->transientLeader = NULL;
2493 } /* END OF FUNCTION ProcessWmTransientFor */
2497 /*************************************<->*************************************
2499 * MakeSystemMenu (pCD)
2504 * This function finds or makes a system menu for the client. A check
2505 * is made for the _MWM_MENU property and, if present, client-specific
2506 * items are added to the custom system menu. Any custom system menu
2507 * must be destroyed when the client is unmanaged (or killed).
2512 * pCD = pointer to the client data structure for the managed window
2517 * pCD.systemMenuSpec = system menu specification for the client, not added
2518 * to wmGD.acceleratorMenuSpecs
2520 *************************************<->***********************************/
2523 MakeSystemMenu (ClientData *pCD)
2525 pCD->mwmMenuItems = GetMwmMenuItems(pCD);
2526 pCD->systemMenuSpec =
2527 MAKE_MENU (PSD_FOR_CLIENT(pCD), pCD, pCD->systemMenu, F_CONTEXT_WINDOW,
2528 F_CONTEXT_WINDOW|F_CONTEXT_ICON, pCD->mwmMenuItems, TRUE);
2530 #ifdef NO_MESSAGE_CATALOG
2531 if (pCD->systemMenuSpec == NULL)
2534 * As the lookup has failed, let's try just one more time.
2536 Warning("Retrying - using builtin window menu\n");
2538 pCD->systemMenuSpec =
2539 MAKE_MENU(PSD_FOR_CLIENT(pCD), pCD, builtinSystemMenuName,
2541 F_CONTEXT_WINDOW|F_CONTEXT_ICON, pCD->mwmMenuItems, TRUE);
2545 } /* END OF FUNCTION MakeSystemMenu */
2549 /*************************************<->*************************************
2551 * InitCColormapData (pCD)
2556 * This function initializes colormap data for the client window that is
2557 * by the window manager in maintaining the colormap focus. This may
2558 * involve retrieving and processing properties that deal with subwindow
2564 * pCD = pointer to the client data structure for the managed window
2569 * pCD.clientColormap = client colormap to be installed when the client
2570 * window gets the colormap focus
2572 * pCD = (cmapWindows, clientCmapList, clientCmapCount, clientCmapIndex)
2574 *************************************<->***********************************/
2577 InitCColormapData (ClientData *pCD)
2580 if (wmGD.windowAttributes.colormap == None)
2582 pCD->clientColormap = WORKSPACE_COLORMAP(pCD);
2586 pCD->clientColormap = wmGD.windowAttributes.colormap;
2590 * Process subwindow colormap windows if they are specified.
2593 ProcessWmColormapWindows (pCD);
2596 } /* END OF FUNCTION InitCColormapData */
2600 /*************************************<->*************************************
2602 * CalculateGravityOffset (pCD, xoff, yoff)
2607 * This function calculates the window offsets based on the window gravity
2608 * and the window frame client offset.
2613 * pCD = pointer to client data (client window configuration fields)
2614 * xoff = pointer to xoffset
2615 * yoff = pointer to yoffset
2620 * xoff = pointer to xoffset set
2621 * yoff = pointer to yoffset set
2623 *************************************<->***********************************/
2626 CalculateGravityOffset (ClientData *pCD, int *xoff, int *yoff)
2628 int borderWidth = pCD->xBorderWidth;
2630 if (pCD->windowGravity < ForgetGravity ||
2631 pCD->windowGravity > StaticGravity)
2638 switch (pCD->windowGravity)
2640 case NorthWestGravity:
2643 *xoff = pCD->clientOffset.x;
2644 *yoff = pCD->clientOffset.y;
2650 *xoff = borderWidth;
2651 *yoff = pCD->clientOffset.y;
2655 case NorthEastGravity:
2657 *xoff = -(pCD->clientOffset.x - (2 * borderWidth));
2658 *yoff = pCD->clientOffset.y;
2664 *xoff = -(pCD->clientOffset.x - (2 * borderWidth));
2665 *yoff = borderWidth +
2666 (pCD->clientOffset.y - pCD->clientOffset.x)/2;
2670 case SouthEastGravity:
2672 *xoff = -(pCD->clientOffset.x - (2 * borderWidth));
2673 *yoff = -(pCD->clientOffset.x - (2 * borderWidth));
2679 *xoff = borderWidth;
2680 *yoff = -(pCD->clientOffset.x - (2 * borderWidth));
2684 case SouthWestGravity:
2686 *xoff = pCD->clientOffset.x;
2687 *yoff = -(pCD->clientOffset.x - (2 * borderWidth));
2693 *xoff = pCD->clientOffset.x;
2694 *yoff = borderWidth +
2695 (pCD->clientOffset.y - pCD->clientOffset.x)/2;
2707 } /* END OF FUNCTION CalculateGravityOffset */
2711 /*************************************<->*************************************
2713 * InitClientPlacement (pCD, manageFlags)
2718 * This function sets up the initial client window placement (for both
2719 * the normal and maximized state).
2724 * pCD = pointer to client data (client window configuration fields)
2726 * manageFlags = flags that indicate wm state information (e.g. whether
2727 * the window manager is starting up or restarting)
2732 * Return = True if position changed by this routine.
2733 * pCD = changes to the client window configuration fields
2735 *************************************<->***********************************/
2738 InitClientPlacement (ClientData *pCD, long manageFlags)
2740 Boolean interactivelyPlaced = False;
2741 Boolean autoPlaced = False;
2742 Boolean rval = False;
2744 int origX, origY, origWidth, origHeight;
2749 * Save initial client values
2751 origX = pCD->clientX;
2752 origY = pCD->clientY;
2753 origWidth = pCD->clientWidth;
2754 origHeight = pCD->clientHeight;
2757 * Do interactive placement if...
2758 * + the resource is turned on
2759 * + the window's coming up on the active screen
2762 * + position specified in DB or by Session Manager
2763 * + the user has specified a position
2764 * + the window is coming up iconic
2765 * + the window is transient
2766 * + we're system modal
2769 if (wmGD.interactivePlacement &&
2770 (!(pCD->clientFlags & (SM_X | SM_Y))) &&
2771 !(pCD->sizeFlags & US_POSITION) &&
2772 (pCD->clientState != MINIMIZED_STATE) &&
2773 (manageFlags == MANAGEW_NORMAL) &&
2774 !(pCD->clientFlags & CLIENT_TRANSIENT) &&
2775 (pCD->inputMode != MWM_INPUT_SYSTEM_MODAL) &&
2776 (ClientInWorkspace(PSD_FOR_CLIENT(pCD)->pActiveWS, pCD)))
2779 * Interactively place the window on the screen.
2781 interactivelyPlaced = True;
2782 PlaceWindowInteractively (pCD);
2787 * Check out the configuration values to insure that they are within
2791 FixWindowConfiguration (pCD, (unsigned int *) &(pCD->clientWidth),
2792 (unsigned int *) &(pCD->clientHeight),
2793 (unsigned int) (pCD->widthInc),
2794 (unsigned int) (pCD->heightInc));
2797 * Do autoplacement of the client window if appropriate.
2800 if ((manageFlags == MANAGEW_NORMAL) && !interactivelyPlaced &&
2801 (!(pCD->clientFlags & (SM_X | SM_Y))) &&
2802 !(pCD->sizeFlags & US_POSITION) &&
2803 !(pCD->clientFlags & CLIENT_TRANSIENT) &&
2804 (pCD->inputMode != MWM_INPUT_SYSTEM_MODAL) && wmGD.clientAutoPlace)
2807 * if (PPosition is on or nonzero), then use current value for
2808 * clientX and clientY which was set to windowAttributes.x,y
2809 * by ProcessWmNormalHints(), else autoplace client.
2812 if ((pCD->sizeFlags & P_POSITION) &&
2813 ((pCD->usePPosition == USE_PPOSITION_ON) ||
2814 ((pCD->usePPosition == USE_PPOSITION_NONZERO) &&
2815 ((pCD->clientX != 0) || (pCD->clientY != 0)))))
2821 FindClientPlacement (pCD);
2827 * Do PositionIsFrame processing:
2828 * Use window gravity to allow the user to specify the window
2829 * position on the screen without having to know the dimensions
2830 * of the decoration that mwm is adding.
2833 if ((wmGD.positionIsFrame) &&
2834 !interactivelyPlaced && !autoPlaced)
2836 CalculateGravityOffset (pCD, &xoff, &yoff);
2837 if (!(pCD->clientFlags & SM_X))
2838 pCD->clientX += xoff;
2839 if (!(pCD->clientFlags & SM_Y))
2840 pCD->clientY += yoff;
2845 * Do PositionOnScreen processing:
2849 if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL)
2851 if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUB_RESTORED)
2857 AdjustSlideOutGeometry (pCD);
2860 else if (((wmGD.positionOnScreen) && !interactivelyPlaced) &&
2861 (!(pCD->clientFlags & (SM_X | SM_Y))))
2863 PlaceFrameOnScreen (pCD, &pCD->clientX, &pCD->clientY,
2864 pCD->clientWidth, pCD->clientHeight);
2869 * Position the maximized frame:
2872 pCD->maxX = pCD->clientX;
2873 pCD->maxY = pCD->clientY;
2874 PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY, pCD->maxWidth,
2878 if (!wmGD.iconAutoPlace)
2880 if (!(pCD->iconFlags & ICON_HINTS_POSITION))
2882 for (iwsc=0; iwsc<pCD->numInhabited; iwsc++)
2884 pCD->pWsList[iwsc].iconX = pCD->clientX;
2885 pCD->pWsList[iwsc].iconY = pCD->clientY;
2886 PlaceIconOnScreen (pCD, &pCD->pWsList[iwsc].iconX,
2887 &pCD->pWsList[iwsc].iconY);
2893 * if client size or position has been changed by this routine,
2894 * then indicate in return value
2896 if ((origX != pCD->clientX) || (origY != pCD->clientY) ||
2897 (origWidth != pCD->clientWidth) || (origHeight != pCD->clientHeight))
2904 } /* END OF FUNCTION InitClientPlacement */
2906 /******************************<->*************************************
2908 * void AdjustSlideOutGeometry (pCD)
2912 * Adjusts the geometry of the slide out panel
2916 * pCD = pointer to a client data of slide out
2923 * Subpanel is to appear above or below the front panel, centered
2924 * on the vertical axis of the spawning control.
2925 ******************************<->***********************************/
2927 AdjustSlideOutGeometry ( ClientData *pCD)
2929 ClientData *pCD_FP = NULL;
2930 WmPanelistObject pPanelist;
2932 pCD->slideDirection = SLIDE_NORTH; /* assume up for now */
2933 pPanelist = (WmPanelistObject) pCD->pSD->wPanelist;
2934 (void) XFindContext (DISPLAY, XtWindow(O_Shell(pPanelist)),
2935 wmGD.windowContextType, (caddr_t *)&pCD_FP);
2940 * Adjust slide up position if coming from front
2942 * (Assumes no nesting of panels !!!)
2943 * (Assumes horizontal oriented front panel!!!)
2945 if (pCD->transientLeader == pCD_FP)
2948 * Subpanel should be sort-of centered already,
2949 * adjust by width of window manager frame.
2951 pCD->clientX -= pCD->frameInfo.lowerBorderWidth;
2954 * Adjust to slide up above front panel.
2956 pCD->clientY = pCD_FP->frameInfo.y -
2957 pCD->frameInfo.lowerBorderWidth -
2958 pCD->clientHeight + 3;
2960 /* RICK -- added the (+ 3) */
2963 if (pCD->clientY < 0)
2966 * Adjust to slide down below front panel.
2968 pCD->clientY = pCD_FP->frameInfo.y +
2969 pCD_FP->frameInfo.height +
2970 pCD->frameInfo.titleBarHeight +
2971 pCD->frameInfo.upperBorderWidth - 3;
2972 pCD->slideDirection = SLIDE_SOUTH;
2973 /* RICK -- added the (- 3) */
2976 if ((pCD->clientY + pCD->clientHeight +
2977 pCD->frameInfo.lowerBorderWidth) >
2978 XDisplayHeight (DISPLAY, pCD->pSD->screen))
2981 * If the bottom of the slide-up is off the bottom
2982 * of the screen, then don't slide, just pop it up.
2984 pCD->slideDirection = SLIDE_NOT;
2987 PlaceFrameOnScreen (pCD, &pCD->clientX, &pCD->clientY,
2988 pCD->clientWidth, pCD->clientHeight);
2994 /*************************************<->*************************************
2996 * PlaceFrameOnScreen (pCD, pX, pY, w, h)
3001 * This function is used to nudge a client window so that it is totally
3002 * onscreen if possible. At least the top left corner will be onscreen.
3007 * pCD - pointer to client data
3008 * pX - pointer to x-coord
3009 * pY - pointer to y-coord
3010 * w - width of window
3011 * h - height of window
3023 *************************************<->***********************************/
3026 PlaceFrameOnScreen (ClientData *pCD, int *pX, int *pY, int w, int h)
3038 clientOffsetX = pCD->clientOffset.x;
3039 clientOffsetY = pCD->clientOffset.y;
3040 frameX = *pX - clientOffsetX;
3041 frameY = *pY - clientOffsetY;
3042 frameWidth = w + (2 * clientOffsetX);
3043 frameHeight = h + clientOffsetX + clientOffsetY;
3044 screenWidth = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD));
3045 screenHeight = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT(pCD));
3047 if ((frameX + frameWidth) > screenWidth)
3049 frameX -= (frameX + frameWidth) - screenWidth;
3051 if ((frameY + frameHeight) > screenHeight)
3053 frameY -= (frameY + frameHeight) - screenHeight;
3064 *pX = frameX + clientOffsetX;
3065 *pY = frameY + clientOffsetY;
3067 } /* END OF FUNCTION PlaceFrameOnScreen */
3071 /*************************************<->*************************************
3073 * PlaceIconOnScreen (pCD, pX, pY)
3078 * This function positions an icon on-screen.
3083 * pCD - pointer to client data
3084 * pX - pointer to x-coord
3085 * pY - pointer to y-coord
3095 *************************************<->***********************************/
3098 PlaceIconOnScreen (ClientData *pCD, int *pX, int *pY)
3106 screenWidth = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD));
3107 screenHeight = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT(pCD));
3111 if ((iconX + ICON_WIDTH(pCD)) > screenWidth)
3113 iconX = screenWidth - ICON_WIDTH(pCD);
3120 if ((iconY + ICON_HEIGHT(pCD)) > screenHeight)
3122 iconY = screenHeight - ICON_HEIGHT(pCD);
3133 } /* END OF FUNCTION PlaceIconOnScreen */
3137 /*************************************<->*************************************
3139 * FixWindowConfiguration (pCD, pWidth, pHeight, widthInc, heightInc)
3144 * This function adjusts the configuration for the client window so that
3145 * it is in line with the client window's sizing constraints.
3150 * pCD = a pointer to the client window data
3151 * pWidth, pHeight = pointers to the window configuration values
3152 * widthInc, heightInc = window size increment values
3157 * pWidth, pHeight = adjusted configuration values are returned here
3160 *************************************<->***********************************/
3163 FixWindowConfiguration (ClientData *pCD, unsigned int *pWidth, unsigned int *pHeight, unsigned int widthInc, unsigned int heightInc)
3168 * Make sure we're on width/height increment boundaries.
3171 if ((int) *pWidth < pCD->minWidth)
3173 *pWidth = pCD->minWidth;
3175 else if ((delta = (*pWidth - pCD->baseWidth) % pCD->widthInc))
3180 if ((int) *pHeight < pCD->minHeight)
3182 *pHeight = pCD->minHeight;
3184 else if ((delta = (*pHeight - pCD->baseHeight) % pCD->heightInc))
3190 * Constrain size within bounds.
3193 FixWindowSize (pCD, pWidth, pHeight, widthInc, heightInc);
3195 } /* END OF FUNCTION FixWindowConfiguration */
3199 /*************************************<->*************************************
3201 * FixWindowSize (pCD, pWidth, pHeight, widthInc, heightInc)
3206 * This function adjusts the client window width and height so that
3207 * it is in line with its sizing constraints.
3212 * pCD = a pointer to the client window data
3213 * pWidth, pHeight = pointers to the window size values
3214 * widthInc, heightInc = window size increment values
3220 * pWidth, pHeight = adjusted size values.
3223 *************************************<->***********************************/
3226 FixWindowSize (ClientData *pCD, unsigned int *pWidth, unsigned int *pHeight, unsigned int widthInc, unsigned int heightInc)
3230 WmScreenData *pSD = pCD->pSD;
3233 * All occurrences of maxHeight and maxWidth in this routing has been
3234 * hacked to use maxHeightLimit and maxWidthLimit as the real max when
3235 * maximumClientSize is set to 'horizontal' or 'vertical', since
3236 * pCD->maxHeight and pCD->maxWidth is fiddle to on reconfiguration.
3239 if ((int) *pWidth < pCD->minWidth)
3241 *pWidth = pCD->minWidth;
3243 else if (*pWidth > pCD->maxWidthLimit &&
3245 !(pCD->clientFlags & CLIENT_WM_CLIENTS))
3247 *pWidth = pCD->maxWidthLimit;
3250 if ((int) *pHeight < pCD->minHeight)
3252 *pHeight = pCD->minHeight;
3254 else if (*pHeight > pCD->maxHeightLimit &&
3256 !(pCD->clientFlags & CLIENT_WM_CLIENTS))
3258 *pHeight = pCD->maxHeightLimit;
3261 if ((pCD->sizeFlags & P_ASPECT) &&
3262 *pWidth * pCD->maxAspect.y > *pHeight * pCD->maxAspect.x)
3264 * Client aspect is too big.
3265 * Candidate height >= client height:
3266 * Try to increase the client's height without violating bounds.
3267 * If this fails, use maximum height and try to decrease its width.
3268 * Candidate height < client height:
3269 * Try to decrease the client's width without violating bounds.
3270 * If this fails, use minimum width and try to increase its height.
3273 if ((*pHeight >= pCD->clientHeight) ||
3274 (*pWidth > pCD->clientWidth))
3276 * Candidate height >= client height:
3277 * Try to increase the client's height without violating bounds.
3278 * If this fails, use maximum height and try to decrease its width.
3281 deltaH = makemult (*pWidth * pCD->maxAspect.y / pCD->maxAspect.x -
3282 *pHeight, heightInc);
3283 if (*pHeight + deltaH <= pCD->maxHeightLimit ||
3284 !pSD->limitResize ||
3285 pCD->clientFlags & CLIENT_WM_CLIENTS)
3291 *pHeight = pCD->maxHeightLimit;
3292 deltaW = makemult (*pWidth - *pHeight * pCD->maxAspect.x /
3293 pCD->maxAspect.y, widthInc);
3294 if (*pWidth - deltaW >= pCD->minWidth)
3300 *pWidth = pCD->minWidth;
3306 * Candidate height < client height and candidate width <= client width.
3307 * Try to decrease the client's width without violating bounds.
3308 * If this fails, use minimum width and try to increase its height.
3311 deltaW = makemult (*pWidth - *pHeight * pCD->maxAspect.x /
3312 pCD->maxAspect.y, widthInc);
3314 if (*pWidth - deltaW >= pCD->minWidth)
3320 *pWidth = pCD->minWidth;
3321 deltaH = makemult (*pWidth * pCD->maxAspect.y /
3322 pCD->maxAspect.x - *pHeight, heightInc);
3323 if (*pHeight + deltaH <= pCD->maxHeightLimit ||
3324 !pSD->limitResize ||
3325 pCD->clientFlags & CLIENT_WM_CLIENTS)
3331 *pHeight = pCD->maxHeightLimit;
3337 else if ((pCD->sizeFlags & P_ASPECT) &&
3338 *pHeight * pCD->minAspect.x > *pWidth * pCD->minAspect.y)
3340 * Client aspect is too small.
3341 * Candidate width >= client width:
3342 * Try to increase the client's width without violating bounds.
3343 * If this fails, use maximum width and try to decrease its height.
3344 * Candidate width < client width:
3345 * Try to decrease the client's height without violating bounds.
3346 * If this fails, use minimum height and try to increase its width.
3349 if ((*pWidth >= pCD->clientWidth) ||
3350 (*pHeight > pCD->clientHeight))
3352 * Candidate width >= client width:
3353 * Try to increase the client's width without violating bounds.
3354 * If this fails, use maximum width and try to decrease its height.
3357 deltaW = makemult (*pHeight * pCD->minAspect.x / pCD->minAspect.y -
3359 if (*pWidth + deltaW <= pCD->maxWidthLimit ||
3360 !pSD->limitResize ||
3361 pCD->clientFlags & CLIENT_WM_CLIENTS)
3367 *pWidth = pCD->maxWidthLimit;
3368 deltaH = makemult (*pHeight - *pWidth * pCD->minAspect.y /
3369 pCD->minAspect.x, heightInc);
3370 if (*pHeight - deltaH >= pCD->minHeight)
3376 *pHeight = pCD->minHeight;
3382 * Candidate width < client width and Candidate height <= client height:
3383 * Try to decrease the client's height without violating bounds.
3384 * If this fails, use minimum height and try to increase its width.
3387 deltaH = makemult (*pHeight - *pWidth * pCD->minAspect.y /
3388 pCD->minAspect.x, heightInc);
3389 if (*pHeight - deltaH >= pCD->minHeight)
3395 *pHeight = pCD->minHeight;
3396 deltaW = makemult (*pHeight * pCD->minAspect.x /
3397 pCD->minAspect.y - *pWidth, widthInc);
3398 if (*pWidth + deltaW <= pCD->maxWidthLimit ||
3399 !pSD->limitResize ||
3400 pCD->clientFlags & CLIENT_WM_CLIENTS)
3406 *pWidth = pCD->maxWidthLimit;
3411 } /* END OF FUNCTION FixWindowSize */
3415 /*************************************<->*************************************
3417 * FindClientPlacement (pCD)
3422 * This function finds a position for the client window on the screen.
3423 * Windows positions are stepped down the screen. An attempt is made
3424 * to keep windows from being clipped by the edge of the screen.
3429 * pCD = pointer to client data (client window configuration fields)
3434 * pCD = changes to the client window configuration fields
3436 *************************************<->***********************************/
3439 FindClientPlacement (ClientData *pCD)
3441 static Boolean clientPlacementInitialized = False;
3442 static int clientPlacementOffset;
3443 static int clientPlacementX;
3444 static int clientPlacementY;
3445 static int clientPlacementOrigin;
3446 static int clientPlacementXOrigin;
3448 Boolean placed = False;
3455 int borderWidth = 0;
3458 WmHeadInfo_t *WmHI = NULL;
3461 if (!clientPlacementInitialized)
3463 if (pCD->clientDecoration & WM_DECOR_RESIZEH)
3465 borderWidth = ((RESIZE_BORDER_WIDTH(pCD) > FRAME_BORDER_WIDTH(pCD))
3466 ? RESIZE_BORDER_WIDTH(pCD) : FRAME_BORDER_WIDTH(pCD));
3470 borderWidth = pCD->matteWidth;
3472 clientPlacementOffset = TitleTextHeight(pCD) + borderWidth;
3473 clientPlacementOrigin = clientPlacementOffset;
3474 clientPlacementX = clientPlacementOrigin;
3475 clientPlacementY = clientPlacementOrigin;
3476 clientPlacementXOrigin = clientPlacementX;
3477 clientPlacementInitialized = True;
3480 frameWidth = pCD->clientWidth + (2 * pCD->clientOffset.x);
3481 frameHeight = pCD->clientHeight + pCD->clientOffset.y + pCD->clientOffset.x;
3483 if (WmHI = GetHeadInfo(wmGD.keyboardFocus)) {
3484 /* Use Head metrics for placeable area */
3485 screenX = WmHI->x_org;
3486 screenY = WmHI->y_org;
3487 screenWidth = WmHI->width;
3488 screenHeight = WmHI->height;
3492 /* Use X Screen metrics for placeable area */
3495 screenWidth = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD));
3496 screenHeight = DisplayHeight (DISPLAY, SCREEN_FOR_CLIENT(pCD));
3501 if ((clientPlacementX - pCD->clientOffset.x + frameWidth)
3510 if ((clientPlacementY - pCD->clientOffset.y + frameHeight)
3520 if (offScreenX || offScreenY)
3522 if (clientPlacementX == clientPlacementOrigin)
3525 * Placement location is already as far to the NW as it is
3531 else if (clientPlacementY == clientPlacementOrigin)
3534 * Placement location is as far to the N as it is going to go.
3535 * Use the current placement if the window is not off the
3536 * screen in the x coordinate otherwise reset the placement
3537 * back to the NW origin.
3542 clientPlacementXOrigin = clientPlacementOrigin;
3543 clientPlacementX = clientPlacementXOrigin;
3550 * If window is off the right edge of screen, just move
3551 * window in the X direction onto screen. Process similarly
3552 * for windows that are off the bottom of the screen.
3555 if (offScreenX && !offScreenY)
3557 clientPlacementX = clientPlacementOrigin;
3559 else if (offScreenY && !offScreenX)
3561 clientPlacementY = clientPlacementOrigin;
3567 * Reset the placement location back to the NW of the
3568 * current location. Go as far N as possible and step the
3569 * x coordinate to the E.
3572 clientPlacementXOrigin += clientPlacementOffset;
3573 clientPlacementX = clientPlacementXOrigin;
3574 clientPlacementY = clientPlacementOrigin;
3585 * The window has been placed, now update the placement information.
3588 pCD->clientX = clientPlacementX + screenX;
3589 pCD->clientY = clientPlacementY + screenY;
3590 clientPlacementX += clientPlacementOffset;
3592 if (clientPlacementX >= screenWidth)
3594 clientPlacementXOrigin = clientPlacementOrigin;
3595 clientPlacementX = clientPlacementXOrigin;
3597 clientPlacementY += clientPlacementOffset;
3600 * Reset Y position to top of screen so that windows start new column of
3601 * placement that is offset from the previous column. Previously, the new
3602 * column was place right over the old column, obscuring it.
3603 * NOTE: column == diagonal
3606 if (clientPlacementY >= (screenHeight / 3))
3608 clientPlacementY = clientPlacementOrigin;
3612 } /* END OF FUNCTION FindClientPlacement */
3616 /*************************************<->*************************************
3618 * WmGetWindowAttributes (window)
3623 * This function gets window attributes if necessary and saves them in the
3624 * global window attribute cache. If the window attributes are already
3625 * there then no X call is made.
3630 * window = get attributes for window with this id
3635 * wmGD.attributesWindow = set to window that matches windowAttributes
3637 * wmGD.windowAttributes = XWindowAttributes of window
3642 * The attributes in the global cache are (known) current only for a
3643 * single pass through the wm event processing loop. They (should be)
3644 * regularly cleared.
3646 *************************************<->***********************************/
3649 WmGetWindowAttributes (Window window)
3651 if (wmGD.attributesWindow != window)
3653 if (!XGetWindowAttributes (DISPLAY, window, &wmGD.windowAttributes))
3656 * Cannot get window attributes.
3659 wmGD.attributesWindow = (Window)0L;
3662 wmGD.attributesWindow = window;
3667 } /* END OF FUNCTION WmGetWindowAttributes */
3671 /*************************************<->*************************************
3673 * SetupClientIconWindow (pCD, window)
3678 * This function prepares a client supplied icon window for insertion into
3679 * a window manager icon frame.
3684 * pCD = pointer to client data
3686 * window = client supplied icon window
3691 * pCD = (iconWindow)
3693 * Return = True if the icon window can be used
3695 *************************************<->***********************************/
3698 SetupClientIconWindow (ClientData *pCD, Window window)
3704 * Check to see if the icon window can be used (i.e there is no conflict
3708 if (!XFindContext (DISPLAY, window, wmGD.windowContextType,
3711 if (window == pCD->client)
3714 * The proposed icon window is the same as the client!
3721 * The proposed icon window is already being managed.
3722 * Assume that we managed it by mistake. Unmanage the
3723 * window and use it as the icon window for this client.
3726 UnManageWindow (pcd);
3729 /* update client data */
3730 pCD->iconWindow = window;
3732 /* put in window manager's save set */
3733 XChangeSaveSet (DISPLAY, pCD->iconWindow, SetModeInsert);
3734 pCD->clientFlags |= ICON_IN_SAVE_SET;
3738 } /* END OF FUNCTION SetupClientIconWindow */
3742 /*************************************<->*************************************
3744 * ProcessMwmHints (pCD)
3749 * Process the _MWM_HINTS property on the window (if any). Setup the
3750 * applicable function and decoration masks.
3755 * pCD = pointer to client data
3760 * pCD = may be changed.
3762 *************************************<->***********************************/
3765 ProcessMwmHints (ClientData *pCD)
3767 PropMwmHints *pHints;
3771 * Fix the client functions and decorations fields if they have
3772 * default resource values.
3775 if (pCD->clientFunctions & WM_FUNC_DEFAULT)
3777 if (pCD->clientFlags & CLIENT_TRANSIENT)
3779 pCD->clientFunctions = TRANSIENT_FUNCTIONS(pCD);
3783 pCD->clientFunctions = WM_FUNC_ALL;
3785 if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL)
3787 pCD->clientFunctions &= WM_FUNC_SUBPANEL_DEFAULT;
3788 pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
3790 else if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_PANEL)
3792 pCD->clientFunctions &= WM_FUNC_PANEL_DEFAULT;
3793 pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
3797 if (pCD->clientDecoration & WM_DECOR_DEFAULT)
3799 if (pCD->clientFlags & CLIENT_TRANSIENT)
3801 pCD->clientDecoration = TRANSIENT_DECORATION(pCD);
3805 pCD->clientDecoration = WM_DECOR_ALL;
3807 if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL)
3809 pCD->clientDecoration = pCD->pSD->subpanelDecoration;
3811 else if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_PANEL)
3813 pCD->clientDecoration &= WM_DECOR_PANEL_DEFAULT;
3819 * Retrieve the _MWM_HINTS property if it exists.
3822 pCD->inputMode = MWM_INPUT_MODELESS;
3824 if ((pHints = GetMwmHints (pCD)) != NULL)
3826 if (pHints->flags & MWM_HINTS_FUNCTIONS)
3828 if (pHints->functions & MWM_FUNC_ALL)
3830 /* client indicating inapplicable functions */
3831 pCD->clientFunctions &= ~(pHints->functions);
3835 /* client indicating applicable functions */
3836 pCD->clientFunctions &= pHints->functions;
3839 if (!(pCD->clientFlags & GOT_DT_WM_HINTS) &&
3843 * !!! Backward compatibility heurisitic !!!
3845 * If client doesn't want any functions and
3846 * no DT_WM_HINTS specified, then remove
3847 * workspace functions.
3849 pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
3852 /* !!! check for some minimal level of functionality? !!! */
3855 if (pHints->flags & MWM_HINTS_DECORATIONS)
3857 if (pHints->decorations & MWM_DECOR_ALL)
3859 /* client indicating decorations to be removed */
3860 pCD->clientDecoration &= ~(pHints->decorations);
3864 /* client indicating decorations to be added */
3865 pCD->clientDecoration &= pHints->decorations;
3869 * Fix up decoration configuration.
3872 if (pCD->clientDecoration &
3873 (MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE))
3875 pCD->clientDecoration |= MWM_DECOR_TITLE;
3877 if (pCD->clientDecoration & MWM_DECOR_RESIZEH)
3879 pCD->clientDecoration |= MWM_DECOR_BORDER;
3883 if (pHints->flags & MWM_HINTS_INPUT_MODE)
3885 if ((pHints->inputMode == MWM_INPUT_PRIMARY_APPLICATION_MODAL) ||
3886 (pHints->inputMode == MWM_INPUT_FULL_APPLICATION_MODAL) ||
3887 ((pHints->inputMode == MWM_INPUT_SYSTEM_MODAL) &&
3888 !wmGD.systemModalActive))
3891 pCD->inputMode = pHints->inputMode;
3896 * Don't allow a system modal window to be a secondary window
3897 * (except with respect to applicable functions and frame
3898 * decorations). Also, don't allow system modal window to
3902 if (pCD->inputMode == MWM_INPUT_SYSTEM_MODAL)
3904 pCD->transientLeader = NULL;
3905 if (pCD->clientFunctions & MWM_FUNC_MINIMIZE)
3907 pCD->clientFunctions &= ~(MWM_FUNC_MINIMIZE);
3912 if (pHints->flags & MWM_HINTS_STATUS)
3914 pCD->window_status = pHints->status;
3917 XFree ((char*)pHints);
3919 #ifndef NO_OL_COMPAT
3922 ProcessOLDecoration (pCD);
3924 #endif /* NO_OL_COMPAT */
3927 * If primary window can't move between workspaces, then
3928 * secondary window shouldn't either.
3930 if (pCD->transientLeader &&
3931 !(pCD->transientLeader->dtwmFunctions & DtWM_FUNCTION_OCCUPY_WS))
3933 pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
3937 * Fix up functions based on system modal settings. System modal
3938 * windows and their descendents cannot be minimized.
3941 if (!((FindTransientTreeLeader (pCD))->clientFunctions&MWM_FUNC_MINIMIZE))
3943 pCD->clientFunctions &= ~MWM_FUNC_MINIMIZE;
3948 * Fix up decoration configuration based on applicable functions.
3951 if (!(pCD->clientFunctions & MWM_FUNC_RESIZE))
3953 pCD->clientDecoration &= ~MWM_DECOR_RESIZEH;
3956 if (!(pCD->clientFunctions & MWM_FUNC_MINIMIZE))
3958 pCD->clientDecoration &= ~MWM_DECOR_MINIMIZE;
3961 if (!(pCD->clientFunctions & MWM_FUNC_MAXIMIZE))
3963 pCD->clientDecoration &= ~MWM_DECOR_MAXIMIZE;
3966 pCD->decor = pCD->clientDecoration; /* !!! combine decor ... !!! */
3969 } /* END OF ProcessMwmHints */