1 /*
2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2014 Kim Woelders
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 #include "E.h"
25 #include "desktops.h"
26 #include "ewins.h"
27 #include "hints.h"
28 #include "xprop.h"
29 #include "xwin.h"
30
31 /* WIN_WM_NAME STRING - contains a string identifier for the WM's name */
32 #define XA_WIN_WM_NAME "_WIN_WM_NAME"
33
34 /* WIN_WM_NAME VERSION - contains a string identifier for the WM's version */
35 #define XA_WIN_WM_VERSION "_WIN_WM_VERSION"
36
37 /* WIN_AREA CARD32[2] contains the current desktop area X,Y */
38 #define XA_WIN_AREA "_WIN_AREA"
39
40 /* WIN_AREA CARD32[2] contains the current desktop area size WxH */
41 #define XA_WIN_AREA_COUNT "_WIN_AREA_COUNT"
42
43 /* array of atoms - atom being one of the following atoms */
44 #define XA_WIN_PROTOCOLS "_WIN_PROTOCOLS"
45
46 /* array of iocn in various sizes */
47 /* Type: array of CARD32 */
48 /* first item is icon count (n) */
49 /* second item is icon record length (in CARD32s) */
50 /* this is followed by (n) icon records as follows */
51 /* pixmap (XID) */
52 /* mask (XID) */
53 /* width (CARD32) */
54 /* height (CARD32) */
55 /* depth (of pixmap, mask is assumed to be of depth 1) (CARD32) */
56 /* drawable (screen root drawable of pixmap) (XID) */
57 /* ... additional fields can be added at the end of this list */
58 #define XA_WIN_ICONS "_WIN_ICONS"
59
60 /* WIN_WORKSPACE CARD32 contains the current desktop number */
61 #define XA_WIN_WORKSPACE "_WIN_WORKSPACE"
62 /* WIN_WORKSPACE_COUNT CARD32 contains the number of desktops */
63 #define XA_WIN_WORKSPACE_COUNT "_WIN_WORKSPACE_COUNT"
64
65 /* WIN_WORKSPACE_NAMES StringList (Text Property) of workspace names */
66 /* unused by enlightenment */
67 #define XA_WIN_WORKSPACE_NAMES "_WIN_WORKSPACE_NAMES"
68
69 /* ********** Don't use this.. iffy at best. *********** */
70 /* The available work area for client windows. The WM can set this and the WM */
71 /* and/or clients may change it at any time. If it is changed the WM and/or */
72 /* clients should honor the changes. If this property does not exist a client */
73 /* or WM can create it. */
74 /*
75 * CARD32 min_x;
76 * CARD32 min_y;
77 * CARD32 max_x;
78 * CARD32 max_y;
79 */
80 #define XA_WIN_WORKAREA "_WIN_WORKAREA"
81 /* array of 4 CARD32's */
82
83 /* This is a list of window id's the WM is currently managing - primarily */
84 /* for being able to have external "tasklist" apps */
85 #define XA_WIN_CLIENT_LIST "_WIN_CLIENT_LIST"
86 /* array of N XID's */
87
88 /*********************************************************/
89 /* Properties on client windows */
90 /*********************************************************/
91
92 /* The layer the window exists in */
93 /* 0 = Desktop */
94 /* 1 = Below */
95 /* 2 = Normal (default app layer) */
96 /* 4 = OnTop */
97 /* 6 = Dock (always on top - for panel) */
98 /* The app sets this alone, not the WM. If this property changes the WM */
99 /* should comply and change the appearance/behavior of the Client window */
100 /* if this hint does not exist the WM Will create it on the Client window */
101 #define WIN_LAYER_DESKTOP 0
102 #define WIN_LAYER_BELOW 2
103 #define WIN_LAYER_NORMAL 4
104 #define WIN_LAYER_ONTOP 6
105 #define WIN_LAYER_DOCK 8
106 #define WIN_LAYER_ABOVE_DOCK 10
107 #define WIN_LAYER_MENU 12
108 #define XA_WIN_LAYER "_WIN_LAYER"
109 /* WIN_LAYER = CARD32 */
110
111 /* flags for the window's state. The WM will change these as needed when */
112 /* state changes. If the property contains info on client map, E will modify */
113 /* the windows state accordingly. if the Hint does not exist the WM will */
114 /* create it on the client window. 0 for the bit means off, 1 means on. */
115 /* unused (default) values are 0 */
116
117 /* removed Minimized - no explanation of what it really means - ambiguity */
118 /* should not be here if not clear */
119 #define WIN_STATE_STICKY (1<<0) /* everyone knows sticky */
120 #define WIN_STATE_RESERVED_BIT1 (1<<1) /* removed minimize here */
121 #define WIN_STATE_MAXIMIZED_VERT (1<<2) /* window in maximized V state */
122 #define WIN_STATE_MAXIMIZED_HORIZ (1<<3) /* window in maximized H state */
123 #define WIN_STATE_HIDDEN (1<<4) /* not on taskbar but window visible */
124 #define WIN_STATE_SHADED (1<<5) /* shaded (NeXT style) */
125 #define WIN_STATE_HID_WORKSPACE (1<<6) /* not on current desktop */
126 #define WIN_STATE_HID_TRANSIENT (1<<7) /* owner of transient is hidden */
127 #define WIN_STATE_FIXED_POSITION (1<<8) /* window is fixed in position even */
128 #define WIN_STATE_ARRANGE_IGNORE (1<<9) /* ignore for auto arranging */
129 /* when scrolling about large */
130 /* virtual desktops ala fvwm */
131 #define XA_WIN_STATE "_WIN_STATE"
132 /* WIN_STATE = CARD32 */
133
134 /* Preferences for behavior for app */
135 /* ONLY the client sets this */
136 #define WIN_HINTS_SKIP_FOCUS (1<<0) /* "alt-tab" skips this win */
137 #define WIN_HINTS_SKIP_WINLIST (1<<1) /* not in win list */
138 #define WIN_HINTS_SKIP_TASKBAR (1<<2) /* not on taskbar */
139 #define WIN_HINTS_GROUP_TRANSIENT (1<<3) /* ??????? */
140 #define WIN_HINTS_FOCUS_ON_CLICK (1<<4) /* app only accepts focus when clicked */
141 #define WIN_HINTS_DO_NOT_COVER (1<<5) /* attempt to not cover this window */
142 #define XA_WIN_HINTS "_WIN_HINTS"
143 /* WIN_HINTS = CARD32 */
144
145 /* Application state - also "color reactiveness" - the app can keep changing */
146 /* this property when it changes its state and the WM or monitoring program */
147 /* will pick this up and display somehting accordingly. ONLY the client sets */
148 /* this. */
149 #define WIN_APP_STATE_NONE 0
150 #define WIN_APP_STATE_ACTIVE1 1
151 #define WIN_APP_STATE_ACTIVE2 2
152 #define WIN_APP_STATE_ERROR1 3
153 #define WIN_APP_STATE_ERROR2 4
154 #define WIN_APP_STATE_FATAL_ERROR1 5
155 #define WIN_APP_STATE_FATAL_ERROR2 6
156 #define WIN_APP_STATE_IDLE1 7
157 #define WIN_APP_STATE_IDLE2 8
158 #define WIN_APP_STATE_WAITING1 9
159 #define WIN_APP_STATE_WAITING2 10
160 #define WIN_APP_STATE_WORKING1 11
161 #define WIN_APP_STATE_WORKING2 12
162 #define WIN_APP_STATE_NEED_USER_INPUT1 13
163 #define WIN_APP_STATE_NEED_USER_INPUT2 14
164 #define WIN_APP_STATE_STRUGGLING1 15
165 #define WIN_APP_STATE_STRUGGLING2 16
166 #define WIN_APP_STATE_DISK_TRAFFIC1 17
167 #define WIN_APP_STATE_DISK_TRAFFIC2 18
168 #define WIN_APP_STATE_NETWORK_TRAFFIC1 19
169 #define WIN_APP_STATE_NETWORK_TRAFFIC2 20
170 #define WIN_APP_STATE_OVERLOADED1 21
171 #define WIN_APP_STATE_OVERLOADED2 22
172 #define WIN_APP_STATE_PERCENT000_1 23
173 #define WIN_APP_STATE_PERCENT000_2 24
174 #define WIN_APP_STATE_PERCENT010_1 25
175 #define WIN_APP_STATE_PERCENT010_2 26
176 #define WIN_APP_STATE_PERCENT020_1 27
177 #define WIN_APP_STATE_PERCENT020_2 28
178 #define WIN_APP_STATE_PERCENT030_1 29
179 #define WIN_APP_STATE_PERCENT030_2 30
180 #define WIN_APP_STATE_PERCENT040_1 31
181 #define WIN_APP_STATE_PERCENT040_2 32
182 #define WIN_APP_STATE_PERCENT050_1 33
183 #define WIN_APP_STATE_PERCENT050_2 34
184 #define WIN_APP_STATE_PERCENT060_1 35
185 #define WIN_APP_STATE_PERCENT060_2 36
186 #define WIN_APP_STATE_PERCENT070_1 37
187 #define WIN_APP_STATE_PERCENT070_2 38
188 #define WIN_APP_STATE_PERCENT080_1 39
189 #define WIN_APP_STATE_PERCENT080_2 40
190 #define WIN_APP_STATE_PERCENT090_1 41
191 #define WIN_APP_STATE_PERCENT090_2 42
192 #define WIN_APP_STATE_PERCENT100_1 43
193 #define WIN_APP_STATE_PERCENT100_2 44
194 #define XA_WIN_APP_STATE "_WIN_APP_STATE"
195 /* WIN_APP_STATE = CARD32 */
196
197 /* Expanded space occupied - this is the area on screen the app's window */
198 /* will occupy when "expanded" - ie if you have a button on an app that */
199 /* "hides" it by reducing its size, this is the geometry of the expanded */
200 /* window - so the window manager can allow for this when doign auto */
201 /* positioing of client windows assuming the app can at any point use this */
202 /* this area and thus try and keep it clear. ONLY the client sets this */
203 /*
204 * CARD32 x;
205 * CARD32 y;
206 * CARD32 width;
207 * CARD32 height;
208 */
209 #define XA_WIN_EXPANDED_SIZE "_WIN_EXPANDED_SIZE"
210 /* array of 4 CARD32's */
211
212 /* CARD32 that contians the desktop number the application is on If the */
213 /* application's state is "sticky" it is irrelevant. Only the WM should */
214 /* change this. */
215 #define XA_WIN_WORKSPACE "_WIN_WORKSPACE"
216
217 /* This atom is a 32-bit integer that is either 0 or 1 (currently). */
218 /* 0 denotes everything is as per usual but 1 denotes that ALL configure */
219 /* requests by the client on the client window with this property are */
220 /* not just a simple "moving" of the window, but the result of a user */
221 /* moving the window BUT the client handling that interaction by moving */
222 /* its own window. The window manager should respond accordingly by assuming */
223 /* any configure requests for this window whilst this atom is "active" in */
224 /* the "1" state are a client move and should handle flipping desktops if */
225 /* the window is being dragged "off screem" or across desktop boundaries */
226 /* etc. This atom is ONLY ever set by the client */
227 #define XA_WIN_CLIENT_MOVING "_WIN_CLIENT_MOVING"
228 /* WIN_CLIENT_MOVING = CARD32 */
229
230 /* Designed for checking if the WIN_ supporting WM is still there */
231 /* and kicking about - basically check this property - check the window */
232 /* ID it points to - then check that window Id has this property too */
233 /* if that is the case the WIN_ supporting WM is there and alive and the */
234 /* list of WIN_PROTOCOLS is valid */
235 #define XA_WIN_SUPPORTING_WM_CHECK "_WIN_SUPPORTING_WM_CHECK"
236 /* CARD32 */
237
238 /*********************************************************/
239 /* How an app can modify things after mapping */
240 /*********************************************************/
241
242 /* For a client to change layer or state it should send a client message */
243 /* to the root window as follows: */
244 /*
245 * Display *disp;
246 * Window root, client_window;
247 * XClientMessageEvent xev;
248 * CARD32 new_layer;
249 *
250 * xev.type = ClientMessage;
251 * xev.window = client_window;
252 * xev.message_type = ex_atom_get(XA_WIN_LAYER);
253 * xev.format = 32;
254 * xev.data.l[0] = new_layer;
255 * xev.data.l[1] = CurrentTime;
256 * XSendEvent(disp, root, False, SubstructureNotifyMask, (XEvent *) &xev);
257 */
258 /*
259 * Display *disp;
260 * Window root, client_window;
261 * XClientMessageEvent xev;
262 * CARD32 mask_of_members_to_change, new_members;
263 *
264 * xev.type = ClientMessage;
265 * xev.window = client_window;
266 * xev.message_type = ex_atom_get(XA_WIN_STATE);
267 * xev.format = 32;
268 * xev.data.l[0] = mask_of_members_to_change;
269 * xev.data.l[1] = new_members;
270 * xev.data.l[2] = CurrentTimep;
271 * XSendEvent(disp, root, False, SubstructureNotifyMask, (XEvent *) &xev);
272 */
273 /*
274 * Display *disp;
275 * Window root, client_window;
276 * XClientMessageEvent xev;
277 * CARD32 new_desktop_number;
278 *
279 * xev.type = ClientMessage;
280 * xev.window = client_window;
281 * xev.message_type = ex_atom_get(XA_WIN_WORKSPACE);
282 * xev.format = 32;
283 * xev.data.l[0] = new_desktop_number;
284 * xev.data.l[2] = CurrentTimep;
285 * XSendEvent(disp, root, False, SubstructureNotifyMask, (XEvent *) &xev);
286 */
287
288 #if 0 /* Does nothing useful */
289 static void
290 GNOME_GetHintIcons(EWin * ewin, EX_Atom atom_change)
291 {
292 static EX_Atom atom_get = 0;
293 int num, i;
294 EX_ID *plst;
295 EX_Pixmap pmap;
296 EX_Pixmap mask;
297
298 if (EwinIsInternal(ewin))
299 return;
300
301 if (!atom_get)
302 atom_get = ex_atom_get(XA_WIN_ICONS);
303 if ((atom_change) && (atom_change != atom_get))
304 return;
305
306 num = ex_window_prop_xid_list_get(EwinGetClientXwin(ewin), atom_get,
307 XA_PIXMAP, &plst);
308 if (num < 2)
309 return;
310
311 for (i = 0; i < num / 2; i++)
312 {
313 pmap = plst[2 * i];
314 mask = plst[2 * i + 1];
315 }
316 free(plst);
317 }
318 #endif
319
320 static void
GNOME_GetHintLayer(EWin * ewin,EX_Atom atom_change)321 GNOME_GetHintLayer(EWin * ewin, EX_Atom atom_change)
322 {
323 static EX_Atom atom_get = 0;
324 int num;
325 unsigned int layer;
326
327 if (EwinIsInternal(ewin))
328 return;
329
330 if (!atom_get)
331 atom_get = ex_atom_get(XA_WIN_LAYER);
332 if ((atom_change) && (atom_change != atom_get))
333 return;
334
335 num = ex_window_prop_card32_get(EwinGetClientXwin(ewin), atom_get,
336 &layer, 1);
337 if (num <= 0)
338 return;
339
340 EoSetLayer(ewin, layer);
341 EwinChange(ewin, EWIN_CHANGE_LAYER);
342 }
343
344 static void
GNOME_GetHintState(EWin * ewin,EX_Atom atom_change)345 GNOME_GetHintState(EWin * ewin, EX_Atom atom_change)
346 {
347 static EX_Atom atom_get = 0;
348 int num;
349 unsigned int flags;
350
351 if (EwinIsInternal(ewin))
352 return;
353
354 if (!atom_get)
355 atom_get = ex_atom_get(XA_WIN_STATE);
356 if ((atom_change) && (atom_change != atom_get))
357 return;
358
359 num = ex_window_prop_card32_get(EwinGetClientXwin(ewin), atom_get,
360 &flags, 1);
361 if (num <= 0)
362 return;
363
364 if (flags & WIN_STATE_SHADED)
365 ewin->state.shaded = 1;
366 if (flags & WIN_STATE_STICKY)
367 EoSetSticky(ewin, 1);
368 if (flags & WIN_STATE_FIXED_POSITION)
369 EwinInhSetUser(ewin, move, 1);
370 if (flags & WIN_STATE_ARRANGE_IGNORE)
371 ewin->props.ignorearrange = 1;
372 }
373
374 #if 0 /* Does nothing */
375 static void
376 GNOME_GetHintAppState(EWin * ewin, EX_Atom atom_change)
377 {
378 static EX_Atom atom_get = 0;
379 int num;
380 unsigned int flags;
381
382 /* have nothing interesting to do with an app state (lamp) right now */
383
384 if (EwinIsInternal(ewin))
385 return;
386
387 if (!atom_get)
388 atom_get = ex_atom_get(XA_WIN_APP_STATE);
389 if ((atom_change) && (atom_change != atom_get))
390 return;
391
392 num = ex_window_prop_card32_get(EwinGetClientXwin(ewin), atom_get,
393 &flags, 1);
394 if (num <= 0)
395 return;
396 }
397 #endif
398
399 static void
GNOME_GetHintDesktop(EWin * ewin,EX_Atom atom_change)400 GNOME_GetHintDesktop(EWin * ewin, EX_Atom atom_change)
401 {
402 static EX_Atom atom_get = 0;
403 int num;
404 unsigned int desk;
405
406 if (EwinIsInternal(ewin))
407 return;
408
409 if (!atom_get)
410 atom_get = ex_atom_get(XA_WIN_WORKSPACE);
411 if ((atom_change) && (atom_change != atom_get))
412 return;
413
414 num = ex_window_prop_card32_get(EwinGetClientXwin(ewin), atom_get, &desk, 1);
415 if (num <= 0)
416 return;
417
418 EoSetDesk(ewin, DeskGet(desk));
419 EwinChange(ewin, EWIN_CHANGE_DESKTOP);
420 }
421
422 static void
GNOME_GetHint(EWin * ewin,EX_Atom atom_change)423 GNOME_GetHint(EWin * ewin, EX_Atom atom_change)
424 {
425 static EX_Atom atom_get = 0;
426 int num;
427 unsigned int flags;
428
429 if (EwinIsInternal(ewin))
430 return;
431
432 if (!atom_get)
433 atom_get = ex_atom_get(XA_WIN_HINTS);
434 if ((atom_change) && (atom_change != atom_get))
435 return;
436
437 num = ex_window_prop_card32_get(EwinGetClientXwin(ewin), atom_get,
438 &flags, 1);
439 if (num <= 0)
440 return;
441
442 if (flags & WIN_HINTS_SKIP_TASKBAR)
443 ewin->props.skip_ext_task = 1;
444 if (flags & WIN_HINTS_SKIP_FOCUS)
445 ewin->props.skip_focuslist = 1;
446 if (flags & WIN_HINTS_SKIP_WINLIST)
447 ewin->props.skip_winlist = 1;
448 if (flags & WIN_HINTS_FOCUS_ON_CLICK)
449 ewin->props.focusclick = 1;
450 if (flags & WIN_HINTS_DO_NOT_COVER)
451 ewin->props.never_use_area = 1;
452 }
453
454 void
GNOME_SetHint(const EWin * ewin)455 GNOME_SetHint(const EWin * ewin)
456 {
457 static EX_Atom atom_set = 0;
458 unsigned int val;
459
460 if ((ewin->type == EWIN_TYPE_MENU) || (ewin->type == EWIN_TYPE_PAGER))
461 return;
462 if (!atom_set)
463 atom_set = ex_atom_get(XA_WIN_STATE);
464 val = 0;
465 if (EoIsSticky(ewin))
466 val |= WIN_STATE_STICKY;
467 if (ewin->state.shaded)
468 val |= WIN_STATE_SHADED;
469 if (EwinInhGetUser(ewin, move))
470 val |= WIN_STATE_FIXED_POSITION;
471 ex_window_prop_card32_set(EwinGetClientXwin(ewin), atom_set, &val, 1);
472 }
473
474 void
GNOME_SetEwinArea(const EWin * ewin)475 GNOME_SetEwinArea(const EWin * ewin)
476 {
477 static EX_Atom atom_set = 0;
478 unsigned int val[2];
479
480 if ((ewin->type == EWIN_TYPE_MENU) || (ewin->type == EWIN_TYPE_PAGER))
481 return;
482 if (!atom_set)
483 atom_set = ex_atom_get(XA_WIN_AREA);
484 val[0] = ewin->area_x;
485 val[1] = ewin->area_y;
486 ex_window_prop_card32_set(EwinGetClientXwin(ewin), atom_set, val, 2);
487 }
488
489 void
GNOME_SetEwinDesk(const EWin * ewin)490 GNOME_SetEwinDesk(const EWin * ewin)
491 {
492 static EX_Atom atom_set = 0;
493 unsigned int val;
494
495 if ((ewin->type == EWIN_TYPE_MENU) || (ewin->type == EWIN_TYPE_PAGER))
496 return;
497 if (!atom_set)
498 atom_set = ex_atom_get(XA_WIN_WORKSPACE);
499 val = EoGetDeskNum(ewin);
500 ex_window_prop_card32_set(EwinGetClientXwin(ewin), atom_set, &val, 1);
501 }
502
503 #if 0 /* Does nothing */
504 static void
505 GNOME_GetExpandedSize(EWin * ewin, EX_Atom atom_change)
506 {
507 static EX_Atom atom_get = 0;
508 int num;
509 unsigned int exp[4];
510
511 if (EwinIsInternal(ewin))
512 return;
513
514 if (!atom_get)
515 atom_get = ex_atom_get(XA_WIN_EXPANDED_SIZE);
516 if ((atom_change) && (atom_change != atom_get))
517 return;
518
519 num = ex_window_prop_card32_get(EwinGetClientXwin(ewin), atom_get, exp, 4);
520 if (num >= 4)
521 {
522 #if 0 /* Not actually used */
523 ewin->expanded_x = retval[0];
524 ewin->expanded_y = retval[1];
525 ewin->expanded_width = retval[2];
526 ewin->expanded_height = retval[3];
527 #endif
528 }
529 }
530 #endif
531
532 static void
GNOME_SetUsedHints(void)533 GNOME_SetUsedHints(void)
534 {
535 static EX_Atom atom_set = 0;
536 EX_Atom list[10];
537
538 if (!atom_set)
539 atom_set = ex_atom_get(XA_WIN_PROTOCOLS);
540 list[0] = ex_atom_get(XA_WIN_LAYER);
541 list[1] = ex_atom_get(XA_WIN_STATE);
542 list[2] = ex_atom_get(XA_WIN_HINTS);
543 list[3] = ex_atom_get(XA_WIN_APP_STATE);
544 list[4] = ex_atom_get(XA_WIN_EXPANDED_SIZE);
545 list[5] = ex_atom_get(XA_WIN_ICONS);
546 list[6] = ex_atom_get(XA_WIN_WORKSPACE);
547 list[7] = ex_atom_get(XA_WIN_WORKSPACE_COUNT);
548 list[8] = ex_atom_get(XA_WIN_WORKSPACE_NAMES);
549 list[9] = ex_atom_get(XA_WIN_CLIENT_LIST);
550 ex_window_prop_atom_set(WinGetXwin(VROOT), atom_set, list, 10);
551 }
552
553 void
GNOME_SetCurrentArea(void)554 GNOME_SetCurrentArea(void)
555 {
556 static EX_Atom atom_set = 0;
557 unsigned int val[2];
558 int ax, ay;
559
560 if (!atom_set)
561 atom_set = ex_atom_get(XA_WIN_AREA);
562 DeskCurrentGetArea(&ax, &ay);
563 val[0] = ax;
564 val[1] = ay;
565 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, val, 2);
566 }
567
568 void
GNOME_SetCurrentDesk(void)569 GNOME_SetCurrentDesk(void)
570 {
571 static EX_Atom atom_set = 0;
572 unsigned int val;
573
574 if (!atom_set)
575 atom_set = ex_atom_get(XA_WIN_WORKSPACE);
576 val = DesksGetCurrentNum();
577 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1);
578 }
579
580 static void
GNOME_SetWMCheck(EX_Window win_wm_check)581 GNOME_SetWMCheck(EX_Window win_wm_check)
582 {
583 static EX_Atom atom_set = 0;
584 unsigned int val;
585
586 if (!atom_set)
587 atom_set = ex_atom_get(XA_WIN_SUPPORTING_WM_CHECK);
588 val = win_wm_check;
589 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1);
590 ex_window_prop_card32_set(win_wm_check, atom_set, &val, 1);
591 }
592
593 void
GNOME_SetDeskCount(void)594 GNOME_SetDeskCount(void)
595 {
596 static EX_Atom atom_set = 0;
597 unsigned int val;
598
599 if (!atom_set)
600 atom_set = ex_atom_get(XA_WIN_WORKSPACE_COUNT);
601 val = DesksGetNumber();
602 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1);
603 }
604
605 void
GNOME_SetAreaCount(void)606 GNOME_SetAreaCount(void)
607 {
608 static EX_Atom atom_set = 0;
609 int ax, ay;
610 unsigned int val[2];
611
612 if (!atom_set)
613 atom_set = ex_atom_get(XA_WIN_AREA_COUNT);
614 DesksGetAreaSize(&ax, &ay);
615 val[0] = ax;
616 val[1] = ay;
617 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, val, 2);
618 }
619
620 void
GNOME_SetDeskNames(void)621 GNOME_SetDeskNames(void)
622 {
623 static EX_Atom atom_set = 0;
624 char s[1024], **names;
625 int i, n_desks;
626
627 if (!atom_set)
628 atom_set = ex_atom_get(XA_WIN_WORKSPACE_NAMES);
629
630 n_desks = DesksGetNumber();
631 names = EMALLOC(char *, n_desks);
632
633 if (!names)
634 return;
635
636 for (i = 0; i < n_desks; i++)
637 {
638 Esnprintf(s, sizeof(s), "%i", i);
639 names[i] = Estrdup(s);
640 }
641
642 ex_window_prop_string_list_set(WinGetXwin(VROOT), atom_set, names, n_desks);
643
644 for (i = 0; i < n_desks; i++)
645 Efree(names[i]);
646 Efree(names);
647 }
648
649 void
GNOME_SetClientList(void)650 GNOME_SetClientList(void)
651 {
652 static EX_Atom atom_set = 0;
653 unsigned int *wl;
654 int j, i, num;
655 EWin *const *lst;
656
657 if (!atom_set)
658 atom_set = ex_atom_get(XA_WIN_CLIENT_LIST);
659
660 lst = EwinListOrderGet(&num);
661 wl = NULL;
662 j = 0;
663 if (lst)
664 {
665 wl = EMALLOC(unsigned int, num);
666
667 for (i = 0; i < num; i++)
668 {
669 if (!lst[i]->props.skip_ext_task && !EwinIsTransientChild(lst[i]))
670 wl[j++] = EwinGetClientXwin(lst[i]);
671 }
672 }
673 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, wl, j);
674 Efree(wl);
675 }
676
677 static void
GNOME_SetWMNameVer(void)678 GNOME_SetWMNameVer(void)
679 {
680 static EX_Atom atom_set = 0, atom_set2 = 0;
681
682 if (!atom_set)
683 atom_set = ex_atom_get(XA_WIN_WM_NAME);
684 ex_window_prop_string_set(WinGetXwin(VROOT), atom_set, e_wm_name);
685
686 if (!atom_set2)
687 atom_set2 = ex_atom_get(XA_WIN_WM_VERSION);
688 ex_window_prop_string_set(WinGetXwin(VROOT), atom_set2, e_wm_version);
689 }
690
691 void
GNOME_DelHints(const EWin * ewin)692 GNOME_DelHints(const EWin * ewin)
693 {
694 static EX_Atom atom_get[6] = { 0, 0, 0, 0, 0, 0 };
695 EX_Window win;
696
697 if (!atom_get[0])
698 {
699 atom_get[0] = ex_atom_get(XA_WIN_WORKSPACE);
700 atom_get[1] = ex_atom_get(XA_WIN_LAYER);
701 atom_get[2] = ex_atom_get(XA_WIN_STATE);
702 atom_get[3] = ex_atom_get(XA_WIN_HINTS);
703 atom_get[4] = ex_atom_get(XA_WIN_APP_STATE);
704 atom_get[5] = ex_atom_get(XA_WIN_AREA);
705 }
706
707 win = EwinGetClientXwin(ewin);
708 XDeleteProperty(disp, win, atom_get[0]);
709 XDeleteProperty(disp, win, atom_get[1]);
710 XDeleteProperty(disp, win, atom_get[2]);
711 XDeleteProperty(disp, win, atom_get[3]);
712 XDeleteProperty(disp, win, atom_get[4]);
713 XDeleteProperty(disp, win, atom_get[5]);
714 }
715
716 void
GNOME_GetHints(EWin * ewin,EX_Atom atom_change)717 GNOME_GetHints(EWin * ewin, EX_Atom atom_change)
718 {
719 GNOME_GetHintDesktop(ewin, atom_change);
720 GNOME_GetHintLayer(ewin, atom_change);
721 GNOME_GetHintState(ewin, atom_change);
722 GNOME_GetHint(ewin, atom_change);
723 #if 0 /* Do nothing */
724 GNOME_GetHintIcons(ewin, atom_change);
725 GNOME_GetHintAppState(ewin, atom_change);
726 GNOME_GetExpandedSize(ewin, atom_change);
727 #endif
728 }
729
730 void
GNOME_SetHints(EX_Window win_wm_check)731 GNOME_SetHints(EX_Window win_wm_check)
732 {
733 GNOME_SetWMNameVer();
734 GNOME_SetUsedHints();
735 GNOME_SetWMCheck(win_wm_check);
736 {
737 EX_Atom atom_set;
738 unsigned int val;
739
740 atom_set = ex_atom_get("_WIN_DESKTOP_BUTTON_PROXY");
741 Mode.button_proxy_win =
742 XCreateSimpleWindow(disp, WinGetXwin(VROOT), -80, -80, 24, 24, 0,
743 0, 0);
744 val = Mode.button_proxy_win;
745 ex_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1);
746 ex_window_prop_card32_set(Mode.button_proxy_win, atom_set, &val, 1);
747 }
748 }
749
750 int
GNOME_ProcessClientClientMessage(EWin * ewin,XClientMessageEvent * event)751 GNOME_ProcessClientClientMessage(EWin * ewin, XClientMessageEvent * event)
752 {
753 static EX_Atom a4 = 0, a5 = 0;
754
755 if (!a4)
756 a4 = ex_atom_get("_WIN_LAYER");
757 if (!a5)
758 a5 = ex_atom_get("_WIN_STATE");
759
760 if (event->message_type == a4)
761 {
762 unsigned int val;
763
764 val = event->data.l[0];
765 EoSetLayer(ewin, val);
766 ex_window_prop_card32_set(EwinGetClientXwin(ewin), a4, &val, 1);
767 EwinRaise(ewin);
768 return 1;
769 }
770 if (event->message_type == a5)
771 {
772 if (event->data.l[0] & WIN_STATE_FIXED_POSITION)
773 {
774 if (event->data.l[1] & WIN_STATE_FIXED_POSITION)
775 EwinInhSetUser(ewin, move, 1);
776 else
777 EwinInhSetUser(ewin, move, 0);
778 }
779 if (event->data.l[0] & WIN_STATE_ARRANGE_IGNORE)
780 {
781 if (event->data.l[1] & WIN_STATE_ARRANGE_IGNORE)
782 ewin->props.ignorearrange = 1;
783 else
784 ewin->props.ignorearrange = 0;
785 }
786 if ((event->data.l[0] & WIN_STATE_STICKY)
787 && (!ewin->props.ignorearrange))
788 {
789 EwinOpStick(ewin, OPSRC_USER,
790 (event->data.l[1] & WIN_STATE_STICKY) != 0);
791 }
792 if (event->data.l[0] & WIN_STATE_SHADED)
793 {
794 EwinOpShade(ewin, OPSRC_USER,
795 (event->data.l[1] & WIN_STATE_SHADED) != 0);
796 }
797 HintsSetWindowState(ewin);
798 return 1;
799 }
800
801 return 0;
802 }
803
804 int
GNOME_ProcessRootClientMessage(XClientMessageEvent * event)805 GNOME_ProcessRootClientMessage(XClientMessageEvent * event)
806 {
807 static EX_Atom a2 = 0, a3 = 0;
808
809 if (!a2)
810 a2 = ex_atom_get("_WIN_AREA");
811 if (!a3)
812 a3 = ex_atom_get("_WIN_WORKSPACE");
813
814 if (event->message_type == a2)
815 {
816 DeskCurrentGotoArea(event->data.l[0], event->data.l[1]);
817 return 1;
818 }
819 if (event->message_type == a3)
820 {
821 DeskGotoNum(event->data.l[0]);
822 return 1;
823 }
824
825 return 0;
826 }
827