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 4
72 /* Motif window hints */
80 static Atom _XA_MOTIF_WM_HINTS
;
85 setupMWMHints(WWindow
*wwin
, MWMHints
*mwm_hints
)
88 * We will ignore all decoration hints that have an equivalent as
89 * functions, because wmaker does not distinguish decoration hints
92 if (mwm_hints
->flags
& MWM_HINTS_DECORATIONS
) {
94 fprintf(stderr
,"has decor hints [ ");
96 WSETUFLAG(wwin
, no_titlebar
, 1);
97 WSETUFLAG(wwin
, no_close_button
, 1);
98 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
99 WSETUFLAG(wwin
, no_resizebar
, 1);
101 if (mwm_hints
->decorations
& MWM_DECOR_ALL
) {
103 fprintf(stderr
,"ALL ");
105 WSETUFLAG(wwin
, no_titlebar
, 0);
106 WSETUFLAG(wwin
, no_close_button
, 0);
107 WSETUFLAG(wwin
, no_closable
, 0);
108 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
109 WSETUFLAG(wwin
, no_miniaturizable
, 0);
110 WSETUFLAG(wwin
, no_resizebar
, 0);
111 WSETUFLAG(wwin
, no_resizable
, 0);
114 if (mwm_hints->decorations & MWM_DECOR_BORDER) {
116 fprintf(stderr,"(BORDER) ");
121 if (mwm_hints
->decorations
& MWM_DECOR_RESIZEH
) {
123 fprintf(stderr
,"RESIZEH ");
125 WSETUFLAG(wwin
, no_resizebar
, 0);
128 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
130 fprintf(stderr
,"TITLE+close ");
132 WSETUFLAG(wwin
, no_titlebar
, 0);
133 WSETUFLAG(wwin
, no_close_button
, 0);
134 WSETUFLAG(wwin
, no_closable
, 0);
137 if (mwm_hints->decorations & MWM_DECOR_MENU) {
139 fprintf(stderr,"(MENU) ");
144 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
146 fprintf(stderr
,"MINIMIZE ");
148 WSETUFLAG(wwin
, no_miniaturize_button
, 0);
149 WSETUFLAG(wwin
, no_miniaturizable
, 0);
152 if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
154 fprintf(stderr,"(MAXIMIZE) ");
159 fprintf(stderr
,"]\n");
164 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
166 fprintf(stderr
,"has function hints [ ");
168 WSETUFLAG(wwin
, no_closable
, 1);
169 WSETUFLAG(wwin
, no_miniaturizable
, 1);
170 WSETUFLAG(wwin
, no_resizable
, 1);
172 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
174 fprintf(stderr
,"ALL ");
176 WSETUFLAG(wwin
, no_closable
, 0);
177 WSETUFLAG(wwin
, no_miniaturizable
, 0);
178 WSETUFLAG(wwin
, no_resizable
, 0);
180 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
) {
182 fprintf(stderr
,"RESIZE ");
184 WSETUFLAG(wwin
, no_resizable
, 0);
187 if (mwm_hints->functions & MWM_FUNC_MOVE) {
189 fprintf(stderr,"(MOVE) ");
193 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
) {
195 fprintf(stderr
,"MINIMIZE ");
197 WSETUFLAG(wwin
, no_miniaturizable
, 0);
199 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
201 fprintf(stderr
,"MAXIMIZE ");
202 /* a window must be resizable to be maximizable */
203 WSETUFLAG(wwin
, no_resizable
, 0);
206 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
) {
208 fprintf(stderr
,"CLOSE ");
210 WSETUFLAG(wwin
, no_closable
, 0);
213 fprintf(stderr
,"]\n");
220 getMWMHints(Window window
, MWMHints
*mwmhints
)
224 if (!_XA_MOTIF_WM_HINTS
) {
225 _XA_MOTIF_WM_HINTS
= XInternAtom(dpy
, "_MOTIF_WM_HINTS", False
);
228 data
= (unsigned long*)PropGetCheckProperty(window
, _XA_MOTIF_WM_HINTS
,
229 _XA_MOTIF_WM_HINTS
, 32,
230 PROP_MWM_HINTS_ELEMENTS
, NULL
);
235 mwmhints
->flags
= data
[0];
236 mwmhints
->functions
= data
[1];
237 mwmhints
->decorations
= data
[2];
238 mwmhints
->inputMode
= data
[3];
247 wMWMCheckClientHints(WWindow
*wwin
)
251 if (getMWMHints(wwin
->client_win
, &hints
)) {
252 setupMWMHints(wwin
, &hints
);
258 #endif /* MWM_HINTS */