1 /* wmspec.c-- support for the wm-spec 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,
27 * This file needs to be checked for all calls to XGetWindowProperty() and
28 * proper checks need to be made on the returned values. Only checking for
29 * return to be Success is not enough. -Dan
37 #include <X11/Xatom.h>
40 #include "WindowMaker.h"
43 #include "workspace.h"
51 #include "properties.h"
58 /* Global variables */
59 extern Atom _XA_WM_DELETE_WINDOW
;
60 extern Time LastTimestamp
;
61 extern WPreferences wPreferences
;
63 /* Root Window Properties */
64 static Atom net_supported
;
65 static Atom net_client_list
;
66 static Atom net_client_list_stacking
;
67 static Atom net_number_of_desktops
;
68 static Atom net_desktop_geometry
;
69 static Atom net_desktop_viewport
;
70 static Atom net_current_desktop
;
71 static Atom net_desktop_names
;
72 static Atom net_active_window
;
73 static Atom net_workarea
; /* XXX: not xinerama compatible */
74 static Atom net_supporting_wm_check
;
75 static Atom net_virtual_roots
; /* N/A */
76 static Atom net_desktop_layout
; /* XXX */
77 static Atom net_showing_desktop
;
79 /* Other Root Window Messages */
80 static Atom net_close_window
;
81 static Atom net_moveresize_window
; /* TODO */
82 static Atom net_wm_moveresize
; /* TODO */
84 /* Application Window Properties */
85 static Atom net_wm_name
;
86 static Atom net_wm_visible_name
; /* TODO (unnecessary?) */
87 static Atom net_wm_icon_name
;
88 static Atom net_wm_visible_icon_name
; /* TODO (unnecessary?) */
89 static Atom net_wm_desktop
;
90 static Atom net_wm_window_type
;
91 static Atom net_wm_window_type_desktop
;
92 static Atom net_wm_window_type_dock
;
93 static Atom net_wm_window_type_toolbar
;
94 static Atom net_wm_window_type_menu
;
95 static Atom net_wm_window_type_utility
;
96 static Atom net_wm_window_type_splash
;
97 static Atom net_wm_window_type_dialog
;
98 static Atom net_wm_window_type_normal
;
99 static Atom net_wm_state
;
100 static Atom net_wm_state_modal
; /* XXX: what is this?!? */
101 static Atom net_wm_state_sticky
;
102 static Atom net_wm_state_maximized_vert
;
103 static Atom net_wm_state_maximized_horz
;
104 static Atom net_wm_state_shaded
;
105 static Atom net_wm_state_skip_taskbar
;
106 static Atom net_wm_state_skip_pager
;
107 static Atom net_wm_state_hidden
;
108 static Atom net_wm_state_fullscreen
;
109 static Atom net_wm_state_above
;
110 static Atom net_wm_state_below
;
111 static Atom net_wm_allowed_actions
;
112 static Atom net_wm_action_move
;
113 static Atom net_wm_action_resize
;
114 static Atom net_wm_action_minimize
;
115 static Atom net_wm_action_shade
;
116 static Atom net_wm_action_stick
;
117 static Atom net_wm_action_maximize_horz
;
118 static Atom net_wm_action_maximize_vert
;
119 static Atom net_wm_action_fullscreen
;
120 static Atom net_wm_action_change_desktop
;
121 static Atom net_wm_action_close
;
122 static Atom net_wm_strut
; /* XXX: see net_workarea */
123 static Atom net_wm_strut_partial
; /* TODO: doesn't really fit into the current strut scheme */
124 static Atom net_wm_icon_geometry
; /* FIXME: should work together with net_wm_handled_icons, gnome-panel-2.2.0.1 doesn't use _NET_WM_HANDLED_ICONS, thus present situation. */
125 static Atom net_wm_icon
;
126 static Atom net_wm_pid
; /* TODO */
127 static Atom net_wm_handled_icons
; /* FIXME: see net_wm_icon_geometry */
129 /* Window Manager Protocols */
130 static Atom net_wm_ping
; /* TODO */
132 static Atom utf8_string
;
139 static atomitem_t atomNames
[] = {
140 { "_NET_SUPPORTED", &net_supported
},
141 { "_NET_CLIENT_LIST", &net_client_list
},
142 { "_NET_CLIENT_LIST_STACKING", &net_client_list_stacking
},
143 { "_NET_NUMBER_OF_DESKTOPS", &net_number_of_desktops
},
144 { "_NET_DESKTOP_GEOMETRY", &net_desktop_geometry
},
145 { "_NET_DESKTOP_VIEWPORT", &net_desktop_viewport
},
146 { "_NET_CURRENT_DESKTOP", &net_current_desktop
},
147 { "_NET_DESKTOP_NAMES", &net_desktop_names
},
148 { "_NET_ACTIVE_WINDOW", &net_active_window
},
149 { "_NET_WORKAREA", &net_workarea
},
150 { "_NET_SUPPORTING_WM_CHECK", &net_supporting_wm_check
},
151 { "_NET_VIRTUAL_ROOTS", &net_virtual_roots
},
152 { "_NET_DESKTOP_LAYOUT", &net_desktop_layout
},
153 { "_NET_SHOWING_DESKTOP", &net_showing_desktop
},
155 { "_NET_CLOSE_WINDOW", &net_close_window
},
156 { "_NET_MOVERESIZE_WINDOW", &net_moveresize_window
},
157 { "_NET_WM_MOVERESIZE", &net_wm_moveresize
},
159 { "_NET_WM_NAME", &net_wm_name
},
160 { "_NET_WM_VISIBLE_NAME", &net_wm_visible_name
},
161 { "_NET_WM_ICON_NAME", &net_wm_icon_name
},
162 { "_NET_WM_VISIBLE_ICON_NAME", &net_wm_visible_icon_name
},
163 { "_NET_WM_DESKTOP", &net_wm_desktop
},
164 { "_NET_WM_WINDOW_TYPE", &net_wm_window_type
},
165 { "_NET_WM_WINDOW_TYPE_DESKTOP", &net_wm_window_type_desktop
},
166 { "_NET_WM_WINDOW_TYPE_DOCK", &net_wm_window_type_dock
},
167 { "_NET_WM_WINDOW_TYPE_TOOLBAR", &net_wm_window_type_toolbar
},
168 { "_NET_WM_WINDOW_TYPE_MENU", &net_wm_window_type_menu
},
169 { "_NET_WM_WINDOW_TYPE_UTILITY", &net_wm_window_type_utility
},
170 { "_NET_WM_WINDOW_TYPE_SPLASH", &net_wm_window_type_splash
},
171 { "_NET_WM_WINDOW_TYPE_DIALOG", &net_wm_window_type_dialog
},
172 { "_NET_WM_WINDOW_TYPE_NORMAL", &net_wm_window_type_normal
},
173 { "_NET_WM_STATE", &net_wm_state
},
174 { "_NET_WM_STATE_MODAL", &net_wm_state_modal
},
175 { "_NET_WM_STATE_STICKY", &net_wm_state_sticky
},
176 { "_NET_WM_STATE_MAXIMIZED_VERT", &net_wm_state_maximized_vert
},
177 { "_NET_WM_STATE_MAXIMIZED_HORZ", &net_wm_state_maximized_horz
},
178 { "_NET_WM_STATE_SHADED", &net_wm_state_shaded
},
179 { "_NET_WM_STATE_SKIP_TASKBAR", &net_wm_state_skip_taskbar
},
180 { "_NET_WM_STATE_SKIP_PAGER", &net_wm_state_skip_pager
},
181 { "_NET_WM_STATE_HIDDEN", &net_wm_state_hidden
},
182 { "_NET_WM_STATE_FULLSCREEN", &net_wm_state_fullscreen
},
183 { "_NET_WM_STATE_ABOVE", &net_wm_state_above
},
184 { "_NET_WM_STATE_BELOW", &net_wm_state_below
},
185 { "_NET_WM_ALLOWED_ACTIONS", &net_wm_allowed_actions
},
186 { "_NET_WM_ACTION_MOVE", &net_wm_action_move
},
187 { "_NET_WM_ACTION_RESIZE", &net_wm_action_resize
},
188 { "_NET_WM_ACTION_MINIMIZE", &net_wm_action_minimize
},
189 { "_NET_WM_ACTION_SHADE", &net_wm_action_shade
},
190 { "_NET_WM_ACTION_STICK", &net_wm_action_stick
},
191 { "_NET_WM_ACTION_MAXIMIZE_HORZ", &net_wm_action_maximize_horz
},
192 { "_NET_WM_ACTION_MAXIMIZE_VERT", &net_wm_action_maximize_vert
},
193 { "_NET_WM_ACTION_FULLSCREEN", &net_wm_action_fullscreen
},
194 { "_NET_WM_ACTION_CHANGE_DESKTOP", &net_wm_action_change_desktop
},
195 { "_NET_WM_ACTION_CLOSE", &net_wm_action_close
},
196 { "_NET_WM_STRUT", &net_wm_strut
},
197 { "_NET_WM_STRUT_PARTIAL", &net_wm_strut_partial
},
198 { "_NET_WM_ICON_GEOMETRY", &net_wm_icon_geometry
},
199 { "_NET_WM_ICON", &net_wm_icon
},
200 { "_NET_WM_PID", &net_wm_pid
},
201 { "_NET_WM_HANDLED_ICONS", &net_wm_handled_icons
},
203 { "_NET_WM_PING", &net_wm_ping
},
205 { "UTF8_STRING", &utf8_string
},
208 #define atomNr (sizeof(atomNames)/sizeof(atomitem_t))
210 #define _NET_WM_STATE_REMOVE 0
211 #define _NET_WM_STATE_ADD 1
212 #define _NET_WM_STATE_TOGGLE 2
214 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
215 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
216 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
217 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
218 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
219 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
220 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
221 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
222 #define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */
223 #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
224 #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
226 static void observer(void *self
, WMNotification
*notif
);
227 static void wsobserver(void *self
, WMNotification
*notif
);
229 static void updateClientList(WScreen
*scr
);
230 static void updateClientListStacking(WScreen
*scr
, WWindow
*);
232 static void updateWorkspaceNames(WScreen
*scr
);
233 static void updateCurrentWorkspace(WScreen
*scr
);
234 static void updateWorkspaceCount(WScreen
*scr
);
236 typedef struct NetData
{
238 WReservedArea
*strut
;
239 WWindow
**show_desktop
;
244 setSupportedHints(WScreen
*scr
)
249 /* set supported hints list */
250 /* XXX: extend this !!! */
252 atom
[i
++] = net_client_list
;
253 atom
[i
++] = net_client_list_stacking
;
254 atom
[i
++] = net_number_of_desktops
;
255 atom
[i
++] = net_desktop_geometry
;
256 atom
[i
++] = net_desktop_viewport
;
257 atom
[i
++] = net_current_desktop
;
258 atom
[i
++] = net_desktop_names
;
259 atom
[i
++] = net_active_window
;
260 atom
[i
++] = net_workarea
;
261 atom
[i
++] = net_supporting_wm_check
;
262 atom
[i
++] = net_showing_desktop
;
264 atom
[i
++] = net_wm_moveresize
;
266 atom
[i
++] = net_wm_desktop
;
267 atom
[i
++] = net_wm_window_type
;
268 atom
[i
++] = net_wm_window_type_desktop
;
269 atom
[i
++] = net_wm_window_type_dock
;
270 atom
[i
++] = net_wm_window_type_toolbar
;
271 atom
[i
++] = net_wm_window_type_menu
;
272 atom
[i
++] = net_wm_window_type_utility
;
273 atom
[i
++] = net_wm_window_type_splash
;
274 atom
[i
++] = net_wm_window_type_dialog
;
275 atom
[i
++] = net_wm_window_type_normal
;
277 atom
[i
++] = net_wm_state
;
278 /* atom[i++] = net_wm_state_modal; */ /* XXX: not sure where/when to use it. */
279 atom
[i
++] = net_wm_state_sticky
;
280 atom
[i
++] = net_wm_state_shaded
;
281 atom
[i
++] = net_wm_state_maximized_horz
;
282 atom
[i
++] = net_wm_state_maximized_vert
;
283 atom
[i
++] = net_wm_state_skip_taskbar
;
284 atom
[i
++] = net_wm_state_skip_pager
;
285 atom
[i
++] = net_wm_state_hidden
;
286 atom
[i
++] = net_wm_state_fullscreen
;
287 atom
[i
++] = net_wm_state_above
;
288 atom
[i
++] = net_wm_state_below
;
290 atom
[i
++] = net_wm_allowed_actions
;
291 atom
[i
++] = net_wm_action_move
;
292 atom
[i
++] = net_wm_action_resize
;
293 atom
[i
++] = net_wm_action_minimize
;
294 atom
[i
++] = net_wm_action_shade
;
295 atom
[i
++] = net_wm_action_stick
;
296 atom
[i
++] = net_wm_action_maximize_horz
;
297 atom
[i
++] = net_wm_action_maximize_vert
;
298 atom
[i
++] = net_wm_action_fullscreen
;
299 atom
[i
++] = net_wm_action_change_desktop
;
300 atom
[i
++] = net_wm_action_close
;
302 atom
[i
++] = net_wm_strut
;
303 atom
[i
++] = net_wm_icon_geometry
;
304 atom
[i
++] = net_wm_icon
;
305 atom
[i
++] = net_wm_handled_icons
;
307 atom
[i
++] = net_wm_name
;
308 atom
[i
++] = net_wm_icon_name
;
310 XChangeProperty(dpy
, scr
->root_win
, net_supported
, XA_ATOM
, 32,
311 PropModeReplace
, (unsigned char*)atom
, i
);
313 /* set supporting wm hint */
314 XChangeProperty(dpy
, scr
->root_win
, net_supporting_wm_check
, XA_WINDOW
, 32,
315 PropModeReplace
, (unsigned char*)&scr
->info_window
, 1);
317 XChangeProperty(dpy
, scr
->info_window
, net_supporting_wm_check
, XA_WINDOW
,
318 32, PropModeReplace
, (unsigned char*)&scr
->info_window
, 1);
323 wNETWMUpdateDesktop(WScreen
*scr
)
325 CARD32
*views
, sizes
[2];
328 if (scr
->workspace_count
==0)
331 count
= scr
->workspace_count
* 2;
332 views
= wmalloc(sizeof(CARD32
) * count
);
333 /*memset(views, 0, sizeof(CARD32) * count);*/
335 #ifdef VIRTUAL_DESKTOP
336 sizes
[0] = scr
->workspaces
[scr
->current_workspace
]->width
;
337 sizes
[1] = scr
->workspaces
[scr
->current_workspace
]->height
;
339 sizes
[0] = scr
->scr_width
;
340 sizes
[1] = scr
->scr_height
;
343 for (i
=0; i
<scr
->workspace_count
; i
++) {
344 #ifdef VIRTUAL_DESKTOP
345 views
[2*i
+ 0] = scr
->workspaces
[i
]->view_x
;
346 views
[2*i
+ 1] = scr
->workspaces
[i
]->view_y
;
353 XChangeProperty(dpy
, scr
->root_win
, net_desktop_geometry
, XA_CARDINAL
, 32,
354 PropModeReplace
, (unsigned char*)sizes
, 2);
356 XChangeProperty(dpy
, scr
->root_win
, net_desktop_viewport
, XA_CARDINAL
, 32,
357 PropModeReplace
, (unsigned char*)views
, count
);
364 wNETWMGetCurrentDesktopFromHint(WScreen
*scr
)
369 prop
= PropGetCheckProperty(scr
->root_win
, net_current_desktop
, XA_CARDINAL
,
373 int desktop
= *(CARD32
*)prop
;
382 * Find the best icon to be used by Window Maker for appicon/miniwindows.
383 * Currently the algorithm is to take the image with the size closest
384 * to icon_size x icon_size, but never bigger than that.
386 * This algorithm is very poorly implemented and needs to be redone (it can
387 * easily select images with very large widths and very small heights over
388 * square images, if the area of the former is closer to the desired one).
390 * The logic can also be changed to accept bigger images and scale them down.
393 findBestIcon(CARD32
*data
, unsigned long items
)
395 int size
, wanted
, d
, distance
;
399 /* better use only 75% of icon_size. For 64x64 this means 48x48
400 * This leaves room around the icon for the miniwindow title and
401 * results in better overall aesthetics -Dan */
402 wanted
= wPreferences
.icon_size
* wPreferences
.icon_size
;
404 for (icon
=NULL
, distance
=LONG_MAX
, i
=0L; i
<items
-1; ) {
405 size
= data
[i
] * data
[i
+1];
409 if (d
>=0 && d
<=distance
&& (i
+size
+2)<=items
) {
421 makeRImageFromARGBData(CARD32
*data
)
423 int size
, width
, height
, i
;
425 unsigned char *imgdata
;
430 size
= width
* height
;
435 image
= RCreateImage(width
, height
, True
);
437 for (imgdata
=image
->data
, i
=2; i
<size
+2; i
++, imgdata
+=4) {
439 imgdata
[3] = (pixel
>> 24) & 0xff; /* A */
440 imgdata
[0] = (pixel
>> 16) & 0xff; /* R */
441 imgdata
[1] = (pixel
>> 8) & 0xff; /* G */
442 imgdata
[2] = (pixel
>> 0) & 0xff; /* B */
450 updateIconImage(WScreen
*scr
, WWindow
*wwin
)
452 CARD32
*property
, *data
;
453 unsigned long items
, rest
;
458 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_icon
, 0L, LONG_MAX
,
459 False
, XA_CARDINAL
, &type
, &format
, &items
, &rest
,
460 (unsigned char**)&property
)!=Success
|| !property
) {
464 if (type
!=XA_CARDINAL
|| format
!=32 || items
<2) {
469 data
= findBestIcon(property
, items
);
475 image
= makeRImageFromARGBData(data
);
478 if (wwin
->net_icon_image
)
479 RReleaseImage(wwin
->net_icon_image
);
480 wwin
->net_icon_image
= image
;
488 updateShowDesktop(WScreen
* scr
, Bool show
)
492 foo
= (show
== True
);
493 XChangeProperty(dpy
, scr
->root_win
, net_showing_desktop
, XA_CARDINAL
, 32,
494 PropModeReplace
, (unsigned char *)&foo
, 1);
499 wNETWMShowingDesktop(WScreen
*scr
, Bool show
)
501 if (show
&& scr
->netdata
->show_desktop
== NULL
) {
502 WWindow
*tmp
, **wins
;
505 wins
= (WWindow
**)wmalloc(sizeof(WWindow
*)*(scr
->window_count
+1));
507 tmp
= scr
->focused_window
;
509 if (!tmp
->flags
.hidden
&& !tmp
->flags
.miniaturized
&&
510 !WFLAGP(tmp
, skip_window_list
)) {
513 tmp
->flags
.skip_next_animation
= 1;
514 tmp
->flags
.net_show_desktop
= 1;
522 scr
->netdata
->show_desktop
= wins
;
523 updateShowDesktop(scr
, True
);
524 } else if (scr
->netdata
->show_desktop
!= NULL
) {
525 /* FIXME: get rid of workspace flashing ! */
526 int ws
= scr
->current_workspace
;
528 for (tmp
= scr
->netdata
->show_desktop
; *tmp
; ++tmp
) {
529 wDeiconifyWindow(*tmp
);
530 (*tmp
)->flags
.net_show_desktop
= 0;
532 if (ws
!= scr
->current_workspace
)
533 wWorkspaceChange(scr
, ws
);
534 wfree(scr
->netdata
->show_desktop
);
535 scr
->netdata
->show_desktop
= NULL
;
536 updateShowDesktop(scr
, False
);
542 wNETWMInitStuff(WScreen
*scr
)
548 printf( "wNETWMInitStuff\n");
551 #ifdef HAVE_XINTERNATOMS
554 char * names
[atomNr
];
556 for (i
= 0; i
< atomNr
; ++i
) {
557 names
[i
] = atomNames
[i
].name
;
559 XInternAtoms(dpy
, &names
[0], atomNr
, False
, atoms
);
560 for (i
= 0; i
< atomNr
; ++i
) {
561 *atomNames
[i
].atom
= atoms
[i
];
565 for (i
= 0; i
< atomNr
; i
++) {
566 *atomNames
[i
].atom
= XInternAtom(dpy
, atomNames
[i
].name
, False
);
570 data
= wmalloc(sizeof(NetData
));
573 data
->show_desktop
= NULL
;
577 setSupportedHints(scr
);
579 WMAddNotificationObserver(observer
, data
, WMNManaged
, NULL
);
580 WMAddNotificationObserver(observer
, data
, WMNUnmanaged
, NULL
);
581 WMAddNotificationObserver(observer
, data
, WMNChangedWorkspace
, NULL
);
582 WMAddNotificationObserver(observer
, data
, WMNChangedState
, NULL
);
583 WMAddNotificationObserver(observer
, data
, WMNChangedFocus
, NULL
);
584 WMAddNotificationObserver(observer
, data
, WMNChangedStacking
, NULL
);
585 WMAddNotificationObserver(observer
, data
, WMNChangedName
, NULL
);
587 WMAddNotificationObserver(wsobserver
, data
, WMNWorkspaceCreated
, NULL
);
588 WMAddNotificationObserver(wsobserver
, data
, WMNWorkspaceDestroyed
, NULL
);
589 WMAddNotificationObserver(wsobserver
, data
, WMNWorkspaceChanged
, NULL
);
590 WMAddNotificationObserver(wsobserver
, data
, WMNWorkspaceNameChanged
, NULL
);
592 updateClientList(scr
);
593 updateClientListStacking(scr
, NULL
);
594 updateWorkspaceCount(scr
);
595 updateWorkspaceNames(scr
);
596 updateShowDesktop(scr
, False
);
598 wScreenUpdateUsableArea(scr
);
603 wNETWMCleanup(WScreen
*scr
)
607 for (i
= 0; i
< atomNr
; i
++)
608 XDeleteProperty(dpy
, scr
->root_win
, *atomNames
[i
].atom
);
613 wNETWMUpdateActions(WWindow
*wwin
, Bool del
)
615 Atom action
[10]; /* nr of actions atoms defined */
619 XDeleteProperty(dpy
, wwin
->client_win
, net_wm_allowed_actions
);
623 if (IS_MOVABLE(wwin
))
624 action
[i
++] = net_wm_action_move
;
626 if (IS_RESIZABLE(wwin
))
627 action
[i
++] = net_wm_action_resize
;
629 if (!WFLAGP(wwin
, no_miniaturizable
))
630 action
[i
++] = net_wm_action_minimize
;
632 if (!WFLAGP(wwin
, no_shadeable
))
633 action
[i
++] = net_wm_action_shade
;
635 /* if (!WFLAGP(wwin, no_stickable)) */
636 action
[i
++] = net_wm_action_stick
;
638 /* if (!(WFLAGP(wwin, no_maximizeable) & MAX_HORIZONTAL)) */
639 if (IS_RESIZABLE(wwin
))
640 action
[i
++] = net_wm_action_maximize_horz
;
642 /* if (!(WFLAGP(wwin, no_maximizeable) & MAX_VERTICAL)) */
643 if (IS_RESIZABLE(wwin
))
644 action
[i
++] = net_wm_action_maximize_vert
;
646 /* if (!WFLAGP(wwin, no_fullscreen)) */
647 action
[i
++] = net_wm_action_fullscreen
;
649 /* if (!WFLAGP(wwin, no_change_desktop)) */
650 action
[i
++] = net_wm_action_change_desktop
;
652 if (!WFLAGP(wwin
, no_closable
))
653 action
[i
++] = net_wm_action_close
;
655 XChangeProperty(dpy
, wwin
->client_win
, net_wm_allowed_actions
,
656 XA_ATOM
, 32, PropModeReplace
, (unsigned char *)action
, i
);
661 wNETWMUpdateWorkarea(WScreen
*scr
, WArea usableArea
)
666 /* XXX: not Xinerama compatible,
667 xinerama gets the largest available */
669 if(!scr
->netdata
|| scr
->workspace_count
==0)
672 count
= scr
->workspace_count
* 4;
673 area
= wmalloc(sizeof(CARD32
) * count
);
674 for (i
=0; i
<scr
->workspace_count
; i
++) {
675 area
[4*i
+ 0] = usableArea
.x1
;
676 area
[4*i
+ 1] = usableArea
.y1
;
677 area
[4*i
+ 2] = usableArea
.x2
- usableArea
.x1
;
678 area
[4*i
+ 3] = usableArea
.y2
- usableArea
.y1
;
681 XChangeProperty(dpy
, scr
->root_win
, net_workarea
, XA_CARDINAL
, 32,
682 PropModeReplace
, (unsigned char*)area
, count
);
689 wNETWMGetUsableArea(WScreen
*scr
, int head
, WArea
*area
)
694 if(!scr
->netdata
|| !scr
->netdata
->strut
)
697 area
->x1
= area
->y1
= area
->x2
= area
->y2
= 0;
699 for(cur
= scr
->netdata
->strut
; cur
; cur
= cur
->next
) {
700 WWindow
* wwin
= wWindowFor(cur
->window
);
701 if (wWindowTouchesHead(wwin
, head
)) {
702 if(cur
->area
.x1
> area
->x1
)
703 area
->x1
= cur
->area
.x1
;
704 if(cur
->area
.y1
> area
->y1
)
705 area
->y1
= cur
->area
.y1
;
706 if(cur
->area
.x2
> area
->x2
)
707 area
->x2
= cur
->area
.x2
;
708 if(cur
->area
.y2
> area
->y2
)
709 area
->y2
= cur
->area
.y2
;
713 if (area
->x1
==0 && area
->x2
==0 &&
714 area
->y1
==0 && area
->y2
==0) return False
;
716 rect
= wGetRectForHead(scr
, head
);
718 area
->x1
= rect
.pos
.x
+ area
->x1
;
719 area
->x2
= rect
.pos
.x
+ rect
.size
.width
- area
->x2
;
720 area
->y1
= rect
.pos
.y
+ area
->y1
;
721 area
->y2
= rect
.pos
.y
+ rect
.size
.height
- area
->y2
;
728 updateClientList(WScreen
*scr
)
734 windows
= (Window
*)wmalloc(sizeof(Window
)*(scr
->window_count
+1));
737 wwin
= scr
->focused_window
;
739 windows
[count
++] = wwin
->client_win
;
742 XChangeProperty(dpy
, scr
->root_win
, net_client_list
, XA_WINDOW
, 32,
743 PropModeReplace
, (unsigned char*)windows
, count
);
751 updateClientListStacking(WScreen
*scr
, WWindow
*wwin_excl
)
755 Window
*client_list_reverse
;
761 /* update client list */
762 i
= scr
->window_count
+ 1;
763 client_list
= (Window
*)wmalloc(sizeof(Window
) * i
);
764 client_list_reverse
= (Window
*)wmalloc(sizeof(Window
) * i
);
767 WM_ETARETI_BAG(scr
->stacking_list
, tmp
, iter
) {
769 wwin
= wWindowFor(tmp
->window
);
770 /* wwin_excl is a window to exclude from the list
771 (e.g. it's now unmanaged) */
772 if(wwin
&& (wwin
!= wwin_excl
))
773 client_list
[client_count
++] = wwin
->client_win
;
774 tmp
= tmp
->stacking
->under
;
778 for(i
= 0; i
< client_count
; i
++) {
779 Window w
= client_list
[client_count
- i
- 1];
780 client_list_reverse
[i
] = w
;
783 XChangeProperty(dpy
, scr
->root_win
, net_client_list_stacking
, XA_WINDOW
, 32,
784 PropModeReplace
, (unsigned char *)client_list_reverse
, client_count
);
787 wfree(client_list_reverse
);
794 updateWorkspaceCount(WScreen
*scr
) /* changeable */
798 count
= scr
->workspace_count
;
800 XChangeProperty(dpy
, scr
->root_win
, net_number_of_desktops
, XA_CARDINAL
,
801 32, PropModeReplace
, (unsigned char*)&count
, 1);
806 updateCurrentWorkspace(WScreen
*scr
) /* changeable */
810 count
= scr
->current_workspace
;
812 XChangeProperty(dpy
, scr
->root_win
, net_current_desktop
, XA_CARDINAL
, 32,
813 PropModeReplace
, (unsigned char*)&count
, 1);
818 updateWorkspaceNames(WScreen
*scr
)
820 char buf
[1024], *pos
;
821 unsigned int i
, len
, curr_size
;
825 for(i
= 0; i
< scr
->workspace_count
; i
++) {
826 curr_size
= strlen(scr
->workspaces
[i
]->name
);
827 strcpy(pos
, scr
->workspaces
[i
]->name
);
828 pos
+= (curr_size
+1);
829 len
+= (curr_size
+1);
832 XChangeProperty(dpy
, scr
->root_win
, net_desktop_names
, utf8_string
, 8,
833 PropModeReplace
, (unsigned char *)buf
, len
);
838 updateFocusHint(WScreen
*scr
, WWindow
*wwin
) /* changeable */
842 if (!scr
->focused_window
|| !scr
->focused_window
->flags
.focused
)
845 window
= scr
->focused_window
->client_win
;
847 XChangeProperty(dpy
, scr
->root_win
, net_active_window
, XA_WINDOW
, 32,
848 PropModeReplace
, (unsigned char*)&window
, 1);
853 updateWorkspaceHint(WWindow
*wwin
, Bool fake
, Bool del
)
858 XDeleteProperty(dpy
, wwin
->client_win
, net_wm_desktop
);
860 l
= ((fake
|| IS_OMNIPRESENT(wwin
)) ? -1 : wwin
->frame
->workspace
);
861 XChangeProperty(dpy
, wwin
->client_win
, net_wm_desktop
, XA_CARDINAL
,
862 32, PropModeReplace
, (unsigned char*)&l
, 1);
868 updateStateHint(WWindow
*wwin
, Bool changedWorkspace
, Bool del
) /* changeable */
871 if (!wwin
->flags
.net_state_from_client
) {
872 XDeleteProperty(dpy
, wwin
->client_win
, net_wm_state
);
875 Atom state
[15]; /* nr of defined state atoms */
878 if(changedWorkspace
|| (wPreferences
.sticky_icons
&& !IS_OMNIPRESENT(wwin
)))
879 updateWorkspaceHint(wwin
, False
, False
);
881 if (IS_OMNIPRESENT(wwin
))
882 state
[i
++] = net_wm_state_sticky
;
883 if (wwin
->flags
.shaded
)
884 state
[i
++] = net_wm_state_shaded
;
885 if (wwin
->flags
.maximized
& MAX_HORIZONTAL
)
886 state
[i
++] = net_wm_state_maximized_horz
;
887 if (wwin
->flags
.maximized
& MAX_VERTICAL
)
888 state
[i
++] = net_wm_state_maximized_vert
;
889 if (WFLAGP(wwin
, skip_window_list
))
890 state
[i
++] = net_wm_state_skip_taskbar
;
891 if (wwin
->flags
.net_skip_pager
)
892 state
[i
++] = net_wm_state_skip_pager
;
893 if ((wwin
->flags
.hidden
|| wwin
->flags
.miniaturized
) && !wwin
->flags
.net_show_desktop
){
894 state
[i
++] = net_wm_state_hidden
;
895 state
[i
++] = net_wm_state_skip_pager
;
897 if (wwin
->flags
.miniaturized
&& wPreferences
.sticky_icons
) {
898 if (!IS_OMNIPRESENT(wwin
))
899 updateWorkspaceHint(wwin
, True
, False
);
900 state
[i
++] = net_wm_state_sticky
;
903 if (WFLAGP(wwin
, sunken
))
904 state
[i
++] = net_wm_state_below
;
905 if (WFLAGP(wwin
, floating
))
906 state
[i
++] = net_wm_state_above
;
907 if (wwin
->flags
.fullscreen
)
908 state
[i
++] = net_wm_state_fullscreen
;
910 XChangeProperty(dpy
, wwin
->client_win
, net_wm_state
, XA_ATOM
, 32,
911 PropModeReplace
, (unsigned char *)state
, i
);
917 updateStrut(WWindow
*wwin
, Bool adding
)
921 Bool hasState
= False
;
923 scr
= wwin
->screen_ptr
;
928 unsigned long nitems_ret
;
929 unsigned long bytes_after_ret
;
932 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_strut
, 0, 4, False
,
933 XA_CARDINAL
, &type_ret
, &fmt_ret
, &nitems_ret
,
935 (unsigned char**)&data
)==Success
&& data
) {
937 area
= (WReservedArea
*)wmalloc(sizeof(WReservedArea
));
938 area
->area
.x1
= data
[0];
939 area
->area
.x2
= data
[1];
940 area
->area
.y1
= data
[2];
941 area
->area
.y2
= data
[3];
943 area
->window
= wwin
->client_win
;
945 area
->next
= scr
->netdata
->strut
;
946 scr
->netdata
->strut
= area
;
950 #ifdef VIRTUAL_DESKTOP
951 /* just in case wm_window_type didn't set it already */
952 wwin
->client_flags
.virtual_stick
= 1;
958 area
= scr
->netdata
->strut
;
961 if(area
->window
== wwin
->client_win
) {
962 scr
->netdata
->strut
= area
->next
;
966 while(area
->next
&& area
->next
->window
!= wwin
->client_win
)
972 next
= area
->next
->next
;
987 getWindowLayer(WWindow
* wwin
)
989 int layer
= WMNormalLevel
;
991 if (wwin
->type
== net_wm_window_type_desktop
) {
992 layer
= WMDesktopLevel
;
993 } else if (wwin
->type
== net_wm_window_type_dock
) {
995 } else if (wwin
->type
== net_wm_window_type_toolbar
) {
996 layer
= WMMainMenuLevel
;
997 } else if (wwin
->type
== net_wm_window_type_menu
) {
998 layer
= WMSubmenuLevel
;
999 } else if (wwin
->type
== net_wm_window_type_utility
) {
1000 } else if (wwin
->type
== net_wm_window_type_splash
) {
1001 } else if (wwin
->type
== net_wm_window_type_dialog
) {
1002 if (wwin
->transient_for
) {
1003 WWindow
*parent
= wWindowFor(wwin
->transient_for
);
1004 if (parent
&& parent
->flags
.fullscreen
) {
1005 layer
= WMFullscreenLevel
;
1008 /* //layer = WMPopUpLevel; // this seems a bad idea -Dan */
1009 } else if (wwin
->type
== net_wm_window_type_normal
) {
1012 if (wwin
->client_flags
.sunken
&& WMSunkenLevel
< layer
)
1013 layer
= WMSunkenLevel
;
1014 if (wwin
->client_flags
.floating
&& WMFloatingLevel
> layer
)
1015 layer
= WMFloatingLevel
;
1022 doStateAtom(WWindow
*wwin
, Atom state
, int set
, Bool init
)
1025 if (state
== net_wm_state_sticky
) {
1026 if (set
== _NET_WM_STATE_TOGGLE
) {
1027 set
= !IS_OMNIPRESENT(wwin
);
1029 if (set
!= wwin
->flags
.omnipresent
) {
1030 wWindowSetOmnipresent(wwin
, set
);
1032 } else if (state
== net_wm_state_shaded
) {
1033 if (set
== _NET_WM_STATE_TOGGLE
) {
1034 set
= !wwin
->flags
.shaded
;
1037 wwin
->flags
.shaded
= set
;
1042 wUnshadeWindow(wwin
);
1045 } else if (state
== net_wm_state_skip_taskbar
) {
1046 if (set
== _NET_WM_STATE_TOGGLE
) {
1047 set
= !wwin
->client_flags
.skip_window_list
;
1049 wwin
->client_flags
.skip_window_list
= set
;
1050 } else if (state
== net_wm_state_skip_pager
) {
1051 if (set
== _NET_WM_STATE_TOGGLE
) {
1052 set
= !wwin
->flags
.net_skip_pager
;
1054 wwin
->flags
.net_skip_pager
= set
;
1055 } else if (state
== net_wm_state_maximized_vert
) {
1056 if (set
== _NET_WM_STATE_TOGGLE
) {
1057 set
= !(wwin
->flags
.maximized
& MAX_VERTICAL
);
1060 wwin
->flags
.maximized
|= (set
? MAX_VERTICAL
: 0);
1063 wMaximizeWindow(wwin
, wwin
->flags
.maximized
| MAX_VERTICAL
);
1065 wMaximizeWindow(wwin
, wwin
->flags
.maximized
& ~MAX_VERTICAL
);
1068 } else if (state
== net_wm_state_maximized_horz
) {
1069 if (set
== _NET_WM_STATE_TOGGLE
) {
1070 set
= !(wwin
->flags
.maximized
& MAX_HORIZONTAL
);
1073 wwin
->flags
.maximized
|= (set
? MAX_HORIZONTAL
: 0);
1076 wMaximizeWindow(wwin
, wwin
->flags
.maximized
| MAX_HORIZONTAL
);
1078 wMaximizeWindow(wwin
, wwin
->flags
.maximized
& ~MAX_HORIZONTAL
);
1081 } else if (state
== net_wm_state_hidden
) {
1082 if (set
== _NET_WM_STATE_TOGGLE
) {
1083 set
= !(wwin
->flags
.miniaturized
);
1086 wwin
->flags
.miniaturized
= set
;
1089 wIconifyWindow(wwin
);
1091 wDeiconifyWindow(wwin
);
1094 } else if (state
== net_wm_state_fullscreen
) {
1095 if (set
== _NET_WM_STATE_TOGGLE
) {
1096 set
= !(wwin
->flags
.fullscreen
);
1099 wwin
->flags
.fullscreen
= set
;
1102 wFullscreenWindow(wwin
);
1104 wUnfullscreenWindow(wwin
);
1107 } else if (state
== net_wm_state_above
) {
1108 if (set
== _NET_WM_STATE_TOGGLE
) {
1109 set
= !(wwin
->client_flags
.floating
);
1112 wwin
->client_flags
.floating
= set
;
1114 wwin
->client_flags
.floating
= set
;
1115 ChangeStackingLevel(wwin
->frame
->core
, getWindowLayer(wwin
));
1118 } else if (state
== net_wm_state_below
) {
1119 if (set
== _NET_WM_STATE_TOGGLE
) {
1120 set
= !(wwin
->client_flags
.sunken
);
1123 wwin
->client_flags
.sunken
= set
;
1125 wwin
->client_flags
.sunken
= set
;
1126 ChangeStackingLevel(wwin
->frame
->core
, getWindowLayer(wwin
));
1131 printf("doStateAtom unknown atom %s set %d\n", XGetAtomName(dpy
, state
), set
);
1138 removeIcon( WWindow
* wwin
)
1140 if (wwin
->icon
== NULL
)
1142 if (wwin
->flags
.miniaturized
&& wwin
->icon
->mapped
) {
1143 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1144 RemoveFromStackList(wwin
->icon
->core
);
1145 wIconDestroy(wwin
->icon
);
1152 handleWindowType(WWindow
* wwin
, Atom type
, int *layer
)
1156 if (type
== net_wm_window_type_desktop
) {
1157 wwin
->client_flags
.no_titlebar
= 1;
1158 wwin
->client_flags
.no_resizable
= 1;
1159 wwin
->client_flags
.no_miniaturizable
= 1;
1160 wwin
->client_flags
.no_border
= 1;
1161 wwin
->client_flags
.no_resizebar
= 1;
1162 wwin
->client_flags
.no_shadeable
= 1;
1163 wwin
->client_flags
.no_movable
= 1;
1164 wwin
->client_flags
.omnipresent
= 1;
1165 wwin
->client_flags
.skip_window_list
= 1;
1166 wwin
->client_flags
.dont_move_off
= 1;
1167 wwin
->client_flags
.no_appicon
= 1;
1168 wwin
->flags
.net_skip_pager
= 1;
1171 #ifdef VIRTUAL_DESKTOP
1172 wwin
->client_flags
.virtual_stick
= 1;
1174 } else if (type
== net_wm_window_type_dock
) {
1175 wwin
->client_flags
.no_titlebar
= 1;
1176 wwin
->client_flags
.no_resizable
= 1;
1177 wwin
->client_flags
.no_miniaturizable
= 1;
1178 wwin
->client_flags
.no_border
= 1; /* XXX: really not a single decoration. */
1179 wwin
->client_flags
.no_resizebar
= 1;
1180 wwin
->client_flags
.no_shadeable
= 1;
1181 wwin
->client_flags
.no_movable
= 1;
1182 wwin
->client_flags
.omnipresent
= 1;
1183 wwin
->client_flags
.skip_window_list
= 1;
1184 wwin
->client_flags
.dont_move_off
= 1;
1185 wwin
->flags
.net_skip_pager
= 1;
1186 #ifdef VIRTUAL_DESKTOP
1187 wwin
->client_flags
.virtual_stick
= 1;
1189 } else if (type
== net_wm_window_type_toolbar
) {
1190 wwin
->client_flags
.no_titlebar
= 1;
1191 wwin
->client_flags
.no_resizable
= 1;
1192 wwin
->client_flags
.no_miniaturizable
= 1;
1193 wwin
->client_flags
.no_resizebar
= 1;
1194 wwin
->client_flags
.no_shadeable
= 1;
1195 wwin
->client_flags
.skip_window_list
= 1;
1196 wwin
->client_flags
.dont_move_off
= 1;
1197 wwin
->client_flags
.no_appicon
= 1;
1198 } else if (type
== net_wm_window_type_menu
) {
1199 wwin
->client_flags
.no_titlebar
= 1;
1200 wwin
->client_flags
.no_resizable
= 1;
1201 wwin
->client_flags
.no_miniaturizable
= 1;
1202 wwin
->client_flags
.no_resizebar
= 1;
1203 wwin
->client_flags
.no_shadeable
= 1;
1204 wwin
->client_flags
.skip_window_list
= 1;
1205 wwin
->client_flags
.dont_move_off
= 1;
1206 wwin
->client_flags
.no_appicon
= 1;
1207 } else if (type
== net_wm_window_type_utility
) {
1208 wwin
->client_flags
.no_appicon
= 1;
1209 } else if (type
== net_wm_window_type_splash
) {
1210 wwin
->client_flags
.no_titlebar
= 1;
1211 wwin
->client_flags
.no_resizable
= 1;
1212 wwin
->client_flags
.no_miniaturizable
= 1;
1213 wwin
->client_flags
.no_resizebar
= 1;
1214 wwin
->client_flags
.no_shadeable
= 1;
1215 wwin
->client_flags
.no_movable
= 1;
1216 wwin
->client_flags
.skip_window_list
= 1;
1217 wwin
->client_flags
.dont_move_off
= 1;
1218 wwin
->client_flags
.no_appicon
= 1;
1219 wwin
->flags
.net_skip_pager
= 1;
1220 } else if (type
== net_wm_window_type_dialog
) {
1221 /* These also seem a bad idea in our context -Dan
1222 // wwin->client_flags.skip_window_list = 1;
1223 // wwin->client_flags.no_appicon = 1;
1225 } else if (type
== net_wm_window_type_normal
) {
1231 *layer
= getWindowLayer(wwin
);
1238 wNETWMPositionSplash(WWindow
*wwin
, int *x
, int *y
, int width
, int height
)
1240 if (wwin
->type
== net_wm_window_type_splash
) {
1241 WScreen
* scr
= wwin
->screen_ptr
;
1242 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1243 *x
= rect
.pos
.x
+ (rect
.size
.width
- width
)/2;
1244 *y
= rect
.pos
.y
+ (rect
.size
.height
- height
)/2;
1250 updateWindowType(WWindow
* wwin
)
1254 unsigned long nitems_ret
;
1255 unsigned long bytes_after_ret
;
1258 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_window_type
, 0, 1,
1259 False
, XA_ATOM
, &type_ret
, &fmt_ret
, &nitems_ret
,
1260 &bytes_after_ret
, (unsigned char **)&data
)==Success
1264 Atom
* type
= (Atom
*)data
;
1265 for (i
=0; i
<nitems_ret
; ++i
) {
1266 if (handleWindowType(wwin
, type
[i
], &layer
)) break;
1271 ChangeStackingLevel(wwin
->frame
->core
, layer
);
1272 wwin
->frame
->flags
.need_texture_change
= 1;
1273 wWindowConfigureBorders(wwin
);
1274 wFrameWindowPaint(wwin
->frame
);
1275 wNETWMUpdateActions(wwin
, False
);
1280 wNETWMCheckClientHints(WWindow
*wwin
, int *layer
, int *workspace
)
1284 unsigned long nitems_ret
;
1285 unsigned long bytes_after_ret
;
1287 Bool hasState
= False
;
1290 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_desktop
, 0, 1, False
,
1291 XA_CARDINAL
, &type_ret
, &fmt_ret
, &nitems_ret
,
1293 (unsigned char**)&data
)==Success
&& data
) {
1295 long desktop
= *data
;
1299 wwin
->client_flags
.omnipresent
= 1;
1301 *workspace
= desktop
;
1306 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_state
, 0, 1, False
,
1307 XA_ATOM
, &type_ret
, &fmt_ret
, &nitems_ret
,
1309 (unsigned char**)&data
)==Success
&& data
) {
1311 Atom
* state
= (Atom
*)data
;
1312 for(i
=0; i
<nitems_ret
; ++i
) {
1313 doStateAtom(wwin
, state
[i
], _NET_WM_STATE_ADD
, True
);
1319 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_window_type
, 0, 1, False
,
1320 XA_ATOM
, &type_ret
, &fmt_ret
, &nitems_ret
,
1322 (unsigned char **)&data
) == Success
&& data
) {
1324 Atom
* type
= (Atom
*)data
;
1325 for (i
=0; i
<nitems_ret
; ++i
) {
1326 if (handleWindowType(wwin
, type
[i
], layer
)) break;
1332 wNETWMUpdateActions(wwin
, False
);
1333 updateStrut(wwin
, False
);
1334 if (updateStrut(wwin
, True
)) {
1337 wScreenUpdateUsableArea(wwin
->screen_ptr
);
1344 updateNetIconInfo(WWindow
*wwin
) {
1348 unsigned long nitems_ret
;
1349 unsigned long bytes_after_ret
;
1351 Bool hasState
= False
;
1352 Bool old_state
= wwin
->flags
.net_handle_icon
;
1354 if (XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_handled_icons
, 0, 1, False
,
1355 XA_CARDINAL
, &type_ret
, &fmt_ret
, &nitems_ret
,
1356 &bytes_after_ret
, (unsigned char **)&data
) == Success
&& data
) {
1357 long handled
= *data
;
1358 wwin
->flags
.net_handle_icon
= (handled
!= 0);
1362 } else wwin
->flags
.net_handle_icon
= False
;
1364 if ( XGetWindowProperty(dpy
, wwin
->client_win
, net_wm_icon_geometry
, 0, 4, False
,
1365 XA_CARDINAL
, &type_ret
, &fmt_ret
, &nitems_ret
,
1366 &bytes_after_ret
, (unsigned char **)&data
) == Success
&& data
) {
1369 if (wwin
->flags
.net_handle_icon
)
1371 wwin
->flags
.net_handle_icon
= True
;
1374 wwin
->icon_x
= data
[0];
1375 wwin
->icon_y
= data
[1];
1376 wwin
->icon_w
= data
[2];
1377 wwin
->icon_h
= data
[3];
1383 } else wwin
->flags
.net_handle_icon
= False
;
1385 if (wwin
->flags
.miniaturized
&&
1386 old_state
!= wwin
->flags
.net_handle_icon
) {
1387 if (wwin
->flags
.net_handle_icon
) {
1390 wwin
->flags
.miniaturized
= False
;
1391 wwin
->flags
.skip_next_animation
= True
;
1392 wIconifyWindow(wwin
);
1401 wNETWMCheckInitialClientState(WWindow
*wwin
)
1403 Bool hasState
= False
;
1406 printf("CheckInitialClientState\n");
1409 wNETWMShowingDesktop(wwin
->screen_ptr
, False
);
1411 hasState
|= updateNetIconInfo(wwin
);
1413 updateIconImage(wwin
->screen_ptr
, wwin
);
1420 handleDesktopNames(XClientMessageEvent
*event
, WScreen
*scr
)
1422 unsigned long nitems_ret
, bytes_after_ret
;
1423 char *data
, *names
[32];
1427 if (XGetWindowProperty(dpy
, scr
->root_win
, net_desktop_names
, 0, 1, False
,
1428 utf8_string
, &type_ret
, &fmt_ret
, &nitems_ret
,
1430 (unsigned char**)&data
)!=Success
) {
1437 if (type_ret
!= utf8_string
|| fmt_ret
!= 8)
1442 for (i
= 0; i
< nitems_ret
; i
++) {
1445 names
[n
] = &data
[i
];
1446 } else if (*names
[n
] == 0) {
1447 names
[n
] = &data
[i
];
1448 wWorkspaceRename(scr
, n
, names
[n
]);
1455 wNETWMProcessClientMessage(XClientMessageEvent
*event
)
1462 printf("processClientMessage type %s\n", XGetAtomName(dpy
, event
->message_type
));
1465 scr
= wScreenForWindow(event
->window
);
1467 /* generic client messages */
1468 if (event
->message_type
== net_current_desktop
) {
1469 wWorkspaceChange(scr
, event
->data
.l
[0]);
1470 } else if(event
->message_type
== net_number_of_desktops
) {
1473 value
= event
->data
.l
[0];
1474 if(value
> scr
->workspace_count
) {
1475 wWorkspaceMake(scr
, value
- scr
->workspace_count
);
1476 } else if(value
< scr
->workspace_count
) {
1478 Bool rebuild
= False
;
1480 for (i
= scr
->workspace_count
-1; i
>= value
; i
--) {
1481 if (!wWorkspaceDelete(scr
, i
)) {
1488 updateWorkspaceCount(scr
);
1491 } else if (event
->message_type
== net_showing_desktop
) {
1492 wNETWMShowingDesktop(scr
, event
->data
.l
[0]);
1493 #ifdef VIRTUAL_DESKTOP
1494 } else if (event
->message_type
== net_desktop_viewport
) {
1495 wWorkspaceSetViewport(scr
, scr
->current_workspace
,
1496 event
->data
.l
[0], event
->data
.l
[1]);
1498 } else if (event
->message_type
== net_desktop_names
) {
1499 handleDesktopNames(event
, scr
);
1508 /* window specific client messages */
1510 wwin
= wWindowFor(event
->window
);
1514 if (event
->message_type
== net_active_window
) {
1515 wNETWMShowingDesktop(scr
, False
);
1516 wMakeWindowVisible(wwin
);
1517 } else if (event
->message_type
== net_close_window
) {
1518 if (!WFLAGP(wwin
, no_closable
)) {
1519 if (wwin
->protocols
.DELETE_WINDOW
)
1520 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
1522 } else if (event
->message_type
== net_wm_state
) {
1523 int maximized
= wwin
->flags
.maximized
;
1524 long set
= event
->data
.l
[0];
1527 printf("net_wm_state set %d a1 %s a2 %s\n", set
,
1528 XGetAtomName(dpy
, event
->data
.l
[1]),
1529 XGetAtomName(dpy
, event
->data
.l
[2]));
1532 doStateAtom(wwin
, (Atom
)event
->data
.l
[1], set
, False
);
1533 if(event
->data
.l
[2])
1534 doStateAtom(wwin
, (Atom
)event
->data
.l
[2], set
, False
);
1536 if(wwin
->flags
.maximized
!= maximized
) {
1537 if(!wwin
->flags
.maximized
) {
1538 wwin
->flags
.maximized
= maximized
;
1539 wUnmaximizeWindow(wwin
);
1541 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
1544 updateStateHint(wwin
, False
, False
);
1545 } else if (event
->message_type
== net_wm_handled_icons
||
1546 event
->message_type
== net_wm_icon_geometry
) {
1547 updateNetIconInfo(wwin
);
1548 } else if (event
->message_type
== net_wm_desktop
) {
1549 long desktop
= event
->data
.l
[0];
1550 if (desktop
== -1) {
1551 wWindowSetOmnipresent(wwin
, True
);
1553 if (IS_OMNIPRESENT(wwin
))
1554 wWindowSetOmnipresent(wwin
, False
);
1555 wWindowChangeWorkspace(wwin
, desktop
);
1557 } else if (event
->message_type
== net_wm_icon
) {
1558 updateIconImage(scr
, wwin
);
1568 wNETWMCheckClientHintChange(WWindow
*wwin
, XPropertyEvent
*event
)
1572 if(event
->atom
== net_wm_strut
) {
1573 updateStrut(wwin
, False
);
1574 updateStrut(wwin
, True
);
1575 wScreenUpdateUsableArea(wwin
->screen_ptr
);
1576 } else if (event
->atom
== net_wm_handled_icons
||
1577 event
->atom
== net_wm_icon_geometry
) {
1578 updateNetIconInfo(wwin
);
1579 } else if (event
->atom
== net_wm_window_type
) {
1580 updateWindowType(wwin
);
1581 } else if (event
->atom
== net_wm_name
) {
1582 char *name
= wNETWMGetWindowName(wwin
->client_win
);
1583 wWindowUpdateName(wwin
, name
);
1584 if (name
) wfree(name
);
1585 } else if (event
->atom
== net_wm_icon_name
) {
1587 char *name
= wNETWMGetIconName(wwin
->client_win
);
1588 wIconChangeTitle(wwin
->icon
, name
);
1599 wNETWMGetPidForWindow(Window window
)
1603 unsigned long nitems_ret
;
1604 unsigned long bytes_after_ret
;
1608 if (XGetWindowProperty(dpy
, window
, net_wm_pid
, 0, 1, False
,
1609 XA_CARDINAL
, &type_ret
, &fmt_ret
, &nitems_ret
,
1611 (unsigned char**)&data
)==Success
&& data
) {
1624 wNETWMGetWindowName(Window window
)
1630 name
= (char*)PropGetCheckProperty(window
,
1631 net_wm_name
, utf8_string
, 0,
1634 ret
= wstrndup(name
, size
);
1644 wNETWMGetIconName(Window window
)
1650 name
= (char*)PropGetCheckProperty(window
,
1651 net_wm_icon_name
, utf8_string
, 0,
1654 ret
= wstrndup(name
, size
);
1664 observer(void *self
, WMNotification
*notif
)
1666 WWindow
*wwin
= (WWindow
*)WMGetNotificationObject(notif
);
1667 const char *name
= WMGetNotificationName(notif
);
1668 void *data
= WMGetNotificationClientData(notif
);
1669 NetData
*ndata
= (NetData
*)self
;
1672 if (strcmp(name
, WMNManaged
) == 0 && wwin
) {
1673 updateClientList(wwin
->screen_ptr
);
1674 updateClientListStacking(wwin
->screen_ptr
, NULL
);
1675 updateStateHint(wwin
, True
, False
);
1677 updateStrut(wwin
, False
);
1678 updateStrut(wwin
, True
);
1679 wScreenUpdateUsableArea(wwin
->screen_ptr
);
1680 } else if (strcmp(name
, WMNUnmanaged
) == 0 && wwin
) {
1681 updateClientList(wwin
->screen_ptr
);
1682 updateClientListStacking(wwin
->screen_ptr
, wwin
);
1683 updateWorkspaceHint(wwin
, False
, True
);
1684 updateStateHint(wwin
, False
, True
);
1685 wNETWMUpdateActions(wwin
, True
);
1687 updateStrut(wwin
, False
);
1688 wScreenUpdateUsableArea(wwin
->screen_ptr
);
1689 } else if (strcmp(name
, WMNResetStacking
) == 0 && wwin
) {
1690 updateClientListStacking(wwin
->screen_ptr
, NULL
);
1691 updateStateHint(wwin
, False
, False
);
1692 } else if (strcmp(name
, WMNChangedStacking
) == 0 && wwin
) {
1693 updateClientListStacking(wwin
->screen_ptr
, NULL
);
1694 updateStateHint(wwin
, False
, False
);
1695 } else if (strcmp(name
, WMNChangedFocus
) == 0) {
1696 updateFocusHint(ndata
->scr
, wwin
);
1697 } else if (strcmp(name
, WMNChangedWorkspace
) == 0 && wwin
) {
1698 updateWorkspaceHint(wwin
, False
, False
);
1699 updateStateHint(wwin
, True
, False
);
1700 } else if (strcmp(name
, WMNChangedState
) == 0 && wwin
) {
1701 updateStateHint(wwin
, !strcmp(data
, "omnipresent"), False
);
1707 wsobserver(void *self
, WMNotification
*notif
)
1709 WScreen
*scr
= (WScreen
*)WMGetNotificationObject(notif
);
1710 const char *name
= WMGetNotificationName(notif
);
1712 if (strcmp(name
, WMNWorkspaceCreated
) == 0) {
1713 updateWorkspaceCount(scr
);
1714 updateWorkspaceNames(scr
);
1715 } else if (strcmp(name
, WMNWorkspaceDestroyed
) == 0) {
1716 updateWorkspaceCount(scr
);
1717 updateWorkspaceNames(scr
);
1718 } else if (strcmp(name
, WMNWorkspaceChanged
) == 0) {
1719 updateCurrentWorkspace(scr
);
1720 } else if (strcmp(name
, WMNWorkspaceNameChanged
) == 0) {
1721 updateWorkspaceNames(scr
);
1725 #endif /* NETWM_HINTS */