Added option to 'configure' to control debug information for compilation
[wmaker-crm.git] / src / motif.c
blob9db9db87167085b5ca8774f38cc079081025b8ff
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.
22 #include "wconfig.h"
24 #ifdef MWM_HINTS
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
32 #include "WindowMaker.h"
33 #include "framewin.h"
34 #include "window.h"
35 #include "properties.h"
36 #include "icon.h"
37 #include "client.h"
38 #include "funcs.h"
39 #include "motif.h"
41 /* Motif window hints */
42 #define MWM_HINTS_FUNCTIONS (1L << 0)
43 #define MWM_HINTS_DECORATIONS (1L << 1)
45 /* bit definitions for MwmHints.functions */
46 #define MWM_FUNC_ALL (1L << 0)
47 #define MWM_FUNC_RESIZE (1L << 1)
48 #define MWM_FUNC_MOVE (1L << 2)
49 #define MWM_FUNC_MINIMIZE (1L << 3)
50 #define MWM_FUNC_MAXIMIZE (1L << 4)
51 #define MWM_FUNC_CLOSE (1L << 5)
53 /* bit definitions for MwmHints.decorations */
54 #define MWM_DECOR_ALL (1L << 0)
55 #define MWM_DECOR_BORDER (1L << 1)
56 #define MWM_DECOR_RESIZEH (1L << 2)
57 #define MWM_DECOR_TITLE (1L << 3)
58 #define MWM_DECOR_MENU (1L << 4)
59 #define MWM_DECOR_MINIMIZE (1L << 5)
60 #define MWM_DECOR_MAXIMIZE (1L << 6)
62 /* Motif window hints */
63 typedef struct {
64 long flags;
65 long functions;
66 long decorations;
67 long inputMode;
68 long unknown;
69 } MWMHints;
71 static Atom _XA_MOTIF_WM_HINTS;
73 static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints)
76 * We will ignore all decoration hints that have an equivalent as
77 * functions, because wmaker does not distinguish decoration hints
80 if (mwm_hints->flags & MWM_HINTS_DECORATIONS) {
81 WSETUFLAG(wwin, no_titlebar, 1);
82 WSETUFLAG(wwin, no_close_button, 1);
83 WSETUFLAG(wwin, no_miniaturize_button, 1);
84 WSETUFLAG(wwin, no_resizebar, 1);
86 if (mwm_hints->decorations & MWM_DECOR_ALL) {
87 WSETUFLAG(wwin, no_titlebar, 0);
88 WSETUFLAG(wwin, no_close_button, 0);
89 WSETUFLAG(wwin, no_closable, 0);
90 WSETUFLAG(wwin, no_miniaturize_button, 0);
91 WSETUFLAG(wwin, no_miniaturizable, 0);
92 WSETUFLAG(wwin, no_resizebar, 0);
93 WSETUFLAG(wwin, no_resizable, 0);
96 if (mwm_hints->decorations & MWM_DECOR_RESIZEH)
97 WSETUFLAG(wwin, no_resizebar, 0);
99 if (mwm_hints->decorations & MWM_DECOR_TITLE) {
100 WSETUFLAG(wwin, no_titlebar, 0);
101 WSETUFLAG(wwin, no_close_button, 0);
102 WSETUFLAG(wwin, no_closable, 0);
105 if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) {
106 WSETUFLAG(wwin, no_miniaturize_button, 0);
107 WSETUFLAG(wwin, no_miniaturizable, 0);
111 if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) {
112 WSETUFLAG(wwin, no_closable, 1);
113 WSETUFLAG(wwin, no_miniaturizable, 1);
114 WSETUFLAG(wwin, no_resizable, 1);
116 if (mwm_hints->functions & MWM_FUNC_ALL) {
117 WSETUFLAG(wwin, no_closable, 0);
118 WSETUFLAG(wwin, no_miniaturizable, 0);
119 WSETUFLAG(wwin, no_resizable, 0);
121 if (mwm_hints->functions & MWM_FUNC_RESIZE)
122 WSETUFLAG(wwin, no_resizable, 0);
124 if (mwm_hints->functions & MWM_FUNC_MINIMIZE)
125 WSETUFLAG(wwin, no_miniaturizable, 0);
127 if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) {
128 /* a window must be resizable to be maximizable */
129 WSETUFLAG(wwin, no_resizable, 0);
131 if (mwm_hints->functions & MWM_FUNC_CLOSE)
132 WSETUFLAG(wwin, no_closable, 0);
136 static int getMWMHints(Window window, MWMHints *mwmhints)
138 unsigned long *data;
139 int count;
141 if (!_XA_MOTIF_WM_HINTS)
142 _XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
144 data = (unsigned long *)PropGetCheckProperty(window, _XA_MOTIF_WM_HINTS,
145 _XA_MOTIF_WM_HINTS, 32, 0, &count);
147 if (!data)
148 return 0;
150 mwmhints->flags = 0;
151 if (count >= 4) {
152 mwmhints->flags = data[0];
153 mwmhints->functions = data[1];
154 mwmhints->decorations = data[2];
155 mwmhints->inputMode = data[3];
156 if (count > 5)
157 mwmhints->unknown = data[4];
159 XFree(data);
161 return 1;
164 void wMWMCheckClientHints(WWindow *wwin)
166 MWMHints hints;
168 if (getMWMHints(wwin->client_win, &hints))
169 setupMWMHints(wwin, &hints);
172 #endif /* MWM_HINTS */