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.
27 #include <X11/Xutil.h>
32 #include "WindowMaker.h"
35 #include "properties.h"
40 /* Motif window hints */
41 #define MWM_HINTS_FUNCTIONS (1L << 0)
42 #define MWM_HINTS_DECORATIONS (1L << 1)
44 /* bit definitions for MwmHints.functions */
45 #define MWM_FUNC_ALL (1L << 0)
46 #define MWM_FUNC_RESIZE (1L << 1)
47 #define MWM_FUNC_MOVE (1L << 2)
48 #define MWM_FUNC_MINIMIZE (1L << 3)
49 #define MWM_FUNC_MAXIMIZE (1L << 4)
50 #define MWM_FUNC_CLOSE (1L << 5)
52 /* bit definitions for MwmHints.decorations */
53 #define MWM_DECOR_ALL (1L << 0)
54 #define MWM_DECOR_BORDER (1L << 1)
55 #define MWM_DECOR_RESIZEH (1L << 2)
56 #define MWM_DECOR_TITLE (1L << 3)
57 #define MWM_DECOR_MENU (1L << 4)
58 #define MWM_DECOR_MINIMIZE (1L << 5)
59 #define MWM_DECOR_MAXIMIZE (1L << 6)
61 /* Motif window hints */
70 static Atom _XA_MOTIF_WM_HINTS
;
72 static void setupMWMHints(WWindow
*wwin
, MWMHints
*mwm_hints
)
75 * We will ignore all decoration hints that have an equivalent as
76 * functions, because wmaker does not distinguish decoration hints
79 if (mwm_hints
->flags
& MWM_HINTS_DECORATIONS
) {
80 WSETUFLAG(wwin
, no_titlebar
, 1);
81 WSETUFLAG(wwin
, no_close_button
, 1);
82 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
83 WSETUFLAG(wwin
, no_resizebar
, 1);
85 if (mwm_hints
->decorations
& MWM_DECOR_ALL
) {
86 WSETUFLAG(wwin
, no_titlebar
, 0);
87 WSETUFLAG(wwin
, no_close_button
, 0);
88 WSETUFLAG(wwin
, no_closable
, 0);
89 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
90 WSETUFLAG(wwin
, no_miniaturizable
, 0);
91 WSETUFLAG(wwin
, no_resizebar
, 0);
92 WSETUFLAG(wwin
, no_resizable
, 0);
95 if (mwm_hints
->decorations
& MWM_DECOR_BORDER
) {
97 * WindowMaker is drawing only a discreet 1 pixel border without
98 * any decoration like a few other X window managers used to do, so
99 * we assume it is not worth spending the time to add extra
100 * complexity to handle this special request, considering also that
101 * the Motif toolkit is not used anymore nowadays.
105 if (mwm_hints
->decorations
& MWM_DECOR_RESIZEH
)
106 WSETUFLAG(wwin
, no_resizebar
, 0);
108 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
109 WSETUFLAG(wwin
, no_titlebar
, 0);
110 WSETUFLAG(wwin
, no_close_button
, 0);
111 WSETUFLAG(wwin
, no_closable
, 0);
114 if (mwm_hints
->decorations
* MWM_DECOR_MENU
) {
116 * WindowMaker does not include a button to display the menu
117 * for windows, this is done using right mouse button on the
118 * title bar. As a consequence, we ignore this flag because we
119 * have nothing to hide.
123 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
124 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
125 WSETUFLAG(wwin
, no_miniaturizable
, 0);
128 if (mwm_hints
->decorations
& MWM_DECOR_MAXIMIZE
) {
130 * WindowMaker does not display a button to maximize windows,
131 * so we don't need to hide anything more for that flag
136 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
137 WSETUFLAG(wwin
, no_closable
, 1);
138 WSETUFLAG(wwin
, no_miniaturizable
, 1);
139 WSETUFLAG(wwin
, no_resizable
, 1);
141 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
142 WSETUFLAG(wwin
, no_closable
, 0);
143 WSETUFLAG(wwin
, no_miniaturizable
, 0);
144 WSETUFLAG(wwin
, no_resizable
, 0);
146 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
)
147 WSETUFLAG(wwin
, no_resizable
, 0);
149 if (mwm_hints
->functions
& MWM_FUNC_MOVE
) {
151 * WindowMaker does not allow a window to not be moved, and this
152 * is a good thing, so we explicitly ignore this flag.
156 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
)
157 WSETUFLAG(wwin
, no_miniaturizable
, 0);
159 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
160 /* a window must be resizable to be maximizable */
161 WSETUFLAG(wwin
, no_resizable
, 0);
163 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
)
164 WSETUFLAG(wwin
, no_closable
, 0);
168 static int getMWMHints(Window window
, MWMHints
*mwmhints
)
173 if (!_XA_MOTIF_WM_HINTS
)
174 _XA_MOTIF_WM_HINTS
= XInternAtom(dpy
, "_MOTIF_WM_HINTS", False
);
176 data
= (unsigned long *)PropGetCheckProperty(window
, _XA_MOTIF_WM_HINTS
,
177 _XA_MOTIF_WM_HINTS
, 32, 0, &count
);
184 mwmhints
->flags
= data
[0];
185 mwmhints
->functions
= data
[1];
186 mwmhints
->decorations
= data
[2];
187 mwmhints
->inputMode
= data
[3];
189 mwmhints
->unknown
= data
[4];
196 void wMWMCheckClientHints(WWindow
*wwin
)
200 if (getMWMHints(wwin
->client_win
, &hints
))
201 setupMWMHints(wwin
, &hints
);
204 #endif /* MWM_HINTS */