1 /* motif.c-- stuff for support for mwm hints
3 * Window Maker window manager
5 * Copyright (c) 1998, 1999 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,
29 #include <X11/Xutil.h>
36 #include "WindowMaker.h"
41 #include "properties.h"
49 /* Motif window hints */
50 #define MWM_HINTS_FUNCTIONS (1L << 0)
51 #define MWM_HINTS_DECORATIONS (1L << 1)
53 /* bit definitions for MwmHints.functions */
54 #define MWM_FUNC_ALL (1L << 0)
55 #define MWM_FUNC_RESIZE (1L << 1)
56 #define MWM_FUNC_MOVE (1L << 2)
57 #define MWM_FUNC_MINIMIZE (1L << 3)
58 #define MWM_FUNC_MAXIMIZE (1L << 4)
59 #define MWM_FUNC_CLOSE (1L << 5)
61 /* bit definitions for MwmHints.decorations */
62 #define MWM_DECOR_ALL (1L << 0)
63 #define MWM_DECOR_BORDER (1L << 1)
64 #define MWM_DECOR_RESIZEH (1L << 2)
65 #define MWM_DECOR_TITLE (1L << 3)
66 #define MWM_DECOR_MENU (1L << 4)
67 #define MWM_DECOR_MINIMIZE (1L << 5)
68 #define MWM_DECOR_MAXIMIZE (1L << 6)
70 #define PROP_MWM_HINTS_ELEMENTS 5
72 /* Motif window hints */
81 static Atom _XA_MOTIF_WM_HINTS
;
86 setupMWMHints(WWindow
*wwin
, MWMHints
*mwm_hints
)
89 * We will ignore all decoration hints that have an equivalent as
90 * functions, because wmaker does not distinguish decoration hints
93 if (mwm_hints
->flags
& MWM_HINTS_DECORATIONS
) {
95 fprintf(stderr
,"has decor hints [ ");
97 WSETUFLAG(wwin
, no_titlebar
, 1);
98 WSETUFLAG(wwin
, no_close_button
, 1);
99 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
100 WSETUFLAG(wwin
, no_resizebar
, 1);
102 if (mwm_hints
->decorations
& MWM_DECOR_ALL
) {
104 fprintf(stderr
,"ALL ");
106 WSETUFLAG(wwin
, no_titlebar
, 0);
107 WSETUFLAG(wwin
, no_close_button
, 0);
108 WSETUFLAG(wwin
, no_closable
, 0);
109 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
110 WSETUFLAG(wwin
, no_miniaturizable
, 0);
111 WSETUFLAG(wwin
, no_resizebar
, 0);
112 WSETUFLAG(wwin
, no_resizable
, 0);
115 if (mwm_hints->decorations & MWM_DECOR_BORDER) {
117 fprintf(stderr,"(BORDER) ");
122 if (mwm_hints
->decorations
& MWM_DECOR_RESIZEH
) {
124 fprintf(stderr
,"RESIZEH ");
126 WSETUFLAG(wwin
, no_resizebar
, 0);
129 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
131 fprintf(stderr
,"TITLE+close ");
133 WSETUFLAG(wwin
, no_titlebar
, 0);
134 WSETUFLAG(wwin
, no_close_button
, 0);
135 WSETUFLAG(wwin
, no_closable
, 0);
138 if (mwm_hints->decorations & MWM_DECOR_MENU) {
140 fprintf(stderr,"(MENU) ");
145 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
147 fprintf(stderr
,"MINIMIZE ");
149 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
150 WSETUFLAG(wwin
, no_miniaturizable
, 0);
153 if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
155 fprintf(stderr,"(MAXIMIZE) ");
160 fprintf(stderr
,"]\n");
165 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
167 fprintf(stderr
,"has function hints [ ");
169 WSETUFLAG(wwin
, no_closable
, 1);
170 WSETUFLAG(wwin
, no_miniaturizable
, 1);
171 WSETUFLAG(wwin
, no_resizable
, 1);
173 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
175 fprintf(stderr
,"ALL ");
177 WSETUFLAG(wwin
, no_closable
, 0);
178 WSETUFLAG(wwin
, no_miniaturizable
, 0);
179 WSETUFLAG(wwin
, no_resizable
, 0);
181 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
) {
183 fprintf(stderr
,"RESIZE ");
185 WSETUFLAG(wwin
, no_resizable
, 0);
188 if (mwm_hints->functions & MWM_FUNC_MOVE) {
190 fprintf(stderr,"(MOVE) ");
194 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
) {
196 fprintf(stderr
,"MINIMIZE ");
198 WSETUFLAG(wwin
, no_miniaturizable
, 0);
200 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
202 fprintf(stderr
,"MAXIMIZE ");
203 /* a window must be resizable to be maximizable */
204 WSETUFLAG(wwin
, no_resizable
, 0);
207 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
) {
209 fprintf(stderr
,"CLOSE ");
211 WSETUFLAG(wwin
, no_closable
, 0);
214 fprintf(stderr
,"]\n");
221 getMWMHints(Window window
, MWMHints
*mwmhints
)
226 if (!_XA_MOTIF_WM_HINTS
) {
227 _XA_MOTIF_WM_HINTS
= XInternAtom(dpy
, "_MOTIF_WM_HINTS", False
);
230 data
= (unsigned long*)PropGetCheckProperty(window
, _XA_MOTIF_WM_HINTS
,
231 _XA_MOTIF_WM_HINTS
, 32,
238 mwmhints
->flags
= data
[0];
239 mwmhints
->functions
= data
[1];
240 mwmhints
->decorations
= data
[2];
241 mwmhints
->inputMode
= data
[3];
243 mwmhints
->unknown
= data
[4];
252 wMWMCheckClientHints(WWindow
*wwin
)
256 if (getMWMHints(wwin
->client_win
, &hints
)) {
257 setupMWMHints(wwin
, &hints
);
263 #endif /* MWM_HINTS */