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"
39 #include "properties.h"
46 /* Motif window hints */
47 #define MWM_HINTS_FUNCTIONS (1L << 0)
48 #define MWM_HINTS_DECORATIONS (1L << 1)
50 /* bit definitions for MwmHints.functions */
51 #define MWM_FUNC_ALL (1L << 0)
52 #define MWM_FUNC_RESIZE (1L << 1)
53 #define MWM_FUNC_MOVE (1L << 2)
54 #define MWM_FUNC_MINIMIZE (1L << 3)
55 #define MWM_FUNC_MAXIMIZE (1L << 4)
56 #define MWM_FUNC_CLOSE (1L << 5)
58 /* bit definitions for MwmHints.decorations */
59 #define MWM_DECOR_ALL (1L << 0)
60 #define MWM_DECOR_BORDER (1L << 1)
61 #define MWM_DECOR_RESIZEH (1L << 2)
62 #define MWM_DECOR_TITLE (1L << 3)
63 #define MWM_DECOR_MENU (1L << 4)
64 #define MWM_DECOR_MINIMIZE (1L << 5)
65 #define MWM_DECOR_MAXIMIZE (1L << 6)
67 #define PROP_MWM_HINTS_ELEMENTS 5
69 /* Motif window hints */
78 static Atom _XA_MOTIF_WM_HINTS;
80 static void setupMWMHints(WWindow * wwin, MWMHints * mwm_hints)
83 * We will ignore all decoration hints that have an equivalent as
84 * functions, because wmaker does not distinguish decoration hints
87 if (mwm_hints->flags & MWM_HINTS_DECORATIONS) {
89 fprintf(stderr, "has decor hints [ ");
91 WSETUFLAG(wwin, no_titlebar, 1);
92 WSETUFLAG(wwin, no_close_button, 1);
93 WSETUFLAG(wwin, no_miniaturize_button, 1);
94 WSETUFLAG(wwin, no_resizebar, 1);
96 if (mwm_hints->decorations & MWM_DECOR_ALL) {
98 fprintf(stderr, "ALL ");
100 WSETUFLAG(wwin, no_titlebar, 0);
101 WSETUFLAG(wwin, no_close_button, 0);
102 WSETUFLAG(wwin, no_closable, 0);
103 WSETUFLAG(wwin, no_miniaturize_button, 0);
104 WSETUFLAG(wwin, no_miniaturizable, 0);
105 WSETUFLAG(wwin, no_resizebar, 0);
106 WSETUFLAG(wwin, no_resizable, 0);
109 if (mwm_hints->decorations & MWM_DECOR_BORDER) {
111 fprintf(stderr,"(BORDER) ");
116 if (mwm_hints->decorations & MWM_DECOR_RESIZEH) {
118 fprintf(stderr, "RESIZEH ");
120 WSETUFLAG(wwin, no_resizebar, 0);
123 if (mwm_hints->decorations & MWM_DECOR_TITLE) {
125 fprintf(stderr, "TITLE+close ");
127 WSETUFLAG(wwin, no_titlebar, 0);
128 WSETUFLAG(wwin, no_close_button, 0);
129 WSETUFLAG(wwin, no_closable, 0);
132 if (mwm_hints->decorations & MWM_DECOR_MENU) {
134 fprintf(stderr,"(MENU) ");
139 if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) {
141 fprintf(stderr, "MINIMIZE ");
143 WSETUFLAG(wwin, no_miniaturize_button, 0);
144 WSETUFLAG(wwin, no_miniaturizable, 0);
147 if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
149 fprintf(stderr,"(MAXIMIZE) ");
154 fprintf(stderr, "]\n");
158 if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) {
160 fprintf(stderr, "has function hints [ ");
162 WSETUFLAG(wwin, no_closable, 1);
163 WSETUFLAG(wwin, no_miniaturizable, 1);
164 WSETUFLAG(wwin, no_resizable, 1);
166 if (mwm_hints->functions & MWM_FUNC_ALL) {
168 fprintf(stderr, "ALL ");
170 WSETUFLAG(wwin, no_closable, 0);
171 WSETUFLAG(wwin, no_miniaturizable, 0);
172 WSETUFLAG(wwin, no_resizable, 0);
174 if (mwm_hints->functions & MWM_FUNC_RESIZE) {
176 fprintf(stderr, "RESIZE ");
178 WSETUFLAG(wwin, no_resizable, 0);
181 if (mwm_hints->functions & MWM_FUNC_MOVE) {
183 fprintf(stderr,"(MOVE) ");
187 if (mwm_hints->functions & MWM_FUNC_MINIMIZE) {
189 fprintf(stderr, "MINIMIZE ");
191 WSETUFLAG(wwin, no_miniaturizable, 0);
193 if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) {
195 fprintf(stderr, "MAXIMIZE ");
196 /* a window must be resizable to be maximizable */
197 WSETUFLAG(wwin, no_resizable, 0);
200 if (mwm_hints->functions & MWM_FUNC_CLOSE) {
202 fprintf(stderr, "CLOSE ");
204 WSETUFLAG(wwin, no_closable, 0);
207 fprintf(stderr, "]\n");
212 static int getMWMHints(Window window, MWMHints * mwmhints)
217 if (!_XA_MOTIF_WM_HINTS) {
218 _XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
221 data = (unsigned long *)PropGetCheckProperty(window, _XA_MOTIF_WM_HINTS,
222 _XA_MOTIF_WM_HINTS, 32, 0, &count);
228 mwmhints->flags = data[0];
229 mwmhints->functions = data[1];
230 mwmhints->decorations = data[2];
231 mwmhints->inputMode = data[3];
233 mwmhints->unknown = data[4];
240 void wMWMCheckClientHints(WWindow * wwin)
244 if (getMWMHints(wwin->client_win, &hints)) {
245 setupMWMHints(wwin, &hints);
249 #endif /* MWM_HINTS */