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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
25 * (c) Copyright 1989 Sun Microsystems, Inc.
26 * (c) Copyright 1993 HEWLETT-PACKARD COMPANY
31 static char rcsid[] = "$XConsortium: WmOL.c /main/4 1995/11/01 11:45:08 rswiston $"
41 #define ValidPropertyList(pcd) ((pcd)->paInitialProperties != NULL)
45 /*************************************<->*************************************
51 * Interns the atoms necessary for OL protocols.
59 *************************************<->***********************************/
64 XmInternAtom (DISPLAY, OL_WIN_ATTR, False);
65 wmGD.xa_OL_DECOR_RESIZE =
66 XmInternAtom (DISPLAY, OL_DECOR_RESIZE, False);
67 wmGD.xa_OL_DECOR_HEADER =
68 XmInternAtom (DISPLAY, OL_DECOR_HEADER, False);
69 wmGD.xa_OL_DECOR_CLOSE =
70 XmInternAtom (DISPLAY, OL_DECOR_CLOSE, False);
71 wmGD.xa_OL_DECOR_PIN =
72 XmInternAtom (DISPLAY, OL_DECOR_PIN, False);
73 wmGD.xa_OL_DECOR_ADD =
74 XmInternAtom (DISPLAY, OL_DECOR_ADD, False);
75 wmGD.xa_OL_DECOR_DEL =
76 XmInternAtom (DISPLAY, OL_DECOR_DEL, False);
78 XmInternAtom (DISPLAY, OL_WT_BASE, False);
79 wmGD.xa_OL_WT_COMMAND =
80 XmInternAtom (DISPLAY, OL_WT_CMD, False);
82 XmInternAtom (DISPLAY, OL_WT_HELP, False);
83 wmGD.xa_OL_WT_NOTICE =
84 XmInternAtom (DISPLAY, OL_WT_NOTICE, False);
86 XmInternAtom (DISPLAY, OL_WT_OTHER, False);
88 XmInternAtom (DISPLAY, OL_PIN_IN, False);
90 XmInternAtom (DISPLAY, OL_PIN_OUT, False);
91 wmGD.xa_OL_MENU_LIMITED =
92 XmInternAtom (DISPLAY, OL_MENU_LIMITED, False);
93 wmGD.xa_OL_MENU_FULL =
94 XmInternAtom (DISPLAY, OL_MENU_FULL, False);
96 } /* END OF FUNCTION InitOLCompat */
100 /*************************************<->*************************************
102 * HasOpenLookHints (pCD)
106 * Returns True if this client has OpenLook hints on it.
110 * pCD = pointer to client data
114 * Returns True if client has the _OL_WIN_ATTR property on it.
116 *************************************<->***********************************/
121 Boolean rval = False;
122 OLWinAttr *property = NULL;
124 if (ValidPropertyList (pCD) &&
125 HasProperty(pCD, wmGD.xa_OL_WIN_ATTR))
129 else if ((property=GetOLWinAttr (pCD)) != NULL)
131 XFree ((char *) property);
137 } /* END OF FUNCTION HasOpenLookHints */
141 /*************************************<->*************************************
147 * Fetches the OLWinAttr property off of the client
151 * pCD = pointer to client data
155 * Returns a pointer to the OLWinAttr property if found and valid.
156 * (Returned data should be freed with XFree())
157 * Returns NULL pointer otherwise.
159 *************************************<->***********************************/
164 Boolean rval = False;
165 OLWinAttr *property = NULL;
169 unsigned long nitems;
170 unsigned long leftover;
173 ret_val = XGetWindowProperty (DISPLAY, pCD->client, wmGD.xa_OL_WIN_ATTR,
175 False, wmGD.xa_OL_WIN_ATTR,
176 &actual_type, &actual_format,
177 &nitems, &leftover, (unsigned char **)&property);
179 if (ret_val != Success)
183 else if ((actual_format != 32) ||
184 (actual_type != wmGD.xa_OL_WIN_ATTR))
187 XFree((char *)property);
191 if (property && (nitems == OLDOLWINATTRLENGTH))
193 /* Old size, convert to new size */
195 * !!! Should use XAlloc() here, but Xlib doesn't
196 * define an inverse function of XFree(). !!!
198 prop_new = (OLWinAttr *) malloc (sizeof(OLWinAttr));
200 prop_new->flags = WA_WINTYPE | WA_MENUTYPE | WA_PINSTATE;
201 prop_new->win_type = ((old_OLWinAttr *)property)->win_type;
202 prop_new->menu_type = ((old_OLWinAttr *)property)->menu_type;
203 prop_new->pin_initial_state =
204 ((old_OLWinAttr *)property)->pin_initial_state;
206 XFree ((char *) property);
210 /* convert pin state for old clients */
211 if (property && (property->flags & WA_PINSTATE))
213 if (property->pin_initial_state == wmGD.xa_OL_PIN_IN)
215 property->pin_initial_state = PIN_IN;
217 else if (property->pin_initial_state == wmGD.xa_OL_PIN_OUT)
219 property->pin_initial_state = PIN_OUT;
225 } /* END OF FUNCTION GetOLWinAttr */
228 /*************************************<->*************************************
230 * GetOLDecorFlags (pCD, property, pDecor)
234 * Fetches the _OL_DECOR_ADD or _OL_DECOR_DEL property off of the
235 * client and returns OL flavored decor flags.
239 * pCD = pointer to client data
240 * property = property to fetch
241 * pDecor = pointer to OL decor flags word
245 * Return = True if property found, False otherwise
246 * *pDecor = OL decor flags if valid property found,
247 * undefined if property not found.
249 *************************************<->***********************************/
254 unsigned long *pDecor)
260 unsigned long nitems;
261 unsigned long leftover;
264 status = XGetWindowProperty (DISPLAY, pCD->client, property,
267 &actual_type, &actual_format,
268 &nitems, &leftover, (unsigned char **)&pAtoms);
270 if ((status != Success) ||
273 (actual_type != XA_ATOM) ||
274 (actual_format != 32))
277 XFree((char *)pAtoms);
285 * We only look for the ones we might be interested in.
286 * Several OL decoration types are ignored.
288 for (i = 0; i < nitems; i++) {
289 if (pAtoms[i] == wmGD.xa_OL_DECOR_RESIZE)
290 *pDecor |= OLDecorResizeable;
291 else if (pAtoms[i] == wmGD.xa_OL_DECOR_HEADER)
292 *pDecor |= OLDecorHeader;
293 else if (pAtoms[i] == wmGD.xa_OL_DECOR_CLOSE)
294 *pDecor |= OLDecorCloseButton;
295 else if (pAtoms[i] == wmGD.xa_OL_DECOR_PIN)
296 *pDecor |= OLDecorPushPin;
299 XFree((char *)pAtoms);
305 } /* END OF FUNCTION GetOLDecorFlags */
309 /*************************************<->*************************************
311 * ProcessOLDecoration (pCD)
318 * pCD = pointer to client data
322 * pCD = possibly modified with new decoration info
324 *************************************<->***********************************/
329 OLWinAttr * pOLWinAttr;
330 unsigned long OLdecor;
333 if (HasOpenLookHints (pCD) &&
334 ((pOLWinAttr = GetOLWinAttr (pCD)) != NULL))
337 * This window already has some decoration applied to
338 * it based on its ICCCM type (transient or not).
339 * Use the OL hints to construct a mask to further
340 * modify these decorations.
342 if ((pOLWinAttr->flags & WA_WINTYPE) == 0)
345 * Window type not specified, assume all decorations
347 decorMask = WM_DECOR_ALL;
349 else if (pOLWinAttr->win_type == wmGD.xa_OL_WT_BASE)
352 * Base windows can have all decorations
354 decorMask = WM_DECOR_ALL;
356 else if (pOLWinAttr->win_type == wmGD.xa_OL_WT_COMMAND)
359 * Command windows have titles, pins (close button), and
362 decorMask = WM_DECOR_TITLE | WM_DECOR_SYSTEM | WM_DECOR_RESIZEH;
364 else if (pOLWinAttr->win_type == wmGD.xa_OL_WT_HELP)
367 * Help windows have titles and pins (close button).
368 * No resize, but give it a border to look nicer.
370 decorMask = (WM_DECOR_TITLE | WM_DECOR_SYSTEM | WM_DECOR_BORDER);
372 else if ((pOLWinAttr->win_type == wmGD.xa_OL_WT_NOTICE) &&
373 (pOLWinAttr->win_type == wmGD.xa_OL_WT_OTHER))
375 decorMask = WM_DECOR_NONE;
379 decorMask = WM_DECOR_ALL;
382 if (GetOLDecorAdd(pCD,&OLdecor))
384 if (OLdecor & OLDecorResizeable)
386 decorMask |= WM_DECOR_RESIZEH;
388 if (OLdecor & OLDecorHeader)
390 decorMask |= WM_DECOR_TITLE;
392 if (OLdecor & OLDecorCloseButton)
394 /* OL "close" is same as "Motif" minimize */
395 decorMask |= MWM_DECOR_MINIMIZE;
397 if (OLdecor & OLDecorPushPin)
400 * windows with pins can't be minimized
402 decorMask &= ~MWM_DECOR_MINIMIZE;
403 decorMask |= MWM_DECOR_TITLE | MWM_DECOR_MENU;
407 if (GetOLDecorDel(pCD,&OLdecor))
409 if (OLdecor & OLDecorResizeable)
411 decorMask &= ~MWM_DECOR_RESIZEH;
413 if (OLdecor & OLDecorHeader)
415 decorMask &= ~WM_DECOR_TITLEBAR;
417 if (OLdecor & OLDecorCloseButton)
419 /* OL "close" is same as "Motif" minimize */
420 decorMask &= ~MWM_DECOR_MINIMIZE;
423 /* push pin is ignored here */
428 * If the window has a push pin or a limited menu,
429 * then consider it very similar to a secondary window.
431 if (((pOLWinAttr->flags & WA_PINSTATE) &&
432 (pOLWinAttr->pin_initial_state == PIN_IN)) ||
433 ((pOLWinAttr->flags & WA_MENUTYPE) &&
434 (pOLWinAttr->menu_type == wmGD.xa_OL_MENU_LIMITED)))
436 decorMask &= ~(MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE);
437 pCD->bPseudoTransient = True;
438 pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
442 * Reduce decoration on this window according to OL hints
444 pCD->clientDecoration &= decorMask;
447 * Reduce client functions if necessary.
449 if (!(decorMask & MWM_DECOR_MINIMIZE))
451 pCD->clientFunctions &= ~MWM_FUNC_MINIMIZE;
453 if (!(decorMask & MWM_DECOR_MAXIMIZE))
455 pCD->clientFunctions &= ~MWM_FUNC_MAXIMIZE;
457 if (!(decorMask & MWM_DECOR_RESIZEH))
459 pCD->clientFunctions &= ~MWM_FUNC_RESIZE;
463 * Set the clients secondariesOnTop value to false to allow
464 * open look transient behaviour (transients below primary).
466 pCD->secondariesOnTop = False;
469 XFree((char *)pOLWinAttr);
472 } /* END OF FUNCTION ProcessOLDecoration */
474 #endif /* NO_OL_COMPAT */