2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies of the Software, its documentation and marketing & publicity
13 * materials, and acknowledgment shall be given in the documentation, materials
14 * and software packages that this Software was used.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 /* Motif window hints */
28 #define MWM_HINTS_FUNCTIONS (1L << 0)
29 #define MWM_HINTS_DECORATIONS (1L << 1)
30 #define MWM_HINTS_INPUT_MODE (1L << 2)
31 #define MWM_HINTS_STATUS (1L << 3)
33 /* bit definitions for MwmHints.functions */
34 #define MWM_FUNC_ALL (1L << 0)
35 #define MWM_FUNC_RESIZE (1L << 1)
36 #define MWM_FUNC_MOVE (1L << 2)
37 #define MWM_FUNC_MINIMIZE (1L << 3)
38 #define MWM_FUNC_MAXIMIZE (1L << 4)
39 #define MWM_FUNC_CLOSE (1L << 5)
41 /* bit definitions for MwmHints.decorations */
42 #define MWM_DECOR_ALL (1L << 0)
43 #define MWM_DECOR_BORDER (1L << 1)
44 #define MWM_DECOR_RESIZEH (1L << 2)
45 #define MWM_DECOR_TITLE (1L << 3)
46 #define MWM_DECOR_MENU (1L << 4)
47 #define MWM_DECOR_MINIMIZE (1L << 5)
48 #define MWM_DECOR_MAXIMIZE (1L << 6)
50 /* bit definitions for MwmHints.inputMode */
51 #define MWM_INPUT_MODELESS 0
52 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
53 #define MWM_INPUT_SYSTEM_MODAL 2
54 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
56 #define PROP_MWM_HINTS_ELEMENTS 5
57 #define PROP_MWM_HINTS_ELEMENTS_MIN 4
59 static Atom _MOTIF_WM_HINTS = 0;
61 /* Motif window hints */
71 MWM_GetHints(EWin * ewin, Atom atom_change)
75 unsigned long num, end;
79 if (EwinIsInternal(ewin))
83 _MOTIF_WM_HINTS = EInternAtom("_MOTIF_WM_HINTS");
85 if (atom_change && atom_change != _MOTIF_WM_HINTS)
89 ewin->mwm.decor_border = 1;
90 ewin->mwm.decor_resizeh = 1;
91 ewin->mwm.decor_title = 1;
92 ewin->mwm.decor_menu = 1;
93 ewin->mwm.decor_minimize = 1;
94 ewin->mwm.decor_maximize = 1;
95 ewin->mwm.func_resize = 1;
96 ewin->mwm.func_move = 1;
97 ewin->mwm.func_minimize = 1;
98 ewin->mwm.func_maximize = 1;
99 ewin->mwm.func_close = 1;
102 XGetWindowProperty(disp, EwinGetClientXwin(ewin), _MOTIF_WM_HINTS, 0, 20,
103 False, _MOTIF_WM_HINTS, &a2, &fmt, &num, &end, &puc);
104 mwmhints = (MWMHints *) puc;
108 if (num < PROP_MWM_HINTS_ELEMENTS_MIN)
111 if (mwmhints->flags & MWM_HINTS_DECORATIONS)
113 ewin->mwm.decor_border = 0;
114 ewin->mwm.decor_resizeh = 0;
115 ewin->mwm.decor_title = 0;
116 ewin->mwm.decor_menu = 0;
117 ewin->mwm.decor_minimize = 0;
118 ewin->mwm.decor_maximize = 0;
119 if (mwmhints->decorations & MWM_DECOR_ALL)
121 ewin->mwm.decor_border = 1;
122 ewin->mwm.decor_resizeh = 1;
123 ewin->mwm.decor_title = 1;
124 ewin->mwm.decor_menu = 1;
125 ewin->mwm.decor_minimize = 1;
126 ewin->mwm.decor_maximize = 1;
128 if (mwmhints->decorations & MWM_DECOR_BORDER)
129 ewin->mwm.decor_border = 1;
130 if (mwmhints->decorations & MWM_DECOR_RESIZEH)
131 ewin->mwm.decor_resizeh = 1;
132 if (mwmhints->decorations & MWM_DECOR_TITLE)
133 ewin->mwm.decor_title = 1;
134 if (mwmhints->decorations & MWM_DECOR_MENU)
135 ewin->mwm.decor_menu = 1;
136 if (mwmhints->decorations & MWM_DECOR_MINIMIZE)
137 ewin->mwm.decor_minimize = 1;
138 if (mwmhints->decorations & MWM_DECOR_MAXIMIZE)
139 ewin->mwm.decor_maximize = 1;
142 if (mwmhints->flags & MWM_HINTS_FUNCTIONS)
144 ewin->mwm.func_resize = 0;
145 ewin->mwm.func_move = 0;
146 ewin->mwm.func_minimize = 0;
147 ewin->mwm.func_maximize = 0;
148 ewin->mwm.func_close = 0;
149 if (mwmhints->functions & MWM_FUNC_ALL)
151 ewin->mwm.func_resize = 1;
152 ewin->mwm.func_move = 1;
153 ewin->mwm.func_minimize = 1;
154 ewin->mwm.func_maximize = 1;
155 ewin->mwm.func_close = 1;
157 if (mwmhints->functions & MWM_FUNC_RESIZE)
158 ewin->mwm.func_resize = 1;
159 if (mwmhints->functions & MWM_FUNC_MOVE)
160 ewin->mwm.func_move = 1;
161 if (mwmhints->functions & MWM_FUNC_MINIMIZE)
162 ewin->mwm.func_minimize = 1;
163 if (mwmhints->functions & MWM_FUNC_MAXIMIZE)
164 ewin->mwm.func_maximize = 1;
165 if (mwmhints->functions & MWM_FUNC_CLOSE)
166 ewin->mwm.func_close = 1;
169 if (!ewin->mwm.decor_title && !ewin->mwm.decor_border)
170 ewin->props.no_border = 1;
186 a1 = EInternAtom("_MOTIF_WM_INFO");
188 mwminfo.win = WinGetXwin(VROOT);
189 XChangeProperty(disp, WinGetXwin(VROOT), a1, a1, 32, PropModeReplace,
190 (unsigned char *)&mwminfo, 2);