1 /* motif.c-- stuff for support for mwm hints
3 * Window Maker window manager
5 * Copyright (c) 1998-2003 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <X11/Xutil.h>
30 #include "WindowMaker.h"
33 #include "properties.h"
38 /* Motif window hints */
39 #define MWM_HINTS_FUNCTIONS (1L << 0)
40 #define MWM_HINTS_DECORATIONS (1L << 1)
42 /* bit definitions for MwmHints.functions */
43 #define MWM_FUNC_ALL (1L << 0)
44 #define MWM_FUNC_RESIZE (1L << 1)
45 #define MWM_FUNC_MOVE (1L << 2)
46 #define MWM_FUNC_MINIMIZE (1L << 3)
47 #define MWM_FUNC_MAXIMIZE (1L << 4)
48 #define MWM_FUNC_CLOSE (1L << 5)
50 /* bit definitions for MwmHints.decorations */
51 #define MWM_DECOR_ALL (1L << 0)
52 #define MWM_DECOR_BORDER (1L << 1)
53 #define MWM_DECOR_RESIZEH (1L << 2)
54 #define MWM_DECOR_TITLE (1L << 3)
55 #define MWM_DECOR_MENU (1L << 4)
56 #define MWM_DECOR_MINIMIZE (1L << 5)
57 #define MWM_DECOR_MAXIMIZE (1L << 6)
59 /* Motif window hints */
68 static Atom _XA_MOTIF_WM_HINTS
;
70 static void setupMWMHints(WWindow
*wwin
, MWMHints
*mwm_hints
)
73 * We will ignore all decoration hints that have an equivalent as
74 * functions, because wmaker does not distinguish decoration hints
77 if (mwm_hints
->flags
& MWM_HINTS_DECORATIONS
) {
78 WSETUFLAG(wwin
, no_titlebar
, 1);
79 WSETUFLAG(wwin
, no_close_button
, 1);
80 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
81 WSETUFLAG(wwin
, no_resizebar
, 1);
83 if (mwm_hints
->decorations
& MWM_DECOR_ALL
) {
84 WSETUFLAG(wwin
, no_titlebar
, 0);
85 WSETUFLAG(wwin
, no_close_button
, 0);
86 WSETUFLAG(wwin
, no_closable
, 0);
87 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
88 WSETUFLAG(wwin
, no_miniaturizable
, 0);
89 WSETUFLAG(wwin
, no_resizebar
, 0);
90 WSETUFLAG(wwin
, no_resizable
, 0);
93 if (mwm_hints
->decorations
& MWM_DECOR_BORDER
) {
95 * WindowMaker is drawing only a discreet 1 pixel border without
96 * any decoration like a few other X window managers used to do, so
97 * we assume it is not worth spending the time to add extra
98 * complexity to handle this special request, considering also that
99 * the Motif toolkit is not used anymore nowadays.
103 if (mwm_hints
->decorations
& MWM_DECOR_RESIZEH
)
104 WSETUFLAG(wwin
, no_resizebar
, 0);
106 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
107 WSETUFLAG(wwin
, no_titlebar
, 0);
108 WSETUFLAG(wwin
, no_close_button
, 0);
109 WSETUFLAG(wwin
, no_closable
, 0);
112 if (mwm_hints
->decorations
* MWM_DECOR_MENU
) {
114 * WindowMaker does not include a button to display the menu
115 * for windows, this is done using right mouse button on the
116 * title bar. As a consequence, we ignore this flag because we
117 * have nothing to hide.
121 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
122 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
123 WSETUFLAG(wwin
, no_miniaturizable
, 0);
126 if (mwm_hints
->decorations
& MWM_DECOR_MAXIMIZE
) {
128 * WindowMaker does not display a button to maximize windows,
129 * so we don't need to hide anything more for that flag
134 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
135 WSETUFLAG(wwin
, no_closable
, 1);
136 WSETUFLAG(wwin
, no_miniaturizable
, 1);
137 WSETUFLAG(wwin
, no_resizable
, 1);
139 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
140 WSETUFLAG(wwin
, no_closable
, 0);
141 WSETUFLAG(wwin
, no_miniaturizable
, 0);
142 WSETUFLAG(wwin
, no_resizable
, 0);
144 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
)
145 WSETUFLAG(wwin
, no_resizable
, 0);
147 if (mwm_hints
->functions
& MWM_FUNC_MOVE
) {
149 * WindowMaker does not allow a window to not be moved, and this
150 * is a good thing, so we explicitly ignore this flag.
154 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
)
155 WSETUFLAG(wwin
, no_miniaturizable
, 0);
157 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
158 /* a window must be resizable to be maximizable */
159 WSETUFLAG(wwin
, no_resizable
, 0);
161 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
)
162 WSETUFLAG(wwin
, no_closable
, 0);
166 static int getMWMHints(Window window
, MWMHints
*mwmhints
)
171 if (!_XA_MOTIF_WM_HINTS
)
172 _XA_MOTIF_WM_HINTS
= XInternAtom(dpy
, "_MOTIF_WM_HINTS", False
);
174 data
= (unsigned long *)PropGetCheckProperty(window
, _XA_MOTIF_WM_HINTS
,
175 _XA_MOTIF_WM_HINTS
, 32, 0, &count
);
182 mwmhints
->flags
= data
[0];
183 mwmhints
->functions
= data
[1];
184 mwmhints
->decorations
= data
[2];
185 mwmhints
->inputMode
= data
[3];
187 mwmhints
->unknown
= data
[4];
194 void wMWMCheckClientHints(WWindow
*wwin
)
198 if (getMWMHints(wwin
->client_win
, &hints
))
199 setupMWMHints(wwin
, &hints
);