2 * openlook.c - OPEN LOOK (tm) compatibility stuff
4 * Window Maker window manager
6 * Copyright (c) 1998, 1999 Alfredo K. Kojima
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 * Semantics and hint information taken from olwm code
34 #include <X11/Xutil.h>
35 #include <X11/Xatom.h>
42 #include "WindowMaker.h"
47 #include "properties.h"
60 #define OL_DECORATION_HEADER (1<<0)
61 #define OL_DECORATION_FOOTER (1<<1)
62 #define OL_DECORATION_PUSHPIN (1<<2)
63 #define OL_DECORATION_CLOSEBUTTON (1<<3)
64 #define OL_DECORATION_RESIZEABLE (1<<4)
65 #define OL_DECORATION_ICONNAME (1<<5)
66 #define OL_DECORATION_WARPTOPIN (1<<6)
67 #define OL_DECORATION_NONE (1<<7)
79 #define OL_WINTYPE (1<<0)
80 #define OL_MENUTYPE (1<<1)
81 #define OL_PINSTATE (1<<2)
82 #define OL_CANCEL (1<<3)
91 unsigned semantic_compose
:1;
92 unsigned semantic_capslock
:1;
93 unsigned semantic_numlock
:1;
94 unsigned semantic_scrolllock
:1;
98 static Atom _XA_SUN_WM_PROTOCOLS
= 0;
102 getWindowState(Window win
, OLWindowState
*state
)
104 static Atom _XA_SUN_WINDOW_STATE
= 0;
107 if (!_XA_SUN_WINDOW_STATE
) {
108 _XA_SUN_WINDOW_STATE
= XInternAtom(dpy
, "_SUN_WINDOW_STATE", False
);
111 data
= (unsigned long*)PropGetCheckProperty(win
, _XA_SUN_WINDOW_STATE
,
112 XA_INTEGER
, 32, 2, NULL
);
118 state
->flags
= data
[0];
119 state
->state
= data
[1];
128 getWindowHints(Window window
, OLHints
*hints
)
132 static Atom _XA_OL_WIN_ATTR
= 0;
134 if (!_XA_OL_WIN_ATTR
) {
135 _XA_OL_WIN_ATTR
= XInternAtom(dpy
, "_OL_WIN_ATTR", False
);
138 data
= (long*)PropGetCheckProperty(window
, _XA_OL_WIN_ATTR
,
139 _XA_OL_WIN_ATTR
, 32, 0, &count
);
147 hints
->flags
= OL_WINTYPE
|OL_MENUTYPE
|OL_PINSTATE
;
148 hints
->winType
= data
[0];
149 hints
->menuType
= data
[1];
150 hints
->pinInitState
= data
[2];
153 } else if (count
== 5) {
156 hints
->flags
= data
[0];
157 hints
->winType
= data
[1];
158 hints
->menuType
= data
[2];
159 hints
->pinInitState
= data
[3];
160 hints
->cancel
= data
[4];
167 printf("WINDOW TYPE %s\n", XGetAtomName(dpy
, hints
->winType
));
171 /* do backward compatibility stuff */
172 if (hints
->flags
& OL_PINSTATE
) {
173 static Atom pinIn
= 0, pinOut
;
176 pinIn
= XInternAtom(dpy
, "_OL_PIN_IN", False
);
177 pinOut
= XInternAtom(dpy
, "_OL_PIN_OUT", False
);
180 if (hints
->pinInitState
== pinIn
)
181 hints
->pinInitState
= OL_PIN_IN
;
182 else if (hints
->pinInitState
== pinOut
)
183 hints
->pinInitState
= OL_PIN_OUT
;
193 applyDecorationHints(Window win
, int *flags
)
196 static Atom _XA_OL_DECOR_ADD
= 0;
197 static Atom _XA_OL_DECOR_DEL
= 0;
198 static Atom _XA_CLOSE
, _XA_FOOTER
, _XA_RESIZE
, _XA_HEADER
, _XA_PIN
,
203 if (!_XA_OL_DECOR_DEL
) {
204 _XA_OL_DECOR_ADD
= XInternAtom(dpy
, "_OL_DECOR_ADD", False
);
205 _XA_OL_DECOR_DEL
= XInternAtom(dpy
, "_OL_DECOR_DEL", False
);
207 _XA_CLOSE
= XInternAtom(dpy
, "_OL_DECOR_CLOSE", False
);
208 _XA_FOOTER
= XInternAtom(dpy
, "_OL_DECOR_FOOTER", False
);
209 _XA_RESIZE
= XInternAtom(dpy
, "_OL_DECOR_RESIZE", False
);
210 _XA_HEADER
= XInternAtom(dpy
, "_OL_DECOR_HEADER", False
);
211 _XA_PIN
= XInternAtom(dpy
, "_OL_DECOR_PIN", False
);
212 _XA_ICONNAME
= XInternAtom(dpy
, "_OL_DECOR_ICON_NAME", False
);
215 atoms
= (Atom
*)PropGetCheckProperty(win
, _XA_OL_DECOR_ADD
, XA_ATOM
, 32, 0,
218 for (i
=0; i
< count
; i
++) {
219 if (atoms
[i
] == _XA_CLOSE
)
220 *flags
|= OL_DECORATION_CLOSEBUTTON
;
221 else if (atoms
[i
] == _XA_FOOTER
)
222 *flags
|= OL_DECORATION_FOOTER
;
223 else if (atoms
[i
] == _XA_RESIZE
)
224 *flags
|= OL_DECORATION_RESIZEABLE
;
225 else if (atoms
[i
] == _XA_HEADER
)
226 *flags
|= OL_DECORATION_HEADER
;
227 else if (atoms
[i
] == _XA_PIN
)
228 *flags
|= OL_DECORATION_PUSHPIN
;
229 else if (atoms
[i
] == _XA_ICONNAME
)
230 *flags
|= OL_DECORATION_ICONNAME
;
235 atoms
= (Atom
*)PropGetCheckProperty(win
, _XA_OL_DECOR_DEL
, XA_ATOM
, 32, 0,
238 for (i
=0; i
< count
; i
++) {
239 if (atoms
[i
] == _XA_CLOSE
)
240 *flags
&= ~OL_DECORATION_CLOSEBUTTON
;
241 else if (atoms
[i
] == _XA_FOOTER
)
242 *flags
&= ~OL_DECORATION_FOOTER
;
243 else if (atoms
[i
] == _XA_RESIZE
)
244 *flags
&= ~OL_DECORATION_RESIZEABLE
;
245 else if (atoms
[i
] == _XA_HEADER
)
246 *flags
&= ~OL_DECORATION_HEADER
;
247 else if (atoms
[i
] == _XA_PIN
)
248 *flags
&= ~OL_DECORATION_PUSHPIN
;
249 else if (atoms
[i
] == _XA_ICONNAME
)
250 *flags
&= ~OL_DECORATION_ICONNAME
;
258 wOLWMInitStuff(WScreen
*scr
)
260 static Atom _SUN_OL_WIN_ATTR_5
;
262 if (!_XA_SUN_WM_PROTOCOLS
) {
263 _XA_SUN_WM_PROTOCOLS
= XInternAtom(dpy
, "_SUN_WM_PROTOCOLS", False
);
264 _SUN_OL_WIN_ATTR_5
= XInternAtom(dpy
, "_SUN_OL_WIN_ATTR_5", False
);
267 XChangeProperty(dpy
, scr
->root_win
, _XA_SUN_WM_PROTOCOLS
, XA_ATOM
, 32,
268 PropModeReplace
, (unsigned char*)&_SUN_OL_WIN_ATTR_5
, 1);
273 wOLWMChangePushpinState(WWindow
*wwin
, Bool state
)
275 static Atom pinState
= 0;
278 pinState
= XInternAtom(dpy
, "_OL_PIN_STATE", False
);
281 XChangeProperty(dpy
, wwin
->client_win
, pinState
, XA_INTEGER
, 32,
282 PropModeReplace
, (unsigned char *)&state
, 1);
287 wOLWMShutdown(WScreen
*scr
)
289 XDeleteProperty(dpy
, scr
->root_win
, _XA_SUN_WM_PROTOCOLS
);
295 wOLWMUpdateWindowState(WWindow
*wwin
)
297 if (wwin
->ol_window_state
.used
) {
298 if (wwin
->ol_window_state
.semantic
) {
299 if (wwin
->ol_window_state
.semantic_compose
)
302 setComposeLed(False
);
305 setComposeLed(False
);
308 #endif /* unfinished */
311 wOLWMCheckClientHints(WWindow
*wwin
)
314 static Atom WT_BASE
= 0, WT_CMD
, WT_NOTICE
, WT_HELP
, WT_OTHER
;
315 static Atom MT_FULL
, MT_LIMITED
, MT_NONE
;
317 int pinInitState
= OL_PIN_IN
;
321 WT_BASE
= XInternAtom(dpy
, "_OL_WT_BASE", False
);
322 WT_CMD
= XInternAtom(dpy
, "_OL_WT_CMD", False
);
323 WT_NOTICE
= XInternAtom(dpy
, "_OL_WT_NOTICE", False
);
324 WT_HELP
= XInternAtom(dpy
, "_OL_WT_HELP", False
);
325 WT_OTHER
= XInternAtom(dpy
, "_OL_WT_OTHER", False
);
327 MT_FULL
= XInternAtom(dpy
, "_OL_MENU_FULL", False
);
328 MT_LIMITED
= XInternAtom(dpy
, "_OL_MENU_LIMITED", False
);
329 MT_NONE
= XInternAtom(dpy
, "_OL_NONE", False
);
334 if (!getWindowHints(wwin
->client_win
, &hints
) ||
335 !(hints
.flags
& OL_WINTYPE
)) {
337 decoration
= OL_DECORATION_CLOSEBUTTON
|OL_DECORATION_RESIZEABLE
338 |OL_DECORATION_HEADER
|OL_DECORATION_ICONNAME
;
343 if (hints
.winType
== WT_BASE
) {
345 decoration
= OL_DECORATION_CLOSEBUTTON
|OL_DECORATION_RESIZEABLE
346 |OL_DECORATION_HEADER
|OL_DECORATION_ICONNAME
;
350 } else if (hints
.winType
== WT_CMD
) {
352 decoration
= OL_DECORATION_PUSHPIN
|OL_DECORATION_RESIZEABLE
353 |OL_DECORATION_HEADER
|OL_DECORATION_ICONNAME
;
355 menuType
= MT_LIMITED
;
357 } else if (hints
.winType
== WT_NOTICE
) {
359 decoration
= OL_DECORATION_ICONNAME
;
362 } else if (hints
.winType
== WT_HELP
) {
364 decoration
= OL_DECORATION_PUSHPIN
|OL_DECORATION_HEADER
365 |OL_DECORATION_ICONNAME
|OL_DECORATION_WARPTOPIN
;
366 menuType
= MT_LIMITED
;
368 } else if (hints
.winType
== WT_OTHER
) {
370 decoration
= OL_DECORATION_ICONNAME
;
373 if (hints
.flags
& OL_MENUTYPE
) {
374 menuType
= hints
.menuType
;
378 if (hints
.flags
& OL_PINSTATE
) {
379 pinInitState
= hints
.pinInitState
;
381 pinInitState
= OL_PIN_OUT
;
385 /* mask attributes with decoration hints */
386 applyDecorationHints(wwin
->client_win
, &decoration
);
388 if ((decoration
& OL_DECORATION_CLOSEBUTTON
)
389 && (decoration
& OL_DECORATION_PUSHPIN
))
390 decoration
&= ~OL_DECORATION_CLOSEBUTTON
;
392 if (!(decoration
& OL_DECORATION_PUSHPIN
))
393 decoration
&= ~OL_DECORATION_WARPTOPIN
;
396 /* map the hints to our attributes */
397 if (menuType
== MT_FULL
)
398 wwin
->flags
.olwm_limit_menu
= 0;
400 wwin
->flags
.olwm_limit_menu
= 1;
402 /* this is a transient-like window */
403 if (hints
.winType
== WT_CMD
) {
404 wwin
->client_flags
.olwm_transient
= 1;
408 * Emulate olwm pushpin.
409 * If the initial state of the pin is in, then put the normal close
410 * button. If not, make the close button different and when the
411 * user moves the window or clicks in the close button, turn it
412 * into a normal close button.
414 if ((decoration
& OL_DECORATION_PUSHPIN
) && pinInitState
==OL_PIN_OUT
) {
415 wwin
->flags
.olwm_push_pin_out
= 1;
417 wOLWMChangePushpinState(wwin
, False
);
419 wOLWMChangePushpinState(wwin
, True
);
422 if (!(decoration
& OL_DECORATION_RESIZEABLE
)) {
423 wwin
->client_flags
.no_resizable
= 1;
424 wwin
->client_flags
.no_resizebar
= 1;
427 if (decoration
& OL_DECORATION_WARPTOPIN
) {
428 wwin
->client_flags
.olwm_warp_to_pin
= 1;