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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #include <X11/Xutil.h>
34 #include "WindowMaker.h"
38 #include "properties.h"
45 /* Motif window hints */
46 #define MWM_HINTS_FUNCTIONS (1L << 0)
47 #define MWM_HINTS_DECORATIONS (1L << 1)
49 /* bit definitions for MwmHints.functions */
50 #define MWM_FUNC_ALL (1L << 0)
51 #define MWM_FUNC_RESIZE (1L << 1)
52 #define MWM_FUNC_MOVE (1L << 2)
53 #define MWM_FUNC_MINIMIZE (1L << 3)
54 #define MWM_FUNC_MAXIMIZE (1L << 4)
55 #define MWM_FUNC_CLOSE (1L << 5)
57 /* bit definitions for MwmHints.decorations */
58 #define MWM_DECOR_ALL (1L << 0)
59 #define MWM_DECOR_BORDER (1L << 1)
60 #define MWM_DECOR_RESIZEH (1L << 2)
61 #define MWM_DECOR_TITLE (1L << 3)
62 #define MWM_DECOR_MENU (1L << 4)
63 #define MWM_DECOR_MINIMIZE (1L << 5)
64 #define MWM_DECOR_MAXIMIZE (1L << 6)
66 #define PROP_MWM_HINTS_ELEMENTS 5
68 /* Motif window hints */
77 static Atom _XA_MOTIF_WM_HINTS
;
79 static void setupMWMHints(WWindow
* wwin
, MWMHints
* mwm_hints
)
82 * We will ignore all decoration hints that have an equivalent as
83 * functions, because wmaker does not distinguish decoration hints
86 if (mwm_hints
->flags
& MWM_HINTS_DECORATIONS
) {
88 fprintf(stderr
, "has decor hints [ ");
90 WSETUFLAG(wwin
, no_titlebar
, 1);
91 WSETUFLAG(wwin
, no_close_button
, 1);
92 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
93 WSETUFLAG(wwin
, no_resizebar
, 1);
95 if (mwm_hints
->decorations
& MWM_DECOR_ALL
) {
97 fprintf(stderr
, "ALL ");
99 WSETUFLAG(wwin
, no_titlebar
, 0);
100 WSETUFLAG(wwin
, no_close_button
, 0);
101 WSETUFLAG(wwin
, no_closable
, 0);
102 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
103 WSETUFLAG(wwin
, no_miniaturizable
, 0);
104 WSETUFLAG(wwin
, no_resizebar
, 0);
105 WSETUFLAG(wwin
, no_resizable
, 0);
108 if (mwm_hints->decorations & MWM_DECOR_BORDER) {
110 fprintf(stderr,"(BORDER) ");
115 if (mwm_hints
->decorations
& MWM_DECOR_RESIZEH
) {
117 fprintf(stderr
, "RESIZEH ");
119 WSETUFLAG(wwin
, no_resizebar
, 0);
122 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
124 fprintf(stderr
, "TITLE+close ");
126 WSETUFLAG(wwin
, no_titlebar
, 0);
127 WSETUFLAG(wwin
, no_close_button
, 0);
128 WSETUFLAG(wwin
, no_closable
, 0);
131 if (mwm_hints->decorations & MWM_DECOR_MENU) {
133 fprintf(stderr,"(MENU) ");
138 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
140 fprintf(stderr
, "MINIMIZE ");
142 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
143 WSETUFLAG(wwin
, no_miniaturizable
, 0);
146 if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
148 fprintf(stderr,"(MAXIMIZE) ");
153 fprintf(stderr
, "]\n");
157 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
159 fprintf(stderr
, "has function hints [ ");
161 WSETUFLAG(wwin
, no_closable
, 1);
162 WSETUFLAG(wwin
, no_miniaturizable
, 1);
163 WSETUFLAG(wwin
, no_resizable
, 1);
165 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
167 fprintf(stderr
, "ALL ");
169 WSETUFLAG(wwin
, no_closable
, 0);
170 WSETUFLAG(wwin
, no_miniaturizable
, 0);
171 WSETUFLAG(wwin
, no_resizable
, 0);
173 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
) {
175 fprintf(stderr
, "RESIZE ");
177 WSETUFLAG(wwin
, no_resizable
, 0);
180 if (mwm_hints->functions & MWM_FUNC_MOVE) {
182 fprintf(stderr,"(MOVE) ");
186 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
) {
188 fprintf(stderr
, "MINIMIZE ");
190 WSETUFLAG(wwin
, no_miniaturizable
, 0);
192 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
194 fprintf(stderr
, "MAXIMIZE ");
195 /* a window must be resizable to be maximizable */
196 WSETUFLAG(wwin
, no_resizable
, 0);
199 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
) {
201 fprintf(stderr
, "CLOSE ");
203 WSETUFLAG(wwin
, no_closable
, 0);
206 fprintf(stderr
, "]\n");
211 static int getMWMHints(Window window
, MWMHints
* mwmhints
)
216 if (!_XA_MOTIF_WM_HINTS
) {
217 _XA_MOTIF_WM_HINTS
= XInternAtom(dpy
, "_MOTIF_WM_HINTS", False
);
220 data
= (unsigned long *)PropGetCheckProperty(window
, _XA_MOTIF_WM_HINTS
,
221 _XA_MOTIF_WM_HINTS
, 32, 0, &count
);
227 mwmhints
->flags
= data
[0];
228 mwmhints
->functions
= data
[1];
229 mwmhints
->decorations
= data
[2];
230 mwmhints
->inputMode
= data
[3];
232 mwmhints
->unknown
= data
[4];
239 void wMWMCheckClientHints(WWindow
* wwin
)
243 if (getMWMHints(wwin
->client_win
, &hints
)) {
244 setupMWMHints(wwin
, &hints
);
248 #endif /* MWM_HINTS */