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_RESIZEH
)
96 WSETUFLAG(wwin
, no_resizebar
, 0);
98 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
99 WSETUFLAG(wwin
, no_titlebar
, 0);
100 WSETUFLAG(wwin
, no_close_button
, 0);
101 WSETUFLAG(wwin
, no_closable
, 0);
104 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
105 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
106 WSETUFLAG(wwin
, no_miniaturizable
, 0);
110 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
111 WSETUFLAG(wwin
, no_closable
, 1);
112 WSETUFLAG(wwin
, no_miniaturizable
, 1);
113 WSETUFLAG(wwin
, no_resizable
, 1);
115 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
116 WSETUFLAG(wwin
, no_closable
, 0);
117 WSETUFLAG(wwin
, no_miniaturizable
, 0);
118 WSETUFLAG(wwin
, no_resizable
, 0);
120 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
)
121 WSETUFLAG(wwin
, no_resizable
, 0);
123 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
)
124 WSETUFLAG(wwin
, no_miniaturizable
, 0);
126 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
127 /* a window must be resizable to be maximizable */
128 WSETUFLAG(wwin
, no_resizable
, 0);
130 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
)
131 WSETUFLAG(wwin
, no_closable
, 0);
135 static int getMWMHints(Window window
, MWMHints
*mwmhints
)
140 if (!_XA_MOTIF_WM_HINTS
)
141 _XA_MOTIF_WM_HINTS
= XInternAtom(dpy
, "_MOTIF_WM_HINTS", False
);
143 data
= (unsigned long *)PropGetCheckProperty(window
, _XA_MOTIF_WM_HINTS
,
144 _XA_MOTIF_WM_HINTS
, 32, 0, &count
);
151 mwmhints
->flags
= data
[0];
152 mwmhints
->functions
= data
[1];
153 mwmhints
->decorations
= data
[2];
154 mwmhints
->inputMode
= data
[3];
156 mwmhints
->unknown
= data
[4];
163 void wMWMCheckClientHints(WWindow
*wwin
)
167 if (getMWMHints(wwin
->client_win
, &hints
))
168 setupMWMHints(wwin
, &hints
);
171 #endif /* MWM_HINTS */