1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 client.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
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 See the COPYING file for a copy of the GNU General Public License.
22 #include "startupnotify.h"
25 #include "moveresize.h"
39 #include "menuframe.h"
42 #include "render/render.h"
44 #include "obt/display.h"
52 # include <signal.h> /* for kill() */
56 #include <X11/Xutil.h>
58 /*! The event mask to grab on client windows */
59 #define CLIENT_EVENTMASK (PropertyChangeMask | StructureNotifyMask | \
62 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
67 ObClientCallback func
;
71 GList
*client_list
= NULL
;
73 static GSList
*client_destroy_notifies
= NULL
;
74 static RrImage
*client_default_icon
= NULL
;
76 static void client_get_all(ObClient
*self
, gboolean real
);
77 static void client_get_startup_id(ObClient
*self
);
78 static void client_get_session_ids(ObClient
*self
);
79 static void client_get_area(ObClient
*self
);
80 static void client_get_desktop(ObClient
*self
);
81 static void client_get_state(ObClient
*self
);
82 static void client_get_shaped(ObClient
*self
);
83 static void client_get_mwm_hints(ObClient
*self
);
84 static void client_get_colormap(ObClient
*self
);
85 static void client_set_desktop_recursive(ObClient
*self
,
89 static void client_change_allowed_actions(ObClient
*self
);
90 static void client_change_state(ObClient
*self
);
91 static void client_change_wm_state(ObClient
*self
);
92 static void client_apply_startup_state(ObClient
*self
,
93 gint x
, gint y
, gint w
, gint h
);
94 static void client_restore_session_state(ObClient
*self
);
95 static gboolean
client_restore_session_stacking(ObClient
*self
);
96 static ObAppSettings
*client_get_settings_state(ObClient
*self
);
97 static void client_update_transient_tree(ObClient
*self
,
98 ObGroup
*oldgroup
, ObGroup
*newgroup
,
99 gboolean oldgtran
, gboolean newgtran
,
101 ObClient
*newparent
);
102 static void client_present(ObClient
*self
, gboolean here
, gboolean raise
,
104 static GSList
*client_search_all_top_parents_internal(ObClient
*self
,
106 ObStackingLayer layer
);
107 static void client_call_notifies(ObClient
*self
, GSList
*list
);
108 static void client_ping_event(ObClient
*self
, gboolean dead
);
109 static void client_prompt_kill(ObClient
*self
);
111 void client_startup(gboolean reconfig
)
113 if ((client_default_icon
= RrImageCacheFind(ob_rr_icons
,
114 ob_rr_theme
->def_win_icon
,
115 ob_rr_theme
->def_win_icon_w
,
116 ob_rr_theme
->def_win_icon_h
)))
117 RrImageRef(client_default_icon
);
119 client_default_icon
= RrImageNew(ob_rr_icons
);
120 RrImageAddPicture(client_default_icon
,
121 ob_rr_theme
->def_win_icon
,
122 ob_rr_theme
->def_win_icon_w
,
123 ob_rr_theme
->def_win_icon_h
);
126 if (reconfig
) return;
131 void client_shutdown(gboolean reconfig
)
133 RrImageUnref(client_default_icon
);
134 client_default_icon
= NULL
;
136 if (reconfig
) return;
139 static void client_call_notifies(ObClient
*self
, GSList
*list
)
143 for (it
= list
; it
; it
= g_slist_next(it
)) {
144 ClientCallback
*d
= it
->data
;
145 d
->func(self
, d
->data
);
149 void client_add_destroy_notify(ObClientCallback func
, gpointer data
)
151 ClientCallback
*d
= g_new(ClientCallback
, 1);
154 client_destroy_notifies
= g_slist_prepend(client_destroy_notifies
, d
);
157 void client_remove_destroy_notify(ObClientCallback func
)
161 for (it
= client_destroy_notifies
; it
; it
= g_slist_next(it
)) {
162 ClientCallback
*d
= it
->data
;
163 if (d
->func
== func
) {
165 client_destroy_notifies
=
166 g_slist_delete_link(client_destroy_notifies
, it
);
172 void client_set_list(void)
174 Window
*windows
, *win_it
;
176 guint size
= g_list_length(client_list
);
178 /* create an array of the window ids */
180 windows
= g_new(Window
, size
);
182 for (it
= client_list
; it
; it
= g_list_next(it
), ++win_it
)
183 *win_it
= ((ObClient
*)it
->data
)->window
;
187 OBT_PROP_SETA32(obt_root(ob_screen
), NET_CLIENT_LIST
, WINDOW
,
188 (gulong
*)windows
, size
);
196 void client_manage(Window window
, ObPrompt
*prompt
)
199 XSetWindowAttributes attrib_set
;
200 gboolean activate
= FALSE
;
201 ObAppSettings
*settings
;
202 gboolean transient
= FALSE
;
203 Rect place
, *monitor
;
204 Time launch_time
, map_time
;
207 ob_debug("Managing window: 0x%lx", window
);
209 map_time
= event_get_server_time();
211 /* choose the events we want to receive on the CLIENT window
212 (ObPrompt windows can request events too) */
213 attrib_set
.event_mask
= CLIENT_EVENTMASK
|
214 (prompt
? prompt
->event_mask
: 0);
215 attrib_set
.do_not_propagate_mask
= CLIENT_NOPROPAGATEMASK
;
216 XChangeWindowAttributes(obt_display
, window
,
217 CWEventMask
|CWDontPropagate
, &attrib_set
);
219 /* create the ObClient struct, and populate it from the hints on the
221 self
= g_new0(ObClient
, 1);
222 self
->obwin
.type
= OB_WINDOW_CLASS_CLIENT
;
223 self
->window
= window
;
224 self
->prompt
= prompt
;
226 /* non-zero defaults */
227 self
->wmstate
= WithdrawnState
; /* make sure it gets updated first time */
228 self
->gravity
= NorthWestGravity
;
229 self
->desktop
= screen_num_desktops
; /* always an invalid value */
231 /* get all the stuff off the window */
232 client_get_all(self
, TRUE
);
234 ob_debug("Window type: %d", self
->type
);
235 ob_debug("Window group: 0x%x", self
->group
?self
->group
->leader
:0);
236 ob_debug("Window name: %s class: %s role: %s", self
->name
, self
->class, self
->role
);
238 /* per-app settings override stuff from client_get_all, and return the
239 settings for other uses too. the returned settings is a shallow copy,
240 that needs to be freed with g_free(). */
241 settings
= client_get_settings_state(self
);
243 /* now we have all of the window's information so we can set this up.
244 do this before creating the frame, so it can tell that we are still
245 mapping and doesn't go applying things right away */
246 client_setup_decor_and_functions(self
, FALSE
);
248 /* specify that if we exit, the window should not be destroyed and
249 should be reparented back to root automatically, unless we are managing
250 an internal ObPrompt window */
252 XChangeSaveSet(obt_display
, window
, SetModeInsert
);
254 /* create the decoration frame for the client window */
255 self
->frame
= frame_new(self
);
257 frame_grab_client(self
->frame
);
259 /* we've grabbed everything and set everything that we need to at mapping
263 /* the session should get the last say though */
264 client_restore_session_state(self
);
266 /* tell startup notification that this app started */
267 launch_time
= sn_app_started(self
->startup_id
, self
->class, self
->name
);
269 if (!OBT_PROP_GET32(self
->window
, NET_WM_USER_TIME
, CARDINAL
, &user_time
))
270 user_time
= map_time
;
272 /* do this after we have a frame.. it uses the frame to help determine the
273 WM_STATE to apply. */
274 client_change_state(self
);
276 /* add ourselves to the focus order */
277 focus_order_add_new(self
);
279 /* do this to add ourselves to the stacking list in a non-intrusive way */
280 client_calc_layer(self
);
282 /* focus the new window? */
283 if (ob_state() != OB_STATE_STARTING
&&
284 (!self
->session
|| self
->session
->focused
) &&
285 /* this means focus=true for window is same as config_focus_new=true */
286 ((config_focus_new
|| (settings
&& settings
->focus
== 1)) ||
287 client_search_focus_tree_full(self
)) &&
288 /* NET_WM_USER_TIME 0 when mapping means don't focus */
290 /* this checks for focus=false for the window */
291 (!settings
|| settings
->focus
!= 0) &&
292 focus_valid_target(self
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
))
297 /* remove the client's border */
298 XSetWindowBorderWidth(obt_display
, self
->window
, 0);
300 /* adjust the frame to the client's size before showing or placing
302 frame_adjust_area(self
->frame
, FALSE
, TRUE
, FALSE
);
303 frame_adjust_client_area(self
->frame
);
305 /* where the frame was placed is where the window was originally */
307 monitor
= screen_physical_area_monitor(screen_find_monitor(&place
));
309 /* figure out placement for the window if the window is new */
310 if (ob_state() == OB_STATE_RUNNING
) {
311 ob_debug("Positioned: %s @ %d %d",
312 (!self
->positioned
? "no" :
313 (self
->positioned
== PPosition
? "program specified" :
314 (self
->positioned
== USPosition
? "user specified" :
315 (self
->positioned
== (PPosition
| USPosition
) ?
316 "program + user specified" :
317 "BADNESS !?")))), place
.x
, place
.y
);
319 ob_debug("Sized: %s @ %d %d",
320 (!self
->sized
? "no" :
321 (self
->sized
== PSize
? "program specified" :
322 (self
->sized
== USSize
? "user specified" :
323 (self
->sized
== (PSize
| USSize
) ?
324 "program + user specified" :
325 "BADNESS !?")))), place
.width
, place
.height
);
327 /* splash screens are also returned as TRUE for transient,
328 and so will be forced on screen below */
329 transient
= place_client(self
, &place
.x
, &place
.y
, settings
);
331 /* make sure the window is visible. */
332 client_find_onscreen(self
, &place
.x
, &place
.y
,
333 place
.width
, place
.height
,
334 /* non-normal clients has less rules, and
335 windows that are being restored from a
336 session do also. we can assume you want
337 it back where you saved it. Clients saying
338 they placed themselves are subjected to
339 harder rules, ones that are placed by
340 place.c or by the user are allowed partially
341 off-screen and on xinerama divides (ie,
342 it is up to the placement routines to avoid
343 the xinerama divides)
345 splash screens get "transient" set to TRUE by
346 the place_client call
348 ob_state() == OB_STATE_RUNNING
&&
350 (!((self
->positioned
& USPosition
) ||
351 (settings
&& settings
->pos_given
)) &&
352 client_normal(self
) &&
354 /* don't move oldschool fullscreen windows to
355 fit inside the struts (fixes Acroread, which
356 makes its fullscreen window fit the screen
357 but it is not USSize'd or USPosition'd) */
358 !(self
->decorations
== 0 &&
359 RECT_EQUAL(place
, *monitor
)))));
362 /* if the window isn't user-sized, then make it fit inside
363 the visible screen area on its monitor. Use basically the same rules
364 for forcing the window on screen in the client_find_onscreen call.
366 do this after place_client, it chooses the monitor!
368 splash screens get "transient" set to TRUE by
369 the place_client call
371 if (ob_state() == OB_STATE_RUNNING
&&
373 (!(self
->sized
& USSize
|| self
->positioned
& USPosition
) &&
374 client_normal(self
) &&
376 /* don't shrink oldschool fullscreen windows to fit inside the
377 struts (fixes Acroread, which makes its fullscreen window
378 fit the screen but it is not USSize'd or USPosition'd) */
379 !(self
->decorations
== 0 && RECT_EQUAL(place
, *monitor
)))))
381 Rect
*a
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
, &place
);
383 /* get the size of the frame */
384 place
.width
+= self
->frame
->size
.left
+ self
->frame
->size
.right
;
385 place
.height
+= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
387 /* fit the window inside the area */
388 place
.width
= MIN(place
.width
, a
->width
);
389 place
.height
= MIN(place
.height
, a
->height
);
391 ob_debug("setting window size to %dx%d", place
.width
, place
.height
);
393 /* get the size of the client back */
394 place
.width
-= self
->frame
->size
.left
+ self
->frame
->size
.right
;
395 place
.height
-= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
400 ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
401 "some restrictions may apply",
402 self
->window
, place
.x
, place
.y
, place
.width
, place
.height
);
404 ob_debug(" but session requested %d, %d %d x %d instead, "
406 self
->session
->x
, self
->session
->y
,
407 self
->session
->w
, self
->session
->h
);
409 /* do this after the window is placed, so the premax/prefullscreen numbers
412 this also places the window
414 client_apply_startup_state(self
, place
.x
, place
.y
,
415 place
.width
, place
.height
);
420 ob_debug_type(OB_DEBUG_FOCUS
, "Going to try activate new window? %s",
421 activate
? "yes" : "no");
423 gboolean raise
= FALSE
;
424 gboolean relative_focused
;
425 gboolean parent_focused
;
427 parent_focused
= (focus_client
!= NULL
&&
428 client_search_focus_parent(self
));
429 relative_focused
= (focus_client
!= NULL
&&
430 (client_search_focus_tree_full(self
) != NULL
||
431 client_search_focus_group_full(self
) != NULL
));
433 /* This is focus stealing prevention */
434 ob_debug_type(OB_DEBUG_FOCUS
,
435 "Want to focus new window 0x%x at time %u "
436 "launched at %u (last user interaction time %u)",
437 self
->window
, map_time
, launch_time
,
438 event_last_user_time
);
439 ob_debug_type(OB_DEBUG_FOCUS
,
440 "Current focus_client: %s",
441 (focus_client
? focus_client
->title
: "(none)"));
442 ob_debug_type(OB_DEBUG_FOCUS
,
443 "parent focused: %d relative focused: %d",
444 parent_focused
, relative_focused
);
446 if (menu_frame_visible
|| moveresize_in_progress
) {
449 ob_debug_type(OB_DEBUG_FOCUS
,
450 "Not focusing the window because the user is inside "
451 "an Openbox menu or is move/resizing a window and "
452 "we don't want to interrupt them");
455 /* if it's on another desktop */
456 else if (!(self
->desktop
== screen_desktop
||
457 self
->desktop
== DESKTOP_ALL
) &&
458 /* the timestamp is from before you changed desktops */
459 launch_time
&& screen_desktop_user_time
&&
460 !event_time_after(launch_time
, screen_desktop_user_time
))
464 ob_debug_type(OB_DEBUG_FOCUS
,
465 "Not focusing the window because its on another "
468 /* If something is focused... */
469 else if (focus_client
) {
470 /* If the user is working in another window right now, then don't
472 if (!parent_focused
&&
473 event_last_user_time
&& launch_time
&&
474 event_time_after(event_last_user_time
, launch_time
) &&
475 event_last_user_time
!= launch_time
&&
476 event_time_after(event_last_user_time
,
477 map_time
- OB_EVENT_USER_TIME_DELAY
))
480 ob_debug_type(OB_DEBUG_FOCUS
,
481 "Not focusing the window because the user is "
482 "working in another window that is not "
485 /* If the new window is a transient (and its relatives aren't
487 else if (client_has_parent(self
) && !relative_focused
) {
489 ob_debug_type(OB_DEBUG_FOCUS
,
490 "Not focusing the window because it is a "
491 "transient, and its relatives aren't focused");
493 /* Don't steal focus from globally active clients.
494 I stole this idea from KWin. It seems nice.
496 else if (!(focus_client
->can_focus
||
497 focus_client
->focus_notify
))
500 ob_debug_type(OB_DEBUG_FOCUS
,
501 "Not focusing the window because a globally "
502 "active client has focus");
504 /* Don't move focus if it's not going to go to this window
506 else if (client_focus_target(self
) != self
) {
509 ob_debug_type(OB_DEBUG_FOCUS
,
510 "Not focusing the window because another window "
511 "would get the focus anyway");
513 /* Don't move focus if the window is not visible on the current
514 desktop and none of its relatives are focused */
515 else if (!(self
->desktop
== screen_desktop
||
516 self
->desktop
== DESKTOP_ALL
) &&
521 ob_debug_type(OB_DEBUG_FOCUS
,
522 "Not focusing the window because it is on "
523 "another desktop and no relatives are focused ");
528 ob_debug_type(OB_DEBUG_FOCUS
,
529 "Focus stealing prevention activated for %s at "
530 "time %u (last user interaction time %u)",
531 self
->title
, map_time
, event_last_user_time
);
532 /* if the client isn't focused, then hilite it so the user
534 client_hilite(self
, TRUE
);
535 /* we may want to raise it even tho we're not activating it */
536 if (raise
&& !client_restore_session_stacking(self
))
537 stacking_raise(CLIENT_AS_WINDOW(self
));
541 /* This may look rather odd. Well it's because new windows are added
542 to the stacking order non-intrusively. If we're not going to focus
543 the new window or hilite it, then we raise it to the top. This will
544 take affect for things that don't get focused like splash screens.
545 Also if you don't have focus_new enabled, then it's going to get
546 raised to the top. Legacy begets legacy I guess?
548 if (!client_restore_session_stacking(self
))
549 stacking_raise(CLIENT_AS_WINDOW(self
));
552 mouse_grab_for_client(self
, TRUE
);
554 /* this has to happen before we try focus the window, but we want it to
555 happen after the client's stacking has been determined or it looks bad
559 if (!config_focus_under_mouse
)
560 ignore_start
= event_start_ignore_all_enters();
564 if (!config_focus_under_mouse
)
565 event_end_ignore_all_enters(ignore_start
);
569 gboolean stacked
= client_restore_session_stacking(self
);
570 client_present(self
, FALSE
, !stacked
, TRUE
);
573 /* add to client list/map */
574 client_list
= g_list_append(client_list
, self
);
575 window_add(&self
->window
, CLIENT_AS_WINDOW(self
));
577 /* this has to happen after we're in the client_list */
578 if (STRUT_EXISTS(self
->strut
))
579 screen_update_areas();
581 /* update the list hints */
584 /* free the ObAppSettings shallow copy */
587 ob_debug("Managed window 0x%lx plate 0x%x (%s)",
588 window
, self
->frame
->window
, self
->class);
590 hooks_queue(OB_HOOK_WIN_NEW
, self
);
593 ObClient
*client_fake_manage(Window window
)
596 ObAppSettings
*settings
;
598 ob_debug("Pretend-managing window: %lx", window
);
600 /* do this minimal stuff to figure out the client's decorations */
602 self
= g_new0(ObClient
, 1);
603 self
->window
= window
;
605 client_get_all(self
, FALSE
);
606 /* per-app settings override stuff, and return the settings for other
607 uses too. this returns a shallow copy that needs to be freed */
608 settings
= client_get_settings_state(self
);
610 client_setup_decor_and_functions(self
, FALSE
);
612 /* create the decoration frame for the client window and adjust its size */
613 self
->frame
= frame_new(self
);
614 frame_adjust_area(self
->frame
, FALSE
, TRUE
, TRUE
);
616 ob_debug("gave extents left %d right %d top %d bottom %d",
617 self
->frame
->size
.left
, self
->frame
->size
.right
,
618 self
->frame
->size
.top
, self
->frame
->size
.bottom
);
620 /* free the ObAppSettings shallow copy */
626 void client_unmanage_all(void)
629 client_unmanage(client_list
->data
);
632 void client_unmanage(ObClient
*self
)
637 ob_debug("Unmanaging window: 0x%x plate 0x%x (%s) (%s)",
638 self
->window
, self
->frame
->window
,
639 self
->class, self
->title
? self
->title
: "");
641 g_assert(self
!= NULL
);
643 /* we dont want events no more. do this before hiding the frame so we
644 don't generate more events */
645 XSelectInput(obt_display
, self
->window
, NoEventMask
);
647 /* ignore enter events from the unmap so it doesnt mess with the focus */
648 if (!config_focus_under_mouse
)
649 ignore_start
= event_start_ignore_all_enters();
651 frame_hide(self
->frame
);
652 /* flush to send the hide to the server quickly */
655 if (!config_focus_under_mouse
)
656 event_end_ignore_all_enters(ignore_start
);
658 mouse_grab_for_client(self
, FALSE
);
660 /* remove the window from our save set, unless we are managing an internal
663 XChangeSaveSet(obt_display
, self
->window
, SetModeDelete
);
665 /* this can't be queued to run later */
666 hooks_run(OB_HOOK_WIN_CLOSE
, self
);
668 /* update the focus lists */
669 focus_order_remove(self
);
670 if (client_focused(self
)) {
671 /* don't leave an invalid focus_client */
675 /* if we're prompting to kill the client, close that */
676 prompt_unref(self
->kill_prompt
);
677 self
->kill_prompt
= NULL
;
679 client_list
= g_list_remove(client_list
, self
);
680 stacking_remove(self
);
681 window_remove(self
->window
);
683 /* once the client is out of the list, update the struts to remove its
685 if (STRUT_EXISTS(self
->strut
))
686 screen_update_areas();
688 client_call_notifies(self
, client_destroy_notifies
);
690 /* tell our parent(s) that we're gone */
691 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
692 ((ObClient
*)it
->data
)->transients
=
693 g_slist_remove(((ObClient
*)it
->data
)->transients
,self
);
695 /* tell our transients that we're gone */
696 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
697 ((ObClient
*)it
->data
)->parents
=
698 g_slist_remove(((ObClient
*)it
->data
)->parents
, self
);
699 /* we could be keeping our children in a higher layer */
700 client_calc_layer(it
->data
);
703 /* remove from its group */
705 group_remove(self
->group
, self
);
709 /* restore the window's original geometry so it is not lost */
715 if (self
->fullscreen
)
716 a
= self
->pre_fullscreen_area
;
717 else if (self
->max_horz
|| self
->max_vert
) {
718 if (self
->max_horz
) {
719 a
.x
= self
->pre_max_area
.x
;
720 a
.width
= self
->pre_max_area
.width
;
722 if (self
->max_vert
) {
723 a
.y
= self
->pre_max_area
.y
;
724 a
.height
= self
->pre_max_area
.height
;
728 self
->fullscreen
= self
->max_horz
= self
->max_vert
= FALSE
;
729 /* let it be moved and resized no matter what */
730 self
->functions
= OB_CLIENT_FUNC_MOVE
| OB_CLIENT_FUNC_RESIZE
;
731 self
->decorations
= 0; /* unmanaged windows have no decor */
733 /* give the client its border back */
734 XSetWindowBorderWidth(obt_display
, self
->window
, self
->border_width
);
736 client_move_resize(self
, a
.x
, a
.y
, a
.width
, a
.height
);
739 /* reparent the window out of the frame, and free the frame */
740 frame_release_client(self
->frame
);
741 frame_free(self
->frame
);
744 if (ob_state() != OB_STATE_EXITING
) {
745 /* these values should not be persisted across a window
747 OBT_PROP_ERASE(self
->window
, NET_WM_DESKTOP
);
748 OBT_PROP_ERASE(self
->window
, NET_WM_STATE
);
749 OBT_PROP_ERASE(self
->window
, WM_STATE
);
751 /* if we're left in an unmapped state, the client wont be mapped.
752 this is bad, since we will no longer be managing the window on
754 XMapWindow(obt_display
, self
->window
);
757 /* these should not be left on the window ever. other window managers
758 don't necessarily use them and it will mess them up (like compiz) */
759 OBT_PROP_ERASE(self
->window
, NET_WM_VISIBLE_NAME
);
760 OBT_PROP_ERASE(self
->window
, NET_WM_VISIBLE_ICON_NAME
);
762 /* update the list hints */
765 ob_debug("Unmanaged window 0x%lx", self
->window
);
767 /* free all data allocated in the client struct */
768 RrImageUnref(self
->icon_set
);
769 g_slist_free(self
->transients
);
770 g_free(self
->startup_id
);
771 g_free(self
->wm_command
);
773 g_free(self
->icon_title
);
774 g_free(self
->original_title
);
778 g_free(self
->client_machine
);
779 g_free(self
->sm_client_id
);
783 void client_fake_unmanage(ObClient
*self
)
785 /* this is all that got allocated to get the decorations */
787 frame_free(self
->frame
);
791 /*! Returns a new structure containing the per-app settings for this client.
792 The returned structure needs to be freed with g_free. */
793 static ObAppSettings
*client_get_settings_state(ObClient
*self
)
795 ObAppSettings
*settings
;
798 settings
= config_create_app_settings();
800 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
801 ObAppSettings
*app
= it
->data
;
802 gboolean match
= TRUE
;
804 g_assert(app
->name
!= NULL
|| app
->class != NULL
);
806 /* we know that either name or class is not NULL so it will have to
807 match to use the rule */
809 !g_pattern_match(app
->name
, strlen(self
->name
), self
->name
, NULL
))
811 else if (app
->class &&
812 !g_pattern_match(app
->class,
813 strlen(self
->class), self
->class, NULL
))
815 else if (app
->role
&&
816 !g_pattern_match(app
->role
,
817 strlen(self
->role
), self
->role
, NULL
))
819 else if ((signed)app
->type
>= 0 && app
->type
!= self
->type
)
823 ob_debug("Window matching: %s", app
->name
);
825 /* copy the settings to our struct, overriding the existing
826 settings if they are not defaults */
827 config_app_settings_copy_non_defaults(app
, settings
);
831 if (settings
->shade
!= -1)
832 self
->shaded
= !!settings
->shade
;
833 if (settings
->decor
!= -1)
834 self
->undecorated
= !settings
->decor
;
835 if (settings
->iconic
!= -1)
836 self
->iconic
= !!settings
->iconic
;
837 if (settings
->skip_pager
!= -1)
838 self
->skip_pager
= !!settings
->skip_pager
;
839 if (settings
->skip_taskbar
!= -1)
840 self
->skip_taskbar
= !!settings
->skip_taskbar
;
842 if (settings
->max_vert
!= -1)
843 self
->max_vert
= !!settings
->max_vert
;
844 if (settings
->max_horz
!= -1)
845 self
->max_horz
= !!settings
->max_horz
;
847 if (settings
->fullscreen
!= -1)
848 self
->fullscreen
= !!settings
->fullscreen
;
850 if (settings
->desktop
) {
851 if (settings
->desktop
== DESKTOP_ALL
)
852 self
->desktop
= settings
->desktop
;
853 else if (settings
->desktop
> 0 &&
854 settings
->desktop
<= screen_num_desktops
)
855 self
->desktop
= settings
->desktop
- 1;
858 if (settings
->layer
== -1) {
862 else if (settings
->layer
== 0) {
866 else if (settings
->layer
== 1) {
873 static void client_restore_session_state(ObClient
*self
)
877 ob_debug_type(OB_DEBUG_SM
,
878 "Restore session for client %s", self
->title
);
880 if (!(it
= session_state_find(self
))) {
881 ob_debug_type(OB_DEBUG_SM
,
882 "Session data not found for client %s", self
->title
);
886 self
->session
= it
->data
;
888 ob_debug_type(OB_DEBUG_SM
, "Session data loaded for client %s",
891 RECT_SET_POINT(self
->area
, self
->session
->x
, self
->session
->y
);
892 self
->positioned
= USPosition
;
893 self
->sized
= USSize
;
894 if (self
->session
->w
> 0)
895 self
->area
.width
= self
->session
->w
;
896 if (self
->session
->h
> 0)
897 self
->area
.height
= self
->session
->h
;
898 XResizeWindow(obt_display
, self
->window
,
899 self
->area
.width
, self
->area
.height
);
901 self
->desktop
= (self
->session
->desktop
== DESKTOP_ALL
?
902 self
->session
->desktop
:
903 MIN(screen_num_desktops
- 1, self
->session
->desktop
));
904 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, self
->desktop
);
906 self
->shaded
= self
->session
->shaded
;
907 self
->iconic
= self
->session
->iconic
;
908 self
->skip_pager
= self
->session
->skip_pager
;
909 self
->skip_taskbar
= self
->session
->skip_taskbar
;
910 self
->fullscreen
= self
->session
->fullscreen
;
911 self
->above
= self
->session
->above
;
912 self
->below
= self
->session
->below
;
913 self
->max_horz
= self
->session
->max_horz
;
914 self
->max_vert
= self
->session
->max_vert
;
915 self
->undecorated
= self
->session
->undecorated
;
918 static gboolean
client_restore_session_stacking(ObClient
*self
)
922 if (!self
->session
) return FALSE
;
924 mypos
= g_list_find(session_saved_state
, self
->session
);
925 if (!mypos
) return FALSE
;
927 /* start above me and look for the first client */
928 for (it
= g_list_previous(mypos
); it
; it
= g_list_previous(it
)) {
931 for (cit
= client_list
; cit
; cit
= g_list_next(cit
)) {
932 ObClient
*c
= cit
->data
;
933 /* found a client that was in the session, so go below it */
934 if (c
->session
== it
->data
) {
935 stacking_below(CLIENT_AS_WINDOW(self
),
936 CLIENT_AS_WINDOW(cit
->data
));
944 void client_move_onscreen(ObClient
*self
, gboolean rude
)
946 gint x
= self
->area
.x
;
947 gint y
= self
->area
.y
;
948 if (client_find_onscreen(self
, &x
, &y
,
950 self
->area
.height
, rude
)) {
951 client_move(self
, x
, y
);
955 gboolean
client_find_onscreen(ObClient
*self
, gint
*x
, gint
*y
, gint w
, gint h
,
958 gint ox
= *x
, oy
= *y
;
959 gboolean rudel
= rude
, ruder
= rude
, rudet
= rude
, rudeb
= rude
;
965 RECT_SET(desired
, *x
, *y
, w
, h
);
966 frame_rect_to_frame(self
->frame
, &desired
);
968 /* get where the frame would be */
969 frame_client_gravity(self
->frame
, x
, y
);
971 /* get the requested size of the window with decorations */
972 fw
= self
->frame
->size
.left
+ w
+ self
->frame
->size
.right
;
973 fh
= self
->frame
->size
.top
+ h
+ self
->frame
->size
.bottom
;
975 /* If rudeness wasn't requested, then still be rude in a given direction
976 if the client is not moving, only resizing in that direction */
978 Point oldtl
, oldtr
, oldbl
, oldbr
;
979 Point newtl
, newtr
, newbl
, newbr
;
980 gboolean stationary_l
, stationary_r
, stationary_t
, stationary_b
;
982 POINT_SET(oldtl
, self
->frame
->area
.x
, self
->frame
->area
.y
);
983 POINT_SET(oldbr
, self
->frame
->area
.x
+ self
->frame
->area
.width
- 1,
984 self
->frame
->area
.y
+ self
->frame
->area
.height
- 1);
985 POINT_SET(oldtr
, oldbr
.x
, oldtl
.y
);
986 POINT_SET(oldbl
, oldtl
.x
, oldbr
.y
);
988 POINT_SET(newtl
, *x
, *y
);
989 POINT_SET(newbr
, *x
+ fw
- 1, *y
+ fh
- 1);
990 POINT_SET(newtr
, newbr
.x
, newtl
.y
);
991 POINT_SET(newbl
, newtl
.x
, newbr
.y
);
993 /* is it moving or just resizing from some corner? */
994 stationary_l
= oldtl
.x
== newtl
.x
;
995 stationary_r
= oldtr
.x
== newtr
.x
;
996 stationary_t
= oldtl
.y
== newtl
.y
;
997 stationary_b
= oldbl
.y
== newbl
.y
;
999 /* if left edge is growing and didnt move right edge */
1000 if (stationary_r
&& newtl
.x
< oldtl
.x
)
1002 /* if right edge is growing and didnt move left edge */
1003 if (stationary_l
&& newtr
.x
> oldtr
.x
)
1005 /* if top edge is growing and didnt move bottom edge */
1006 if (stationary_b
&& newtl
.y
< oldtl
.y
)
1008 /* if bottom edge is growing and didnt move top edge */
1009 if (stationary_t
&& newbl
.y
> oldbl
.y
)
1013 /* we iterate through every monitor that the window is at least partially
1014 on, to make sure it is obeying the rules on them all
1016 if the window does not appear on any monitors, then use the first one
1019 for (i
= 0; i
< screen_num_monitors
; ++i
) {
1022 if (!screen_physical_area_monitor_contains(i
, &desired
)) {
1023 if (i
< screen_num_monitors
- 1 || found_mon
)
1026 /* the window is not inside any monitor! so just use the first
1028 a
= screen_area(self
->desktop
, 0, NULL
);
1031 a
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
, &desired
);
1034 /* This makes sure windows aren't entirely outside of the screen so you
1035 can't see them at all.
1036 It makes sure 10% of the window is on the screen at least. And don't
1037 let it move itself off the top of the screen, which would hide the
1038 titlebar on you. (The user can still do this if they want too, it's
1039 only limiting the application.
1041 if (client_normal(self
)) {
1042 if (!self
->strut
.right
&& *x
+ fw
/10 >= a
->x
+ a
->width
- 1)
1043 *x
= a
->x
+ a
->width
- fw
/10;
1044 if (!self
->strut
.bottom
&& *y
+ fh
/10 >= a
->y
+ a
->height
- 1)
1045 *y
= a
->y
+ a
->height
- fh
/10;
1046 if (!self
->strut
.left
&& *x
+ fw
*9/10 - 1 < a
->x
)
1047 *x
= a
->x
- fw
*9/10;
1048 if (!self
->strut
.top
&& *y
+ fh
*9/10 - 1 < a
->y
)
1049 *y
= a
->y
- fh
*9/10;
1052 /* This here doesn't let windows even a pixel outside the
1053 struts/screen. When called from client_manage, programs placing
1054 themselves are forced completely onscreen, while things like
1055 xterm -geometry resolution-width/2 will work fine. Trying to
1056 place it completely offscreen will be handled in the above code.
1057 Sorry for this confused comment, i am tired. */
1058 if (rudel
&& !self
->strut
.left
&& *x
< a
->x
) *x
= a
->x
;
1059 if (ruder
&& !self
->strut
.right
&& *x
+ fw
> a
->x
+ a
->width
)
1060 *x
= a
->x
+ MAX(0, a
->width
- fw
);
1062 if (rudet
&& !self
->strut
.top
&& *y
< a
->y
) *y
= a
->y
;
1063 if (rudeb
&& !self
->strut
.bottom
&& *y
+ fh
> a
->y
+ a
->height
)
1064 *y
= a
->y
+ MAX(0, a
->height
- fh
);
1069 /* get where the client should be */
1070 frame_frame_gravity(self
->frame
, x
, y
);
1072 return ox
!= *x
|| oy
!= *y
;
1075 static void client_get_all(ObClient
*self
, gboolean real
)
1077 /* this is needed for the frame to set itself up */
1078 client_get_area(self
);
1080 /* these things can change the decor and functions of the window */
1082 client_get_mwm_hints(self
);
1083 /* this can change the mwmhints for special cases */
1084 client_get_type_and_transientness(self
);
1085 client_get_state(self
);
1086 client_update_normal_hints(self
);
1088 /* get the session related properties, these can change decorations
1089 from per-app settings */
1090 client_get_session_ids(self
);
1092 /* now we got everything that can affect the decorations */
1096 /* get this early so we have it for debugging */
1097 client_update_title(self
);
1099 client_update_protocols(self
);
1101 client_update_wmhints(self
);
1102 /* this may have already been called from client_update_wmhints */
1103 if (!self
->parents
&& !self
->transient_for_group
)
1104 client_update_transient_for(self
);
1106 client_get_startup_id(self
);
1107 client_get_desktop(self
);/* uses transient data/group/startup id if a
1108 desktop is not specified */
1109 client_get_shaped(self
);
1112 /* a couple type-based defaults for new windows */
1114 /* this makes sure that these windows appear on all desktops */
1115 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
1116 self
->desktop
= DESKTOP_ALL
;
1120 client_update_sync_request_counter(self
);
1123 client_get_colormap(self
);
1124 client_update_strut(self
);
1125 client_update_icons(self
);
1126 client_update_icon_geometry(self
);
1129 static void client_get_startup_id(ObClient
*self
)
1131 if (!(OBT_PROP_GETS(self
->window
, NET_STARTUP_ID
, utf8
,
1132 &self
->startup_id
)))
1134 OBT_PROP_GETS(self
->group
->leader
,
1135 NET_STARTUP_ID
, utf8
, &self
->startup_id
);
1138 static void client_get_area(ObClient
*self
)
1140 XWindowAttributes wattrib
;
1143 ret
= XGetWindowAttributes(obt_display
, self
->window
, &wattrib
);
1144 g_assert(ret
!= BadWindow
);
1146 RECT_SET(self
->area
, wattrib
.x
, wattrib
.y
, wattrib
.width
, wattrib
.height
);
1147 POINT_SET(self
->root_pos
, wattrib
.x
, wattrib
.y
);
1148 self
->border_width
= wattrib
.border_width
;
1150 ob_debug("client area: %d %d %d %d bw %d", wattrib
.x
, wattrib
.y
,
1151 wattrib
.width
, wattrib
.height
, wattrib
.border_width
);
1154 static void client_get_desktop(ObClient
*self
)
1156 guint32 d
= screen_num_desktops
; /* an always-invalid value */
1158 if (OBT_PROP_GET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, &d
)) {
1159 if (d
>= screen_num_desktops
&& d
!= DESKTOP_ALL
)
1160 self
->desktop
= screen_num_desktops
- 1;
1163 ob_debug("client requested desktop 0x%x", self
->desktop
);
1166 gboolean first
= TRUE
;
1167 guint all
= screen_num_desktops
; /* not a valid value */
1169 /* if they are all on one desktop, then open it on the
1171 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
1172 ObClient
*c
= it
->data
;
1174 if (c
->desktop
== DESKTOP_ALL
) continue;
1180 else if (all
!= c
->desktop
)
1181 all
= screen_num_desktops
; /* make it invalid */
1183 if (all
!= screen_num_desktops
) {
1184 self
->desktop
= all
;
1186 ob_debug("client desktop set from parents: 0x%x",
1189 /* try get from the startup-notification protocol */
1190 else if (sn_get_desktop(self
->startup_id
, &self
->desktop
)) {
1191 if (self
->desktop
>= screen_num_desktops
&&
1192 self
->desktop
!= DESKTOP_ALL
)
1193 self
->desktop
= screen_num_desktops
- 1;
1194 ob_debug("client desktop set from startup-notification: 0x%x",
1197 /* defaults to the current desktop */
1199 self
->desktop
= screen_desktop
;
1200 ob_debug("client desktop set to the current desktop: %d",
1206 static void client_get_state(ObClient
*self
)
1211 if (OBT_PROP_GETA32(self
->window
, NET_WM_STATE
, ATOM
, &state
, &num
)) {
1213 for (i
= 0; i
< num
; ++i
) {
1214 if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MODAL
))
1216 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SHADED
))
1217 self
->shaded
= TRUE
;
1218 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
))
1219 self
->iconic
= TRUE
;
1220 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
))
1221 self
->skip_taskbar
= TRUE
;
1222 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
))
1223 self
->skip_pager
= TRUE
;
1224 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
))
1225 self
->fullscreen
= TRUE
;
1226 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
))
1227 self
->max_vert
= TRUE
;
1228 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
))
1229 self
->max_horz
= TRUE
;
1230 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_ABOVE
))
1232 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_BELOW
))
1234 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
))
1235 self
->demands_attention
= TRUE
;
1236 else if (state
[i
] == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
))
1237 self
->undecorated
= TRUE
;
1244 static void client_get_shaped(ObClient
*self
)
1246 self
->shaped
= FALSE
;
1248 if (obt_display_extension_shape
) {
1253 XShapeSelectInput(obt_display
, self
->window
, ShapeNotifyMask
);
1255 XShapeQueryExtents(obt_display
, self
->window
, &s
, &foo
,
1256 &foo
, &ufoo
, &ufoo
, &foo
, &foo
, &foo
, &ufoo
,
1263 void client_update_transient_for(ObClient
*self
)
1266 ObClient
*target
= NULL
;
1267 gboolean trangroup
= FALSE
;
1269 if (XGetTransientForHint(obt_display
, self
->window
, &t
)) {
1270 if (t
!= self
->window
) { /* can't be transient to itself! */
1271 ObWindow
*tw
= window_find(t
);
1272 /* if this happens then we need to check for it */
1273 g_assert(tw
!= CLIENT_AS_WINDOW(self
));
1274 if (tw
&& WINDOW_IS_CLIENT(tw
)) {
1275 /* watch out for windows with a parent that is something
1276 different, like a dockapp for example */
1277 target
= WINDOW_AS_CLIENT(tw
);
1281 /* Setting the transient_for to Root is actually illegal, however
1282 applications from time have done this to specify transient for
1284 if (!target
&& self
->group
&& t
== obt_root(ob_screen
))
1286 } else if (self
->group
&& self
->transient
)
1289 client_update_transient_tree(self
, self
->group
, self
->group
,
1290 self
->transient_for_group
, trangroup
,
1291 client_direct_parent(self
), target
);
1292 self
->transient_for_group
= trangroup
;
1296 static void client_update_transient_tree(ObClient
*self
,
1297 ObGroup
*oldgroup
, ObGroup
*newgroup
,
1298 gboolean oldgtran
, gboolean newgtran
,
1299 ObClient
* oldparent
,
1300 ObClient
*newparent
)
1305 g_assert(!oldgtran
|| oldgroup
);
1306 g_assert(!newgtran
|| newgroup
);
1307 g_assert((!oldgtran
&& !oldparent
) ||
1308 (oldgtran
&& !oldparent
) ||
1309 (!oldgtran
&& oldparent
));
1310 g_assert((!newgtran
&& !newparent
) ||
1311 (newgtran
&& !newparent
) ||
1312 (!newgtran
&& newparent
));
1315 Group transient windows are not allowed to have other group
1316 transient windows as their children.
1319 /* No change has occured */
1320 if (oldgroup
== newgroup
&&
1321 oldgtran
== newgtran
&&
1322 oldparent
== newparent
) return;
1324 /** Remove the client from the transient tree **/
1326 for (it
= self
->transients
; it
; it
= next
) {
1327 next
= g_slist_next(it
);
1329 self
->transients
= g_slist_delete_link(self
->transients
, it
);
1330 c
->parents
= g_slist_remove(c
->parents
, self
);
1332 for (it
= self
->parents
; it
; it
= next
) {
1333 next
= g_slist_next(it
);
1335 self
->parents
= g_slist_delete_link(self
->parents
, it
);
1336 c
->transients
= g_slist_remove(c
->transients
, self
);
1339 /** Re-add the client to the transient tree **/
1341 /* If we're transient for a group then we need to add ourselves to all our
1344 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1347 !client_search_top_direct_parent(c
)->transient_for_group
&&
1350 c
->transients
= g_slist_prepend(c
->transients
, self
);
1351 self
->parents
= g_slist_prepend(self
->parents
, c
);
1356 /* If we are now transient for a single window we need to add ourselves to
1359 WARNING: Cyclical transient-ness is possible if two windows are
1360 transient for eachother.
1362 else if (newparent
&&
1363 /* don't make ourself its child if it is already our child */
1364 !client_is_direct_child(self
, newparent
) &&
1365 client_normal(newparent
))
1367 newparent
->transients
= g_slist_prepend(newparent
->transients
, self
);
1368 self
->parents
= g_slist_prepend(self
->parents
, newparent
);
1371 /* Add any group transient windows to our children. But if we're transient
1372 for the group, then other group transients are not our children.
1374 WARNING: Cyclical transient-ness is possible. For e.g. if:
1375 A is transient for the group
1376 B is transient for A
1377 C is transient for B
1378 A can't be transient for C or we have a cycle
1380 if (!newgtran
&& newgroup
&&
1382 !client_search_top_direct_parent(newparent
)->transient_for_group
) &&
1383 client_normal(self
))
1385 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1387 if (c
!= self
&& c
->transient_for_group
&&
1388 /* Don't make it our child if it is already our parent */
1389 !client_is_direct_child(c
, self
))
1391 self
->transients
= g_slist_prepend(self
->transients
, c
);
1392 c
->parents
= g_slist_prepend(c
->parents
, self
);
1397 /** If we change our group transient-ness, our children change their
1398 effective group transient-ness, which affects how they relate to other
1401 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
1403 if (!c
->transient_for_group
)
1404 client_update_transient_tree(c
, c
->group
, c
->group
,
1405 c
->transient_for_group
,
1406 c
->transient_for_group
,
1407 client_direct_parent(c
),
1408 client_direct_parent(c
));
1412 static void client_get_mwm_hints(ObClient
*self
)
1417 self
->mwmhints
.flags
= 0; /* default to none */
1419 if (OBT_PROP_GETA32(self
->window
, MOTIF_WM_HINTS
, MOTIF_WM_HINTS
,
1421 if (num
>= OB_MWM_ELEMENTS
) {
1422 self
->mwmhints
.flags
= hints
[0];
1423 self
->mwmhints
.functions
= hints
[1];
1424 self
->mwmhints
.decorations
= hints
[2];
1430 void client_get_type_and_transientness(ObClient
*self
)
1437 self
->transient
= FALSE
;
1439 if (OBT_PROP_GETA32(self
->window
, NET_WM_WINDOW_TYPE
, ATOM
, &val
, &num
)) {
1440 /* use the first value that we know about in the array */
1441 for (i
= 0; i
< num
; ++i
) {
1442 if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DESKTOP
))
1443 self
->type
= OB_CLIENT_TYPE_DESKTOP
;
1444 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK
))
1445 self
->type
= OB_CLIENT_TYPE_DOCK
;
1446 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_TOOLBAR
))
1447 self
->type
= OB_CLIENT_TYPE_TOOLBAR
;
1448 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_MENU
))
1449 self
->type
= OB_CLIENT_TYPE_MENU
;
1450 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_UTILITY
))
1451 self
->type
= OB_CLIENT_TYPE_UTILITY
;
1452 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_SPLASH
))
1453 self
->type
= OB_CLIENT_TYPE_SPLASH
;
1454 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG
))
1455 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1456 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_NORMAL
))
1457 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1458 else if (val
[i
] == OBT_PROP_ATOM(KDE_NET_WM_WINDOW_TYPE_OVERRIDE
))
1460 /* prevent this window from getting any decor or
1462 self
->mwmhints
.flags
&= (OB_MWM_FLAG_FUNCTIONS
|
1463 OB_MWM_FLAG_DECORATIONS
);
1464 self
->mwmhints
.decorations
= 0;
1465 self
->mwmhints
.functions
= 0;
1467 if (self
->type
!= (ObClientType
) -1)
1468 break; /* grab the first legit type */
1473 if (XGetTransientForHint(obt_display
, self
->window
, &t
))
1474 self
->transient
= TRUE
;
1476 if (self
->type
== (ObClientType
) -1) {
1477 /*the window type hint was not set, which means we either classify
1478 ourself as a normal window or a dialog, depending on if we are a
1480 if (self
->transient
)
1481 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1483 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1486 /* then, based on our type, we can update our transientness.. */
1487 if (self
->type
== OB_CLIENT_TYPE_DIALOG
||
1488 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
1489 self
->type
== OB_CLIENT_TYPE_MENU
||
1490 self
->type
== OB_CLIENT_TYPE_UTILITY
)
1492 self
->transient
= TRUE
;
1496 void client_update_protocols(ObClient
*self
)
1501 self
->focus_notify
= FALSE
;
1502 self
->delete_window
= FALSE
;
1504 if (OBT_PROP_GETA32(self
->window
, WM_PROTOCOLS
, ATOM
, &proto
, &num_ret
)) {
1505 for (i
= 0; i
< num_ret
; ++i
) {
1506 if (proto
[i
] == OBT_PROP_ATOM(WM_DELETE_WINDOW
))
1507 /* this means we can request the window to close */
1508 self
->delete_window
= TRUE
;
1509 else if (proto
[i
] == OBT_PROP_ATOM(WM_TAKE_FOCUS
))
1510 /* if this protocol is requested, then the window will be
1511 notified whenever we want it to receive focus */
1512 self
->focus_notify
= TRUE
;
1513 else if (proto
[i
] == OBT_PROP_ATOM(NET_WM_PING
))
1514 /* if this protocol is requested, then the window will allow
1515 pings to determine if it is still alive */
1518 else if (proto
[i
] == OBT_PROP_ATOM(NET_WM_SYNC_REQUEST
))
1519 /* if this protocol is requested, then resizing the
1520 window will be synchronized between the frame and the
1522 self
->sync_request
= TRUE
;
1530 void client_update_sync_request_counter(ObClient
*self
)
1534 if (OBT_PROP_GET32(self
->window
, NET_WM_SYNC_REQUEST_COUNTER
, CARDINAL
,&i
))
1536 self
->sync_counter
= i
;
1538 self
->sync_counter
= None
;
1542 static void client_get_colormap(ObClient
*self
)
1544 XWindowAttributes wa
;
1546 if (XGetWindowAttributes(obt_display
, self
->window
, &wa
))
1547 client_update_colormap(self
, wa
.colormap
);
1550 void client_update_colormap(ObClient
*self
, Colormap colormap
)
1552 if (colormap
== self
->colormap
) return;
1554 ob_debug("Setting client %s colormap: 0x%x", self
->title
, colormap
);
1556 if (client_focused(self
)) {
1557 screen_install_colormap(self
, FALSE
); /* uninstall old one */
1558 self
->colormap
= colormap
;
1559 screen_install_colormap(self
, TRUE
); /* install new one */
1561 self
->colormap
= colormap
;
1564 void client_update_normal_hints(ObClient
*self
)
1570 self
->min_ratio
= 0.0f
;
1571 self
->max_ratio
= 0.0f
;
1572 SIZE_SET(self
->size_inc
, 1, 1);
1573 SIZE_SET(self
->base_size
, -1, -1);
1574 SIZE_SET(self
->min_size
, 0, 0);
1575 SIZE_SET(self
->max_size
, G_MAXINT
, G_MAXINT
);
1577 /* get the hints from the window */
1578 if (XGetWMNormalHints(obt_display
, self
->window
, &size
, &ret
)) {
1579 /* normal windows can't request placement! har har
1580 if (!client_normal(self))
1582 self
->positioned
= (size
.flags
& (PPosition
|USPosition
));
1583 self
->sized
= (size
.flags
& (PSize
|USSize
));
1585 if (size
.flags
& PWinGravity
)
1586 self
->gravity
= size
.win_gravity
;
1588 if (size
.flags
& PAspect
) {
1589 if (size
.min_aspect
.y
)
1591 (gfloat
) size
.min_aspect
.x
/ size
.min_aspect
.y
;
1592 if (size
.max_aspect
.y
)
1594 (gfloat
) size
.max_aspect
.x
/ size
.max_aspect
.y
;
1597 if (size
.flags
& PMinSize
)
1598 SIZE_SET(self
->min_size
, size
.min_width
, size
.min_height
);
1600 if (size
.flags
& PMaxSize
)
1601 SIZE_SET(self
->max_size
, size
.max_width
, size
.max_height
);
1603 if (size
.flags
& PBaseSize
)
1604 SIZE_SET(self
->base_size
, size
.base_width
, size
.base_height
);
1606 if (size
.flags
& PResizeInc
&& size
.width_inc
&& size
.height_inc
)
1607 SIZE_SET(self
->size_inc
, size
.width_inc
, size
.height_inc
);
1609 ob_debug("Normal hints: min size (%d %d) max size (%d %d)",
1610 self
->min_size
.width
, self
->min_size
.height
,
1611 self
->max_size
.width
, self
->max_size
.height
);
1612 ob_debug("size inc (%d %d) base size (%d %d)",
1613 self
->size_inc
.width
, self
->size_inc
.height
,
1614 self
->base_size
.width
, self
->base_size
.height
);
1617 ob_debug("Normal hints: not set");
1620 void client_setup_decor_and_functions(ObClient
*self
, gboolean reconfig
)
1622 /* start with everything (cept fullscreen) */
1624 (OB_FRAME_DECOR_TITLEBAR
|
1625 OB_FRAME_DECOR_HANDLE
|
1626 OB_FRAME_DECOR_GRIPS
|
1627 OB_FRAME_DECOR_BORDER
|
1628 OB_FRAME_DECOR_ICON
|
1629 OB_FRAME_DECOR_ALLDESKTOPS
|
1630 OB_FRAME_DECOR_ICONIFY
|
1631 OB_FRAME_DECOR_MAXIMIZE
|
1632 OB_FRAME_DECOR_SHADE
|
1633 OB_FRAME_DECOR_CLOSE
);
1635 (OB_CLIENT_FUNC_RESIZE
|
1636 OB_CLIENT_FUNC_MOVE
|
1637 OB_CLIENT_FUNC_ICONIFY
|
1638 OB_CLIENT_FUNC_MAXIMIZE
|
1639 OB_CLIENT_FUNC_SHADE
|
1640 OB_CLIENT_FUNC_CLOSE
|
1641 OB_CLIENT_FUNC_BELOW
|
1642 OB_CLIENT_FUNC_ABOVE
|
1643 OB_CLIENT_FUNC_UNDECORATE
);
1645 if (!(self
->min_size
.width
< self
->max_size
.width
||
1646 self
->min_size
.height
< self
->max_size
.height
))
1647 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1649 switch (self
->type
) {
1650 case OB_CLIENT_TYPE_NORMAL
:
1651 /* normal windows retain all of the possible decorations and
1652 functionality, and can be fullscreen */
1653 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1656 case OB_CLIENT_TYPE_DIALOG
:
1657 /* sometimes apps make dialog windows fullscreen for some reason (for
1658 e.g. kpdf does this..) */
1659 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1662 case OB_CLIENT_TYPE_UTILITY
:
1663 /* these windows don't have anything added or removed by default */
1666 case OB_CLIENT_TYPE_MENU
:
1667 case OB_CLIENT_TYPE_TOOLBAR
:
1668 /* these windows can't iconify or maximize */
1669 self
->decorations
&= ~(OB_FRAME_DECOR_ICONIFY
|
1670 OB_FRAME_DECOR_MAXIMIZE
);
1671 self
->functions
&= ~(OB_CLIENT_FUNC_ICONIFY
|
1672 OB_CLIENT_FUNC_MAXIMIZE
);
1675 case OB_CLIENT_TYPE_SPLASH
:
1676 /* these don't get get any decorations, and the only thing you can
1677 do with them is move them */
1678 self
->decorations
= 0;
1679 self
->functions
= OB_CLIENT_FUNC_MOVE
;
1682 case OB_CLIENT_TYPE_DESKTOP
:
1683 /* these windows are not manipulated by the window manager */
1684 self
->decorations
= 0;
1685 self
->functions
= 0;
1688 case OB_CLIENT_TYPE_DOCK
:
1689 /* these windows are not manipulated by the window manager, but they
1690 can set below layer which has a special meaning */
1691 self
->decorations
= 0;
1692 self
->functions
= OB_CLIENT_FUNC_BELOW
;
1696 /* Mwm Hints are applied subtractively to what has already been chosen for
1697 decor and functionality */
1698 if (self
->mwmhints
.flags
& OB_MWM_FLAG_DECORATIONS
) {
1699 if (! (self
->mwmhints
.decorations
& OB_MWM_DECOR_ALL
)) {
1700 if (! ((self
->mwmhints
.decorations
& OB_MWM_DECOR_HANDLE
) ||
1701 (self
->mwmhints
.decorations
& OB_MWM_DECOR_TITLE
)))
1703 /* if the mwm hints request no handle or title, then all
1704 decorations are disabled, but keep the border if that's
1706 if (self
->mwmhints
.decorations
& OB_MWM_DECOR_BORDER
)
1707 self
->decorations
= OB_FRAME_DECOR_BORDER
;
1709 self
->decorations
= 0;
1714 if (self
->mwmhints
.flags
& OB_MWM_FLAG_FUNCTIONS
) {
1715 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_ALL
)) {
1716 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_RESIZE
))
1717 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1718 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_MOVE
))
1719 self
->functions
&= ~OB_CLIENT_FUNC_MOVE
;
1720 /* dont let mwm hints kill any buttons
1721 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1722 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1723 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1724 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1726 /* dont let mwm hints kill the close button
1727 if (! (self->mwmhints.functions & MwmFunc_Close))
1728 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1732 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
))
1733 self
->decorations
&= ~OB_FRAME_DECOR_SHADE
;
1734 if (!(self
->functions
& OB_CLIENT_FUNC_ICONIFY
))
1735 self
->decorations
&= ~OB_FRAME_DECOR_ICONIFY
;
1736 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
))
1737 self
->decorations
&= ~(OB_FRAME_DECOR_GRIPS
| OB_FRAME_DECOR_HANDLE
);
1739 /* can't maximize without moving/resizing */
1740 if (!((self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) &&
1741 (self
->functions
& OB_CLIENT_FUNC_MOVE
) &&
1742 (self
->functions
& OB_CLIENT_FUNC_RESIZE
))) {
1743 self
->functions
&= ~OB_CLIENT_FUNC_MAXIMIZE
;
1744 self
->decorations
&= ~OB_FRAME_DECOR_MAXIMIZE
;
1747 if (self
->max_horz
&& self
->max_vert
) {
1748 /* you can't resize fully maximized windows */
1749 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1750 /* kill the handle on fully maxed windows */
1751 self
->decorations
&= ~(OB_FRAME_DECOR_HANDLE
| OB_FRAME_DECOR_GRIPS
);
1754 /* If there are no decorations to remove, don't allow the user to try
1756 if (self
->decorations
== 0)
1757 self
->functions
&= ~OB_CLIENT_FUNC_UNDECORATE
;
1759 /* finally, the user can have requested no decorations, which overrides
1760 everything (but doesnt give it a border if it doesnt have one) */
1761 if (self
->undecorated
)
1762 self
->decorations
= 0;
1764 /* if we don't have a titlebar, then we cannot shade! */
1765 if (!(self
->decorations
& OB_FRAME_DECOR_TITLEBAR
))
1766 self
->functions
&= ~OB_CLIENT_FUNC_SHADE
;
1768 /* now we need to check against rules for the client's current state */
1769 if (self
->fullscreen
) {
1770 self
->functions
&= (OB_CLIENT_FUNC_CLOSE
|
1771 OB_CLIENT_FUNC_FULLSCREEN
|
1772 OB_CLIENT_FUNC_ICONIFY
);
1773 self
->decorations
= 0;
1776 client_change_allowed_actions(self
);
1779 /* force reconfigure to make sure decorations are updated */
1780 client_reconfigure(self
, TRUE
);
1783 static void client_change_allowed_actions(ObClient
*self
)
1788 /* desktop windows are kept on all desktops */
1789 if (self
->type
!= OB_CLIENT_TYPE_DESKTOP
)
1790 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_CHANGE_DESKTOP
);
1792 if (self
->functions
& OB_CLIENT_FUNC_SHADE
)
1793 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_SHADE
);
1794 if (self
->functions
& OB_CLIENT_FUNC_CLOSE
)
1795 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_CLOSE
);
1796 if (self
->functions
& OB_CLIENT_FUNC_MOVE
)
1797 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MOVE
);
1798 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
)
1799 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MINIMIZE
);
1800 if (self
->functions
& OB_CLIENT_FUNC_RESIZE
)
1801 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_RESIZE
);
1802 if (self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
)
1803 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_FULLSCREEN
);
1804 if (self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) {
1805 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_HORZ
);
1806 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_VERT
);
1808 if (self
->functions
& OB_CLIENT_FUNC_ABOVE
)
1809 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_ABOVE
);
1810 if (self
->functions
& OB_CLIENT_FUNC_BELOW
)
1811 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_BELOW
);
1812 if (self
->functions
& OB_CLIENT_FUNC_UNDECORATE
)
1813 actions
[num
++] = OBT_PROP_ATOM(OB_WM_ACTION_UNDECORATE
);
1815 OBT_PROP_SETA32(self
->window
, NET_WM_ALLOWED_ACTIONS
, ATOM
, actions
, num
);
1817 /* make sure the window isn't breaking any rules now
1819 don't check ICONIFY here. just cuz a window can't iconify doesnt mean
1820 it can't be iconified with its parent
1823 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
) && self
->shaded
) {
1824 if (self
->frame
) client_shade(self
, FALSE
);
1825 else self
->shaded
= FALSE
;
1827 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) && self
->fullscreen
) {
1828 if (self
->frame
) client_fullscreen(self
, FALSE
);
1829 else self
->fullscreen
= FALSE
;
1831 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && (self
->max_horz
||
1833 if (self
->frame
) client_maximize(self
, FALSE
, 0);
1834 else self
->max_vert
= self
->max_horz
= FALSE
;
1838 void client_update_wmhints(ObClient
*self
)
1842 /* assume a window takes input if it doesn't specify */
1843 self
->can_focus
= TRUE
;
1845 if ((hints
= XGetWMHints(obt_display
, self
->window
)) != NULL
) {
1848 if (hints
->flags
& InputHint
)
1849 self
->can_focus
= hints
->input
;
1851 /* only do this when first managing the window *AND* when we aren't
1853 if (ob_state() != OB_STATE_STARTING
&& self
->frame
== NULL
)
1854 if (hints
->flags
& StateHint
)
1855 self
->iconic
= hints
->initial_state
== IconicState
;
1858 self
->urgent
= (hints
->flags
& XUrgencyHint
);
1859 if (self
->urgent
&& !ur
)
1860 client_hilite(self
, TRUE
);
1861 else if (!self
->urgent
&& ur
&& self
->demands_attention
)
1862 client_hilite(self
, FALSE
);
1864 if (!(hints
->flags
& WindowGroupHint
))
1865 hints
->window_group
= None
;
1867 /* did the group state change? */
1868 if (hints
->window_group
!=
1869 (self
->group
? self
->group
->leader
: None
))
1871 ObGroup
*oldgroup
= self
->group
;
1873 /* remove from the old group if there was one */
1875 group_remove(self
->group
, self
);
1879 /* add ourself to the group if we have one */
1880 if (hints
->window_group
!= None
) {
1881 self
->group
= group_add(hints
->window_group
, self
);
1884 /* Put ourselves into the new group's transient tree, and remove
1885 ourselves from the old group's */
1886 client_update_transient_tree(self
, oldgroup
, self
->group
,
1887 self
->transient_for_group
,
1888 self
->transient_for_group
,
1889 client_direct_parent(self
),
1890 client_direct_parent(self
));
1892 /* Lastly, being in a group, or not, can change if the window is
1893 transient for anything.
1895 The logic for this is:
1896 self->transient = TRUE always if the window wants to be
1897 transient for something, even if transient_for was NULL because
1898 it wasn't in a group before.
1900 If parents was NULL and oldgroup was NULL we can assume
1901 that when we add the new group, it will become transient for
1904 If transient_for_group is TRUE, then it must have already
1905 had a group. If it is getting a new group, the above call to
1906 client_update_transient_tree has already taken care of
1907 everything ! If it is losing all group status then it will
1908 no longer be transient for anything and that needs to be
1911 if (self
->transient
&&
1912 ((self
->parents
== NULL
&& oldgroup
== NULL
) ||
1913 (self
->transient_for_group
&& !self
->group
)))
1914 client_update_transient_for(self
);
1917 /* the WM_HINTS can contain an icon */
1918 if (hints
->flags
& IconPixmapHint
)
1919 client_update_icons(self
);
1925 void client_update_title(ObClient
*self
)
1928 gchar
*visible
= NULL
;
1930 g_free(self
->title
);
1931 g_free(self
->original_title
);
1934 if (!OBT_PROP_GETS(self
->window
, NET_WM_NAME
, utf8
, &data
)) {
1935 /* try old x stuff */
1936 if (!(OBT_PROP_GETS(self
->window
, WM_NAME
, locale
, &data
)
1937 || OBT_PROP_GETS(self
->window
, WM_NAME
, utf8
, &data
))) {
1938 if (self
->transient
) {
1940 GNOME alert windows are not given titles:
1941 http://developer.gnome.org/projects/gup/hig/draft_hig_new/windows-alert.html
1943 data
= g_strdup("");
1945 data
= g_strdup(_("Unnamed Window"));
1948 self
->original_title
= g_strdup(data
);
1950 if (self
->client_machine
) {
1951 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1956 if (self
->not_responding
) {
1958 if (self
->kill_level
> 0)
1959 visible
= g_strdup_printf("%s - [%s]", data
, _("Killing..."));
1961 visible
= g_strdup_printf("%s - [%s]", data
, _("Not Responding"));
1965 OBT_PROP_SETS(self
->window
, NET_WM_VISIBLE_NAME
, utf8
, visible
);
1966 self
->title
= visible
;
1969 frame_adjust_title(self
->frame
);
1971 /* update the icon title */
1973 g_free(self
->icon_title
);
1976 if (!OBT_PROP_GETS(self
->window
, NET_WM_ICON_NAME
, utf8
, &data
))
1977 /* try old x stuff */
1978 if (!(OBT_PROP_GETS(self
->window
, WM_ICON_NAME
, locale
, &data
) ||
1979 OBT_PROP_GETS(self
->window
, WM_ICON_NAME
, utf8
, &data
)))
1980 data
= g_strdup(self
->title
);
1982 if (self
->client_machine
) {
1983 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1988 if (self
->not_responding
) {
1990 if (self
->kill_level
> 0)
1991 visible
= g_strdup_printf("%s - [%s]", data
, _("Killing..."));
1993 visible
= g_strdup_printf("%s - [%s]", data
, _("Not Responding"));
1997 OBT_PROP_SETS(self
->window
, NET_WM_VISIBLE_ICON_NAME
, utf8
, visible
);
1998 self
->icon_title
= visible
;
2001 void client_update_strut(ObClient
*self
)
2005 gboolean got
= FALSE
;
2008 if (OBT_PROP_GETA32(self
->window
, NET_WM_STRUT_PARTIAL
, CARDINAL
,
2013 STRUT_PARTIAL_SET(strut
,
2014 data
[0], data
[2], data
[1], data
[3],
2015 data
[4], data
[5], data
[8], data
[9],
2016 data
[6], data
[7], data
[10], data
[11]);
2022 OBT_PROP_GETA32(self
->window
, NET_WM_STRUT
, CARDINAL
, &data
, &num
)) {
2028 /* use the screen's width/height */
2029 a
= screen_physical_area_all_monitors();
2031 STRUT_PARTIAL_SET(strut
,
2032 data
[0], data
[2], data
[1], data
[3],
2033 a
->y
, a
->y
+ a
->height
- 1,
2034 a
->x
, a
->x
+ a
->width
- 1,
2035 a
->y
, a
->y
+ a
->height
- 1,
2036 a
->x
, a
->x
+ a
->width
- 1);
2043 STRUT_PARTIAL_SET(strut
, 0, 0, 0, 0,
2044 0, 0, 0, 0, 0, 0, 0, 0);
2046 if (!STRUT_EQUAL(strut
, self
->strut
)) {
2047 self
->strut
= strut
;
2049 /* updating here is pointless while we're being mapped cuz we're not in
2050 the client list yet */
2052 screen_update_areas();
2056 void client_update_icons(ObClient
*self
)
2061 guint num_seen
; /* number of icons present */
2066 /* grab the server, because we might be setting the window's icon and
2067 we don't want them to set it in between and we overwrite their own
2071 if (OBT_PROP_GETA32(self
->window
, NET_WM_ICON
, CARDINAL
, &data
, &num
)) {
2072 /* figure out how many valid icons are in here */
2075 while (i
+ 2 < num
) { /* +2 is to make sure there is a w and h */
2078 /* watch for the data being too small for the specified size,
2079 or for zero sized icons. */
2080 if (i
+ w
*h
> num
|| w
== 0 || h
== 0) break;
2082 /* convert it to the right bit order for ObRender */
2083 for (j
= 0; j
< w
*h
; ++j
)
2085 (((data
[i
+j
] >> 24) & 0xff) << RrDefaultAlphaOffset
) +
2086 (((data
[i
+j
] >> 16) & 0xff) << RrDefaultRedOffset
) +
2087 (((data
[i
+j
] >> 8) & 0xff) << RrDefaultGreenOffset
) +
2088 (((data
[i
+j
] >> 0) & 0xff) << RrDefaultBlueOffset
);
2090 /* is it in the cache? */
2091 img
= RrImageCacheFind(ob_rr_icons
, &data
[i
], w
, h
);
2092 if (img
) RrImageRef(img
); /* own it */
2097 /* don't bother looping anymore if we already found it in the cache
2098 since we'll just use that! */
2102 /* if it's not in the cache yet, then add it to the cache now.
2103 we have already converted it to the correct bit order above */
2104 if (!img
&& num_seen
> 0) {
2105 img
= RrImageNew(ob_rr_icons
);
2107 for (j
= 0; j
< num_seen
; ++j
) {
2110 RrImageAddPicture(img
, &data
[i
], w
, h
);
2118 /* if we didn't find an image from the NET_WM_ICON stuff, then try the
2123 if ((hints
= XGetWMHints(obt_display
, self
->window
))) {
2124 if (hints
->flags
& IconPixmapHint
) {
2126 obt_display_ignore_errors(TRUE
);
2127 xicon
= RrPixmapToRGBA(ob_rr_inst
,
2129 (hints
->flags
& IconMaskHint
?
2130 hints
->icon_mask
: None
),
2131 (gint
*)&w
, (gint
*)&h
, &data
);
2132 obt_display_ignore_errors(FALSE
);
2135 if (w
> 0 && h
> 0) {
2136 /* is this icon in the cache yet? */
2137 img
= RrImageCacheFind(ob_rr_icons
, data
, w
, h
);
2138 if (img
) RrImageRef(img
); /* own it */
2140 /* if not, then add it */
2142 img
= RrImageNew(ob_rr_icons
);
2143 RrImageAddPicture(img
, data
, w
, h
);
2154 /* set the client's icons to be whatever we found */
2155 RrImageUnref(self
->icon_set
);
2156 self
->icon_set
= img
;
2158 /* if the client has no icon at all, then we set a default icon onto it.
2159 but, if it has parents, then one of them will have an icon already
2161 if (!self
->icon_set
&& !self
->parents
) {
2162 RrPixel32
*icon
= ob_rr_theme
->def_win_icon
;
2163 gulong
*ldata
; /* use a long here to satisfy OBT_PROP_SETA32 */
2165 w
= ob_rr_theme
->def_win_icon_w
;
2166 h
= ob_rr_theme
->def_win_icon_h
;
2167 ldata
= g_new(gulong
, w
*h
+2);
2170 for (i
= 0; i
< w
*h
; ++i
)
2171 ldata
[i
+2] = (((icon
[i
] >> RrDefaultAlphaOffset
) & 0xff) << 24) +
2172 (((icon
[i
] >> RrDefaultRedOffset
) & 0xff) << 16) +
2173 (((icon
[i
] >> RrDefaultGreenOffset
) & 0xff) << 8) +
2174 (((icon
[i
] >> RrDefaultBlueOffset
) & 0xff) << 0);
2175 OBT_PROP_SETA32(self
->window
, NET_WM_ICON
, CARDINAL
, ldata
, w
*h
+2);
2177 } else if (self
->frame
)
2178 /* don't draw the icon empty if we're just setting one now anyways,
2179 we'll get the property change any second */
2180 frame_adjust_icon(self
->frame
);
2185 void client_update_icon_geometry(ObClient
*self
)
2190 RECT_SET(self
->icon_geometry
, 0, 0, 0, 0);
2192 if (OBT_PROP_GETA32(self
->window
, NET_WM_ICON_GEOMETRY
, CARDINAL
,
2196 /* don't let them set it with an area < 0 */
2197 RECT_SET(self
->icon_geometry
, data
[0], data
[1],
2198 MAX(data
[2],0), MAX(data
[3],0));
2203 static void client_get_session_ids(ObClient
*self
)
2210 if (!OBT_PROP_GET32(self
->window
, WM_CLIENT_LEADER
, WINDOW
, &leader
))
2213 /* get the SM_CLIENT_ID */
2216 got
= OBT_PROP_GETS(leader
, SM_CLIENT_ID
, locale
, &self
->sm_client_id
);
2218 OBT_PROP_GETS(self
->window
, SM_CLIENT_ID
, locale
, &self
->sm_client_id
);
2220 /* get the WM_CLASS (name and class). make them "" if they are not
2224 got
= OBT_PROP_GETSS(leader
, WM_CLASS
, locale
, &ss
);
2226 got
= OBT_PROP_GETSS(self
->window
, WM_CLASS
, locale
, &ss
);
2230 self
->name
= g_strdup(ss
[0]);
2232 self
->class = g_strdup(ss
[1]);
2237 if (self
->name
== NULL
) self
->name
= g_strdup("");
2238 if (self
->class == NULL
) self
->class = g_strdup("");
2240 /* get the WM_WINDOW_ROLE. make it "" if it is not provided */
2243 got
= OBT_PROP_GETS(leader
, WM_WINDOW_ROLE
, locale
, &s
);
2245 got
= OBT_PROP_GETS(self
->window
, WM_WINDOW_ROLE
, locale
, &s
);
2250 self
->role
= g_strdup("");
2252 /* get the WM_COMMAND */
2256 got
= OBT_PROP_GETSS(leader
, WM_COMMAND
, locale
, &ss
);
2258 got
= OBT_PROP_GETSS(self
->window
, WM_COMMAND
, locale
, &ss
);
2261 /* merge/mash them all together */
2262 gchar
*merge
= NULL
;
2265 for (i
= 0; ss
[i
]; ++i
) {
2268 merge
= g_strconcat(merge
, ss
[i
], NULL
);
2270 merge
= g_strconcat(ss
[i
], NULL
);
2275 self
->wm_command
= merge
;
2278 /* get the WM_CLIENT_MACHINE */
2281 got
= OBT_PROP_GETS(leader
, WM_CLIENT_MACHINE
, locale
, &s
);
2283 got
= OBT_PROP_GETS(self
->window
, WM_CLIENT_MACHINE
, locale
, &s
);
2286 gchar localhost
[128];
2289 gethostname(localhost
, 127);
2290 localhost
[127] = '\0';
2291 if (strcmp(localhost
, s
) != 0)
2292 self
->client_machine
= s
;
2296 /* see if it has the PID set too (the PID requires that the
2297 WM_CLIENT_MACHINE be set) */
2298 if (OBT_PROP_GET32(self
->window
, NET_WM_PID
, CARDINAL
, &pid
))
2303 static void client_change_wm_state(ObClient
*self
)
2308 old
= self
->wmstate
;
2310 if (self
->shaded
|| self
->iconic
||
2311 (self
->desktop
!= DESKTOP_ALL
&& self
->desktop
!= screen_desktop
))
2313 self
->wmstate
= IconicState
;
2315 self
->wmstate
= NormalState
;
2317 if (old
!= self
->wmstate
) {
2318 OBT_PROP_MSG(ob_screen
, self
->window
, KDE_WM_CHANGE_STATE
,
2319 self
->wmstate
, 1, 0, 0, 0);
2321 state
[0] = self
->wmstate
;
2323 OBT_PROP_SETA32(self
->window
, WM_STATE
, WM_STATE
, state
, 2);
2327 static void client_change_state(ObClient
*self
)
2329 gulong netstate
[12];
2334 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MODAL
);
2336 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SHADED
);
2338 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
);
2339 if (self
->skip_taskbar
)
2340 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
);
2341 if (self
->skip_pager
)
2342 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
);
2343 if (self
->fullscreen
)
2344 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
);
2346 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
);
2348 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
);
2350 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_ABOVE
);
2352 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_BELOW
);
2353 if (self
->demands_attention
)
2354 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
);
2355 if (self
->undecorated
)
2356 netstate
[num
++] = OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
);
2357 OBT_PROP_SETA32(self
->window
, NET_WM_STATE
, ATOM
, netstate
, num
);
2360 frame_adjust_state(self
->frame
);
2363 ObClient
*client_search_focus_tree(ObClient
*self
)
2368 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
2369 if (client_focused(it
->data
)) return it
->data
;
2370 if ((ret
= client_search_focus_tree(it
->data
))) return ret
;
2375 ObClient
*client_search_focus_tree_full(ObClient
*self
)
2377 if (self
->parents
) {
2380 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
2381 ObClient
*c
= it
->data
;
2382 if ((c
= client_search_focus_tree_full(it
->data
))) return c
;
2388 /* this function checks the whole tree, the client_search_focus_tree
2389 does not, so we need to check this window */
2390 if (client_focused(self
))
2392 return client_search_focus_tree(self
);
2396 ObClient
*client_search_focus_group_full(ObClient
*self
)
2401 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
2402 ObClient
*c
= it
->data
;
2404 if (client_focused(c
)) return c
;
2405 if ((c
= client_search_focus_tree(it
->data
))) return c
;
2408 if (client_focused(self
)) return self
;
2412 gboolean
client_has_parent(ObClient
*self
)
2414 return self
->parents
!= NULL
;
2417 static ObStackingLayer
calc_layer(ObClient
*self
)
2422 monitor
= screen_physical_area_monitor(client_monitor(self
));
2424 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
2425 l
= OB_STACKING_LAYER_DESKTOP
;
2426 else if (self
->type
== OB_CLIENT_TYPE_DOCK
) {
2427 if (self
->below
) l
= OB_STACKING_LAYER_NORMAL
;
2428 else l
= OB_STACKING_LAYER_ABOVE
;
2430 else if ((self
->fullscreen
||
2431 /* No decorations and fills the monitor = oldskool fullscreen.
2432 But not for maximized windows.
2434 (self
->decorations
== 0 &&
2435 !(self
->max_horz
&& self
->max_vert
) &&
2436 RECT_EQUAL(self
->area
, *monitor
))) &&
2437 /* you are fullscreen while you or your children are focused.. */
2438 (client_focused(self
) || client_search_focus_tree(self
) ||
2439 /* you can be fullscreen if you're on another desktop */
2440 (self
->desktop
!= screen_desktop
&&
2441 self
->desktop
!= DESKTOP_ALL
) ||
2442 /* and you can also be fullscreen if the focused client is on
2443 another monitor, or nothing else is focused */
2445 client_monitor(focus_client
) != client_monitor(self
))))
2446 l
= OB_STACKING_LAYER_FULLSCREEN
;
2447 else if (self
->above
) l
= OB_STACKING_LAYER_ABOVE
;
2448 else if (self
->below
) l
= OB_STACKING_LAYER_BELOW
;
2449 else l
= OB_STACKING_LAYER_NORMAL
;
2456 static void client_calc_layer_recursive(ObClient
*self
, ObClient
*orig
,
2457 ObStackingLayer min
)
2459 ObStackingLayer old
, own
;
2463 own
= calc_layer(self
);
2464 self
->layer
= MAX(own
, min
);
2466 if (self
->layer
!= old
) {
2467 stacking_remove(CLIENT_AS_WINDOW(self
));
2468 stacking_add_nonintrusive(CLIENT_AS_WINDOW(self
));
2471 /* we've been restacked */
2472 self
->visited
= TRUE
;
2474 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
2475 client_calc_layer_recursive(it
->data
, orig
,
2479 static void client_calc_layer_internal(ObClient
*self
)
2483 /* transients take on the layer of their parents */
2484 sit
= client_search_all_top_parents(self
);
2486 for (; sit
; sit
= g_slist_next(sit
))
2487 client_calc_layer_recursive(sit
->data
, self
, 0);
2490 void client_calc_layer(ObClient
*self
)
2494 /* skip over stuff above fullscreen layer */
2495 for (it
= stacking_list
; it
; it
= g_list_next(it
))
2496 if (window_layer(it
->data
) <= OB_STACKING_LAYER_FULLSCREEN
) break;
2498 /* find the windows in the fullscreen layer, and mark them not-visited */
2499 for (; it
; it
= g_list_next(it
)) {
2500 if (window_layer(it
->data
) < OB_STACKING_LAYER_FULLSCREEN
) break;
2501 else if (WINDOW_IS_CLIENT(it
->data
))
2502 WINDOW_AS_CLIENT(it
->data
)->visited
= FALSE
;
2505 client_calc_layer_internal(self
);
2507 /* skip over stuff above fullscreen layer */
2508 for (it
= stacking_list
; it
; it
= g_list_next(it
))
2509 if (window_layer(it
->data
) <= OB_STACKING_LAYER_FULLSCREEN
) break;
2511 /* now recalc any windows in the fullscreen layer which have not
2512 had their layer recalced already */
2513 for (; it
; it
= g_list_next(it
)) {
2514 if (window_layer(it
->data
) < OB_STACKING_LAYER_FULLSCREEN
) break;
2515 else if (WINDOW_IS_CLIENT(it
->data
) &&
2516 !WINDOW_AS_CLIENT(it
->data
)->visited
)
2517 client_calc_layer_internal(it
->data
);
2521 gboolean
client_should_show(ObClient
*self
)
2525 if (client_normal(self
) && screen_showing_desktop
)
2527 if (self
->desktop
== screen_desktop
|| self
->desktop
== DESKTOP_ALL
)
2533 gboolean
client_show(ObClient
*self
)
2535 gboolean show
= FALSE
;
2537 if (client_should_show(self
)) {
2538 /* replay pending pointer event before showing the window, in case it
2539 should be going to something under the window */
2540 mouse_replay_pointer();
2542 frame_show(self
->frame
);
2545 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible,
2546 it needs to be in IconicState. This includes when it is on another
2549 client_change_wm_state(self
);
2551 hooks_queue(OB_HOOK_WIN_VISIBLE
, self
);
2556 gboolean
client_hide(ObClient
*self
)
2558 gboolean hide
= FALSE
;
2560 if (!client_should_show(self
)) {
2561 if (self
== focus_client
) {
2562 event_cancel_all_key_grabs();
2565 /* We don't need to ignore enter events here.
2566 The window can hide/iconify in 3 different ways:
2567 1 - through an x message. in this case we ignore all enter events
2568 caused by responding to the x message (unless underMouse)
2569 2 - by a keyboard action. in this case we ignore all enter events
2570 caused by the action
2571 3 - by a mouse action. in this case they are doing stuff with the
2572 mouse and focus _should_ move.
2574 Also in action_end, we simulate an enter event that can't be ignored
2575 so trying to ignore them is futile in case 3 anyways
2578 /* replay pending pointer event before hiding the window, in case it
2579 should be going to the window */
2580 mouse_replay_pointer();
2582 frame_hide(self
->frame
);
2585 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible,
2586 it needs to be in IconicState. This includes when it is on another
2589 client_change_wm_state(self
);
2591 hooks_queue(OB_HOOK_WIN_INVISIBLE
, self
);
2596 void client_showhide(ObClient
*self
)
2598 if (!client_show(self
))
2602 gboolean
client_normal(ObClient
*self
) {
2603 return ! (self
->type
== OB_CLIENT_TYPE_DESKTOP
||
2604 self
->type
== OB_CLIENT_TYPE_DOCK
||
2605 self
->type
== OB_CLIENT_TYPE_SPLASH
);
2608 gboolean
client_helper(ObClient
*self
)
2610 return (self
->type
== OB_CLIENT_TYPE_UTILITY
||
2611 self
->type
== OB_CLIENT_TYPE_MENU
||
2612 self
->type
== OB_CLIENT_TYPE_TOOLBAR
);
2615 gboolean
client_mouse_focusable(ObClient
*self
)
2617 return !(self
->type
== OB_CLIENT_TYPE_MENU
||
2618 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
2619 self
->type
== OB_CLIENT_TYPE_SPLASH
||
2620 self
->type
== OB_CLIENT_TYPE_DOCK
);
2623 gboolean
client_enter_focusable(ObClient
*self
)
2625 /* you can focus desktops but it shouldn't on enter */
2626 return (client_mouse_focusable(self
) &&
2627 self
->type
!= OB_CLIENT_TYPE_DESKTOP
);
2630 static void client_apply_startup_state(ObClient
*self
,
2631 gint x
, gint y
, gint w
, gint h
)
2633 /* save the states that we are going to apply */
2634 gboolean iconic
= self
->iconic
;
2635 gboolean fullscreen
= self
->fullscreen
;
2636 gboolean undecorated
= self
->undecorated
;
2637 gboolean shaded
= self
->shaded
;
2638 gboolean demands_attention
= self
->demands_attention
;
2639 gboolean max_horz
= self
->max_horz
;
2640 gboolean max_vert
= self
->max_vert
;
2644 /* turn them all off in the client, so they won't affect the window
2646 self
->iconic
= self
->fullscreen
= self
->undecorated
= self
->shaded
=
2647 self
->demands_attention
= self
->max_horz
= self
->max_vert
= FALSE
;
2649 /* move the client to its placed position, or it it's already there,
2650 generate a ConfigureNotify telling the client where it is.
2652 do this after adjusting the frame. otherwise it gets all weird and
2653 clients don't work right
2655 do this before applying the states so they have the correct
2656 pre-max/pre-fullscreen values
2658 client_try_configure(self
, &x
, &y
, &w
, &h
, &l
, &l
, FALSE
);
2659 ob_debug("placed window 0x%x at %d, %d with size %d x %d",
2660 self
->window
, x
, y
, w
, h
);
2661 /* save the area, and make it where it should be for the premax stuff */
2662 oldarea
= self
->area
;
2663 RECT_SET(self
->area
, x
, y
, w
, h
);
2665 /* apply the states. these are in a carefully crafted order.. */
2668 client_iconify(self
, TRUE
, FALSE
, TRUE
);
2670 client_fullscreen(self
, TRUE
);
2672 client_set_undecorated(self
, TRUE
);
2674 client_shade(self
, TRUE
);
2675 if (demands_attention
)
2676 client_hilite(self
, TRUE
);
2678 if (max_vert
&& max_horz
)
2679 client_maximize(self
, TRUE
, 0);
2681 client_maximize(self
, TRUE
, 2);
2683 client_maximize(self
, TRUE
, 1);
2685 /* if the window hasn't been configured yet, then do so now, in fact the
2686 x,y,w,h may _not_ be the same as the area rect, which can end up
2687 meaning that the client isn't properly moved/resized by the fullscreen
2689 pho can cause this because it maps at size of the screen but not 0,0
2690 so openbox moves it on screen to 0,0 (thus x,y=0,0 and area.x,y don't).
2691 then fullscreen'ing makes it go to 0,0 which it thinks it already is at
2692 cuz thats where the pre-fullscreen will be. however the actual area is
2693 not, so this needs to be called even if we have fullscreened/maxed
2695 self
->area
= oldarea
;
2696 client_configure(self
, x
, y
, w
, h
, FALSE
, TRUE
, FALSE
);
2698 /* set the desktop hint, to make sure that it always exists */
2699 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, self
->desktop
);
2701 /* nothing to do for the other states:
2710 void client_gravity_resize_w(ObClient
*self
, gint
*x
, gint oldw
, gint neww
)
2712 /* these should be the current values. this is for when you're not moving,
2714 g_assert(*x
== self
->area
.x
);
2715 g_assert(oldw
== self
->area
.width
);
2718 switch (self
->gravity
) {
2720 case NorthWestGravity
:
2722 case SouthWestGravity
:
2729 *x
-= (neww
- oldw
) / 2;
2731 case NorthEastGravity
:
2733 case SouthEastGravity
:
2739 void client_gravity_resize_h(ObClient
*self
, gint
*y
, gint oldh
, gint newh
)
2741 /* these should be the current values. this is for when you're not moving,
2743 g_assert(*y
== self
->area
.y
);
2744 g_assert(oldh
== self
->area
.height
);
2747 switch (self
->gravity
) {
2749 case NorthWestGravity
:
2751 case NorthEastGravity
:
2758 *y
-= (newh
- oldh
) / 2;
2760 case SouthWestGravity
:
2762 case SouthEastGravity
:
2768 void client_try_configure(ObClient
*self
, gint
*x
, gint
*y
, gint
*w
, gint
*h
,
2769 gint
*logicalw
, gint
*logicalh
,
2772 Rect desired
= {*x
, *y
, *w
, *h
};
2773 frame_rect_to_frame(self
->frame
, &desired
);
2775 /* make the frame recalculate its dimensions n shit without changing
2776 anything visible for real, this way the constraints below can work with
2777 the updated frame dimensions. */
2778 frame_adjust_area(self
->frame
, FALSE
, TRUE
, TRUE
);
2780 /* gets the frame's position */
2781 frame_client_gravity(self
->frame
, x
, y
);
2783 /* these positions are frame positions, not client positions */
2785 /* set the size and position if fullscreen */
2786 if (self
->fullscreen
) {
2790 i
= screen_find_monitor(&desired
);
2791 a
= screen_physical_area_monitor(i
);
2798 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2802 } else if (self
->max_horz
|| self
->max_vert
) {
2806 /* use all possible struts when maximizing to the full screen */
2807 i
= screen_find_monitor(&desired
);
2808 a
= screen_area(self
->desktop
, i
,
2809 (self
->max_horz
&& self
->max_vert
? NULL
: &desired
));
2811 /* set the size and position if maximized */
2812 if (self
->max_horz
) {
2814 *w
= a
->width
- self
->frame
->size
.left
- self
->frame
->size
.right
;
2816 if (self
->max_vert
) {
2818 *h
= a
->height
- self
->frame
->size
.top
- self
->frame
->size
.bottom
;
2821 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2827 /* gets the client's position */
2828 frame_frame_gravity(self
->frame
, x
, y
);
2830 /* work within the preferred sizes given by the window, these may have
2831 changed rather than it's requested width and height, so always run
2832 through this code */
2834 gint basew
, baseh
, minw
, minh
;
2836 gfloat minratio
, maxratio
;
2838 incw
= self
->fullscreen
|| self
->max_horz
? 1 : self
->size_inc
.width
;
2839 inch
= self
->fullscreen
|| self
->max_vert
? 1 : self
->size_inc
.height
;
2840 minratio
= self
->fullscreen
|| (self
->max_horz
&& self
->max_vert
) ?
2841 0 : self
->min_ratio
;
2842 maxratio
= self
->fullscreen
|| (self
->max_horz
&& self
->max_vert
) ?
2843 0 : self
->max_ratio
;
2845 /* base size is substituted with min size if not specified */
2846 if (self
->base_size
.width
>= 0 || self
->base_size
.height
>= 0) {
2847 basew
= self
->base_size
.width
;
2848 baseh
= self
->base_size
.height
;
2850 basew
= self
->min_size
.width
;
2851 baseh
= self
->min_size
.height
;
2853 /* min size is substituted with base size if not specified */
2854 if (self
->min_size
.width
|| self
->min_size
.height
) {
2855 minw
= self
->min_size
.width
;
2856 minh
= self
->min_size
.height
;
2858 minw
= self
->base_size
.width
;
2859 minh
= self
->base_size
.height
;
2862 /* This comment is no longer true */
2863 /* if this is a user-requested resize, then check against min/max
2866 /* smaller than min size or bigger than max size? */
2867 if (*w
> self
->max_size
.width
) *w
= self
->max_size
.width
;
2868 if (*w
< minw
) *w
= minw
;
2869 if (*h
> self
->max_size
.height
) *h
= self
->max_size
.height
;
2870 if (*h
< minh
) *h
= minh
;
2875 /* keep to the increments */
2879 /* you cannot resize to nothing */
2880 if (basew
+ *w
< 1) *w
= 1 - basew
;
2881 if (baseh
+ *h
< 1) *h
= 1 - baseh
;
2883 /* save the logical size */
2884 *logicalw
= incw
> 1 ? *w
: *w
+ basew
;
2885 *logicalh
= inch
> 1 ? *h
: *h
+ baseh
;
2893 /* adjust the height to match the width for the aspect ratios.
2894 for this, min size is not substituted for base size ever. */
2895 *w
-= self
->base_size
.width
;
2896 *h
-= self
->base_size
.height
;
2899 if (*h
* minratio
> *w
) {
2900 *h
= (gint
)(*w
/ minratio
);
2902 /* you cannot resize to nothing */
2905 *w
= (gint
)(*h
* minratio
);
2909 if (*h
* maxratio
< *w
) {
2910 *h
= (gint
)(*w
/ maxratio
);
2912 /* you cannot resize to nothing */
2915 *w
= (gint
)(*h
* minratio
);
2919 *w
+= self
->base_size
.width
;
2920 *h
+= self
->base_size
.height
;
2923 /* these override the above states! if you cant move you can't move! */
2925 if (!(self
->functions
& OB_CLIENT_FUNC_MOVE
)) {
2929 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
)) {
2930 *w
= self
->area
.width
;
2931 *h
= self
->area
.height
;
2939 void client_configure(ObClient
*self
, gint x
, gint y
, gint w
, gint h
,
2940 gboolean user
, gboolean final
, gboolean force_reply
)
2944 gboolean send_resize_client
;
2945 gboolean moved
= FALSE
, resized
= FALSE
, rootmoved
= FALSE
;
2946 gboolean fmoved
, fresized
;
2947 guint fdecor
= self
->frame
->decorations
;
2948 gboolean fhorz
= self
->frame
->max_horz
;
2949 gboolean fvert
= self
->frame
->max_vert
;
2950 gint logicalw
, logicalh
;
2952 /* find the new x, y, width, and height (and logical size) */
2953 client_try_configure(self
, &x
, &y
, &w
, &h
, &logicalw
, &logicalh
, user
);
2955 /* set the logical size if things changed */
2956 if (!(w
== self
->area
.width
&& h
== self
->area
.height
))
2957 SIZE_SET(self
->logical_size
, logicalw
, logicalh
);
2959 /* figure out if we moved or resized or what */
2960 moved
= (x
!= self
->area
.x
|| y
!= self
->area
.y
);
2961 resized
= (w
!= self
->area
.width
|| h
!= self
->area
.height
);
2963 oldw
= self
->area
.width
;
2964 oldh
= self
->area
.height
;
2965 oldframe
= self
->frame
->area
;
2966 RECT_SET(self
->area
, x
, y
, w
, h
);
2968 /* for app-requested resizes, always resize if 'resized' is true.
2969 for user-requested ones, only resize if final is true, or when
2970 resizing in redraw mode */
2971 send_resize_client
= ((!user
&& resized
) ||
2973 (resized
&& config_resize_redraw
))));
2975 /* if the client is enlarging, then resize the client before the frame */
2976 if (send_resize_client
&& (w
> oldw
|| h
> oldh
)) {
2977 XMoveResizeWindow(obt_display
, self
->window
,
2978 self
->frame
->size
.left
, self
->frame
->size
.top
,
2979 MAX(w
, oldw
), MAX(h
, oldh
));
2980 frame_adjust_client_area(self
->frame
);
2983 /* find the frame's dimensions and move/resize it */
2987 /* if decorations changed, then readjust everything for the frame */
2988 if (self
->decorations
!= fdecor
||
2989 self
->max_horz
!= fhorz
|| self
->max_vert
!= fvert
)
2991 fmoved
= fresized
= TRUE
;
2994 /* adjust the frame */
2995 if (fmoved
|| fresized
) {
2996 gulong ignore_start
;
2998 ignore_start
= event_start_ignore_all_enters();
3000 /* replay pending pointer event before move the window, in case it
3001 would change what window gets the event */
3002 mouse_replay_pointer();
3004 frame_adjust_area(self
->frame
, fmoved
, fresized
, FALSE
);
3007 event_end_ignore_all_enters(ignore_start
);
3010 if (!user
|| final
) {
3011 gint oldrx
= self
->root_pos
.x
;
3012 gint oldry
= self
->root_pos
.y
;
3013 /* we have reset the client to 0 border width, so don't include
3014 it in these coords */
3015 POINT_SET(self
->root_pos
,
3016 self
->frame
->area
.x
+ self
->frame
->size
.left
-
3018 self
->frame
->area
.y
+ self
->frame
->size
.top
-
3019 self
->border_width
);
3020 if (self
->root_pos
.x
!= oldrx
|| self
->root_pos
.y
!= oldry
)
3024 /* This is kinda tricky and should not be changed.. let me explain!
3026 When user = FALSE, then the request is coming from the application
3027 itself, and we are more strict about when to send a synthetic
3028 ConfigureNotify. We strictly follow the rules of the ICCCM sec 4.1.5
3029 in this case (if force_reply is true)
3031 When user = TRUE, then the request is coming from "us", like when we
3032 maximize a window or something. In this case we are more lenient. We
3033 used to follow the same rules as above, but _Java_ Swing can't handle
3034 this. So just to appease Swing, when user = TRUE, we always send
3035 a synthetic ConfigureNotify to give the window its root coordinates.
3037 if ((!user
&& !resized
&& (rootmoved
|| force_reply
)) ||
3038 (user
&& final
&& rootmoved
))
3042 event
.type
= ConfigureNotify
;
3043 event
.xconfigure
.display
= obt_display
;
3044 event
.xconfigure
.event
= self
->window
;
3045 event
.xconfigure
.window
= self
->window
;
3047 ob_debug("Sending ConfigureNotify to %s for %d,%d %dx%d",
3048 self
->title
, self
->root_pos
.x
, self
->root_pos
.y
, w
, h
);
3050 /* root window real coords */
3051 event
.xconfigure
.x
= self
->root_pos
.x
;
3052 event
.xconfigure
.y
= self
->root_pos
.y
;
3053 event
.xconfigure
.width
= w
;
3054 event
.xconfigure
.height
= h
;
3055 event
.xconfigure
.border_width
= self
->border_width
;
3056 event
.xconfigure
.above
= None
;
3057 event
.xconfigure
.override_redirect
= FALSE
;
3058 XSendEvent(event
.xconfigure
.display
, event
.xconfigure
.window
,
3059 FALSE
, StructureNotifyMask
, &event
);
3062 /* if the client is shrinking, then resize the frame before the client.
3064 both of these resize sections may run, because the top one only resizes
3065 in the direction that is growing
3067 if (send_resize_client
&& (w
<= oldw
|| h
<= oldh
)) {
3068 frame_adjust_client_area(self
->frame
);
3069 XMoveResizeWindow(obt_display
, self
->window
,
3070 self
->frame
->size
.left
, self
->frame
->size
.top
, w
, h
);
3073 XFlush(obt_display
);
3075 /* if it moved between monitors, then this can affect the stacking
3076 layer of this window or others - for fullscreen windows */
3077 if (screen_find_monitor(&self
->frame
->area
) !=
3078 screen_find_monitor(&oldframe
))
3080 client_calc_layer(self
);
3084 void client_fullscreen(ObClient
*self
, gboolean fs
)
3088 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) || /* can't */
3089 self
->fullscreen
== fs
) return; /* already done */
3091 self
->fullscreen
= fs
;
3092 client_change_state(self
); /* change the state hints on the client */
3095 self
->pre_fullscreen_area
= self
->area
;
3096 /* if the window is maximized, its area isn't all that meaningful.
3097 save its premax area instead. */
3098 if (self
->max_horz
) {
3099 self
->pre_fullscreen_area
.x
= self
->pre_max_area
.x
;
3100 self
->pre_fullscreen_area
.width
= self
->pre_max_area
.width
;
3102 if (self
->max_vert
) {
3103 self
->pre_fullscreen_area
.y
= self
->pre_max_area
.y
;
3104 self
->pre_fullscreen_area
.height
= self
->pre_max_area
.height
;
3107 /* these will help configure_full figure out where to fullscreen
3111 w
= self
->area
.width
;
3112 h
= self
->area
.height
;
3114 g_assert(self
->pre_fullscreen_area
.width
> 0 &&
3115 self
->pre_fullscreen_area
.height
> 0);
3117 x
= self
->pre_fullscreen_area
.x
;
3118 y
= self
->pre_fullscreen_area
.y
;
3119 w
= self
->pre_fullscreen_area
.width
;
3120 h
= self
->pre_fullscreen_area
.height
;
3121 RECT_SET(self
->pre_fullscreen_area
, 0, 0, 0, 0);
3124 ob_debug("Window %s going fullscreen (%d)",
3125 self
->title
, self
->fullscreen
);
3127 client_setup_decor_and_functions(self
, FALSE
);
3128 client_move_resize(self
, x
, y
, w
, h
);
3130 /* and adjust our layer/stacking. do this after resizing the window,
3131 and applying decorations, because windows which fill the screen are
3132 considered "fullscreen" and it affects their layer */
3133 client_calc_layer(self
);
3136 /* try focus us when we go into fullscreen mode */
3141 static void client_iconify_recursive(ObClient
*self
,
3142 gboolean iconic
, gboolean curdesk
,
3143 gboolean hide_animation
)
3146 gboolean changed
= FALSE
;
3148 if (self
->iconic
!= iconic
) {
3149 ob_debug("%sconifying window: 0x%lx", (iconic
? "I" : "Uni"),
3153 /* don't let non-normal windows iconify along with their parents
3155 if (client_normal(self
)) {
3156 self
->iconic
= iconic
;
3158 /* update the focus lists.. iconic windows go to the bottom of
3160 focus_order_to_bottom(self
);
3165 self
->iconic
= iconic
;
3167 if (curdesk
&& self
->desktop
!= screen_desktop
&&
3168 self
->desktop
!= DESKTOP_ALL
)
3169 client_set_desktop(self
, screen_desktop
, FALSE
, FALSE
);
3171 /* this puts it after the current focused window */
3172 focus_order_remove(self
);
3173 focus_order_add_new(self
);
3180 client_change_state(self
);
3181 if (config_animate_iconify
&& !hide_animation
)
3182 frame_begin_iconify_animation(self
->frame
, iconic
);
3183 /* do this after starting the animation so it doesn't flash */
3184 client_showhide(self
);
3186 hooks_queue((iconic
? OB_HOOK_WIN_ICONIC
: OB_HOOK_WIN_UNICONIC
),
3190 /* iconify all direct transients, and deiconify all transients
3192 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3193 if (it
->data
!= self
)
3194 if (client_is_direct_child(self
, it
->data
) || !iconic
)
3195 client_iconify_recursive(it
->data
, iconic
, curdesk
,
3199 void client_iconify(ObClient
*self
, gboolean iconic
, gboolean curdesk
,
3200 gboolean hide_animation
)
3202 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
|| !iconic
) {
3203 /* move up the transient chain as far as possible first */
3204 self
= client_search_top_direct_parent(self
);
3205 client_iconify_recursive(self
, iconic
, curdesk
, hide_animation
);
3209 void client_maximize(ObClient
*self
, gboolean max
, gint dir
)
3213 g_assert(dir
== 0 || dir
== 1 || dir
== 2);
3214 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && max
) return;/* can't */
3216 /* check if already done */
3218 if (dir
== 0 && self
->max_horz
&& self
->max_vert
) return;
3219 if (dir
== 1 && self
->max_horz
) return;
3220 if (dir
== 2 && self
->max_vert
) return;
3222 if (dir
== 0 && !self
->max_horz
&& !self
->max_vert
) return;
3223 if (dir
== 1 && !self
->max_horz
) return;
3224 if (dir
== 2 && !self
->max_vert
) return;
3227 /* these will help configure_full figure out which screen to fill with
3231 w
= self
->area
.width
;
3232 h
= self
->area
.height
;
3235 if ((dir
== 0 || dir
== 1) && !self
->max_horz
) { /* horz */
3236 RECT_SET(self
->pre_max_area
,
3237 self
->area
.x
, self
->pre_max_area
.y
,
3238 self
->area
.width
, self
->pre_max_area
.height
);
3240 if ((dir
== 0 || dir
== 2) && !self
->max_vert
) { /* vert */
3241 RECT_SET(self
->pre_max_area
,
3242 self
->pre_max_area
.x
, self
->area
.y
,
3243 self
->pre_max_area
.width
, self
->area
.height
);
3246 if ((dir
== 0 || dir
== 1) && self
->max_horz
) { /* horz */
3247 g_assert(self
->pre_max_area
.width
> 0);
3249 x
= self
->pre_max_area
.x
;
3250 w
= self
->pre_max_area
.width
;
3252 RECT_SET(self
->pre_max_area
, 0, self
->pre_max_area
.y
,
3253 0, self
->pre_max_area
.height
);
3255 if ((dir
== 0 || dir
== 2) && self
->max_vert
) { /* vert */
3256 g_assert(self
->pre_max_area
.height
> 0);
3258 y
= self
->pre_max_area
.y
;
3259 h
= self
->pre_max_area
.height
;
3261 RECT_SET(self
->pre_max_area
, self
->pre_max_area
.x
, 0,
3262 self
->pre_max_area
.width
, 0);
3266 if (dir
== 0 || dir
== 1) /* horz */
3267 self
->max_horz
= max
;
3268 if (dir
== 0 || dir
== 2) /* vert */
3269 self
->max_vert
= max
;
3271 client_change_state(self
); /* change the state hints on the client */
3273 client_setup_decor_and_functions(self
, FALSE
);
3274 client_move_resize(self
, x
, y
, w
, h
);
3276 hooks_queue((max
? OB_HOOK_WIN_MAX
: OB_HOOK_WIN_UNMAX
), self
);
3279 void client_shade(ObClient
*self
, gboolean shade
)
3281 if ((!(self
->functions
& OB_CLIENT_FUNC_SHADE
) &&
3282 shade
) || /* can't shade */
3283 self
->shaded
== shade
) return; /* already done */
3285 self
->shaded
= shade
;
3286 client_change_state(self
);
3287 client_change_wm_state(self
); /* the window is being hidden/shown */
3288 /* resize the frame to just the titlebar */
3289 frame_adjust_area(self
->frame
, FALSE
, TRUE
, FALSE
);
3291 hooks_queue((shade
? OB_HOOK_WIN_SHADE
: OB_HOOK_WIN_UNSHADE
), self
);
3294 static void client_ping_event(ObClient
*self
, gboolean dead
)
3296 if (self
->not_responding
!= dead
) {
3297 self
->not_responding
= dead
;
3298 client_update_title(self
);
3301 /* the client isn't responding, so ask to kill it */
3302 client_prompt_kill(self
);
3304 /* it came back to life ! */
3306 if (self
->kill_prompt
) {
3307 prompt_unref(self
->kill_prompt
);
3308 self
->kill_prompt
= NULL
;
3311 self
->kill_level
= 0;
3316 void client_close(ObClient
*self
)
3318 if (!(self
->functions
& OB_CLIENT_FUNC_CLOSE
)) return;
3320 /* if closing an internal obprompt, that is just cancelling it */
3322 prompt_cancel(self
->prompt
);
3326 /* in the case that the client provides no means to requesting that it
3327 close, we just kill it */
3328 if (!self
->delete_window
)
3329 /* don't use client_kill(), we should only kill based on PID in
3330 response to a lack of PING replies */
3331 XKillClient(obt_display
, self
->window
);
3333 /* request the client to close with WM_DELETE_WINDOW */
3334 OBT_PROP_MSG_TO(self
->window
, self
->window
, WM_PROTOCOLS
,
3335 OBT_PROP_ATOM(WM_DELETE_WINDOW
), event_curtime
,
3336 0, 0, 0, NoEventMask
);
3338 /* we're trying to close the window, so see if it is responding. if it
3339 is not, then we will let them kill the window */
3341 ping_start(self
, client_ping_event
);
3343 /* if we already know the window isn't responding (maybe they clicked
3344 no in the kill dialog but it hasn't come back to life), then show
3346 if (self
->not_responding
)
3347 client_prompt_kill(self
);
3351 #define OB_KILL_RESULT_NO 0
3352 #define OB_KILL_RESULT_YES 1
3354 static gboolean
client_kill_requested(ObPrompt
*p
, gint result
, gpointer data
)
3356 ObClient
*self
= data
;
3358 if (result
== OB_KILL_RESULT_YES
)
3360 return TRUE
; /* call the cleanup func */
3363 static void client_kill_cleanup(ObPrompt
*p
, gpointer data
)
3365 ObClient
*self
= data
;
3367 g_assert(p
== self
->kill_prompt
);
3369 prompt_unref(self
->kill_prompt
);
3370 self
->kill_prompt
= NULL
;
3373 static void client_prompt_kill(ObClient
*self
)
3375 /* check if we're already prompting */
3376 if (!self
->kill_prompt
) {
3377 ObPromptAnswer answers
[] = {
3378 { 0, OB_KILL_RESULT_NO
},
3379 { 0, OB_KILL_RESULT_YES
}
3382 const gchar
*y
, *title
;
3384 title
= self
->original_title
;
3385 if (title
[0] == '\0') {
3386 /* empty string, so use its parent */
3387 ObClient
*p
= client_search_top_direct_parent(self
);
3388 if (p
) title
= p
->original_title
;
3391 if (client_on_localhost(self
)) {
3394 if (self
->kill_level
== 0)
3400 (_("The window \"%s\" does not seem to be responding. Do you want to force it to exit by sending the %s signal?"),
3402 y
= _("End Process");
3406 (_("The window \"%s\" does not seem to be responding. Do you want to disconnect it from the X server?"),
3408 y
= _("Disconnect");
3410 /* set the dialog buttons' text */
3411 answers
[0].text
= _("Cancel"); /* "no" */
3412 answers
[1].text
= y
; /* "yes" */
3414 self
->kill_prompt
= prompt_new(m
, NULL
, answers
,
3415 sizeof(answers
)/sizeof(answers
[0]),
3416 OB_KILL_RESULT_NO
, /* default = no */
3417 OB_KILL_RESULT_NO
, /* cancel = no */
3418 client_kill_requested
,
3419 client_kill_cleanup
,
3424 prompt_show(self
->kill_prompt
, self
, TRUE
);
3427 void client_kill(ObClient
*self
)
3429 /* don't kill our own windows */
3430 if (self
->prompt
) return;
3432 if (client_on_localhost(self
) && self
->pid
) {
3433 /* running on the local host */
3434 if (self
->kill_level
== 0) {
3435 ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
3436 self
->window
, self
->pid
);
3437 kill(self
->pid
, SIGTERM
);
3440 /* show that we're trying to kill it */
3441 client_update_title(self
);
3444 ob_debug("killing window 0x%x with pid %lu, with SIGKILL",
3445 self
->window
, self
->pid
);
3446 kill(self
->pid
, SIGKILL
); /* kill -9 */
3450 /* running on a remote host */
3451 XKillClient(obt_display
, self
->window
);
3455 void client_hilite(ObClient
*self
, gboolean hilite
)
3457 if (self
->demands_attention
== hilite
)
3458 return; /* no change */
3460 /* don't allow focused windows to hilite */
3461 self
->demands_attention
= hilite
&& !client_focused(self
);
3462 if (self
->frame
!= NULL
) { /* if we're mapping, just set the state */
3463 if (self
->demands_attention
)
3464 frame_flash_start(self
->frame
);
3466 frame_flash_stop(self
->frame
);
3467 client_change_state(self
);
3471 static void client_set_desktop_recursive(ObClient
*self
,
3479 if (target
!= self
->desktop
&& self
->type
!= OB_CLIENT_TYPE_DESKTOP
) {
3481 ob_debug("Setting desktop %u", target
+1);
3483 g_assert(target
< screen_num_desktops
|| target
== DESKTOP_ALL
);
3485 old
= self
->desktop
;
3486 self
->desktop
= target
;
3487 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, target
);
3488 /* the frame can display the current desktop state */
3489 frame_adjust_state(self
->frame
);
3490 /* 'move' the window to the new desktop */
3494 /* raise if it was not already on the desktop */
3495 if (old
!= DESKTOP_ALL
&& !dontraise
)
3496 stacking_raise(CLIENT_AS_WINDOW(self
));
3497 if (STRUT_EXISTS(self
->strut
))
3498 screen_update_areas();
3500 /* the new desktop's geometry may be different, so we may need to
3501 resize, for example if we are maximized */
3502 client_reconfigure(self
, FALSE
);
3504 if (old
!= self
->desktop
)
3505 hooks_queue(OB_HOOK_WIN_DESK_CHANGE
, self
);
3508 /* move all transients */
3509 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3510 if (it
->data
!= self
)
3511 if (client_is_direct_child(self
, it
->data
))
3512 client_set_desktop_recursive(it
->data
, target
,
3513 donthide
, dontraise
);
3516 void client_set_desktop(ObClient
*self
, guint target
,
3517 gboolean donthide
, gboolean dontraise
)
3519 self
= client_search_top_direct_parent(self
);
3520 client_set_desktop_recursive(self
, target
, donthide
, dontraise
);
3523 gboolean
client_is_direct_child(ObClient
*parent
, ObClient
*child
)
3525 while (child
!= parent
&& (child
= client_direct_parent(child
)));
3526 return child
== parent
;
3529 ObClient
*client_search_modal_child(ObClient
*self
)
3534 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
3535 ObClient
*c
= it
->data
;
3536 if ((ret
= client_search_modal_child(c
))) return ret
;
3537 if (c
->modal
) return c
;
3542 static gboolean
client_validate_unmap(ObClient
*self
, int n
)
3545 gboolean ret
= TRUE
;
3547 if (XCheckTypedWindowEvent(obt_display
, self
->window
, UnmapNotify
, &e
)) {
3548 if (n
< self
->ignore_unmaps
) // ignore this one, but look for more
3549 ret
= client_validate_unmap(self
, n
+1);
3551 ret
= FALSE
; // the window is going to become unmanaged
3553 /* put them back on the event stack so they end up in the same order */
3554 XPutBackEvent(obt_display
, &e
);
3560 gboolean
client_validate(ObClient
*self
)
3564 XSync(obt_display
, FALSE
); /* get all events on the server */
3566 if (XCheckTypedWindowEvent(obt_display
, self
->window
, DestroyNotify
, &e
)) {
3567 XPutBackEvent(obt_display
, &e
);
3571 if (!client_validate_unmap(self
, 0))
3577 void client_set_wm_state(ObClient
*self
, glong state
)
3579 if (state
== self
->wmstate
) return; /* no change */
3583 client_iconify(self
, TRUE
, TRUE
, FALSE
);
3586 client_iconify(self
, FALSE
, TRUE
, FALSE
);
3591 void client_set_state(ObClient
*self
, Atom action
, glong data1
, glong data2
)
3593 gboolean shaded
= self
->shaded
;
3594 gboolean fullscreen
= self
->fullscreen
;
3595 gboolean undecorated
= self
->undecorated
;
3596 gboolean max_horz
= self
->max_horz
;
3597 gboolean max_vert
= self
->max_vert
;
3598 gboolean modal
= self
->modal
;
3599 gboolean iconic
= self
->iconic
;
3600 gboolean demands_attention
= self
->demands_attention
;
3601 gboolean above
= self
->above
;
3602 gboolean below
= self
->below
;
3606 if (!(action
== OBT_PROP_ATOM(NET_WM_STATE_ADD
) ||
3607 action
== OBT_PROP_ATOM(NET_WM_STATE_REMOVE
) ||
3608 action
== OBT_PROP_ATOM(NET_WM_STATE_TOGGLE
)))
3609 /* an invalid action was passed to the client message, ignore it */
3612 for (i
= 0; i
< 2; ++i
) {
3613 Atom state
= i
== 0 ? data1
: data2
;
3615 if (!state
) continue;
3617 /* if toggling, then pick whether we're adding or removing */
3618 if (action
== OBT_PROP_ATOM(NET_WM_STATE_TOGGLE
)) {
3619 if (state
== OBT_PROP_ATOM(NET_WM_STATE_MODAL
))
3621 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
))
3622 value
= self
->max_vert
;
3623 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
))
3624 value
= self
->max_horz
;
3625 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SHADED
))
3627 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
))
3628 value
= self
->skip_taskbar
;
3629 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
))
3630 value
= self
->skip_pager
;
3631 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
))
3632 value
= self
->iconic
;
3633 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
))
3635 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_ABOVE
))
3636 value
= self
->above
;
3637 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_BELOW
))
3638 value
= self
->below
;
3639 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
))
3640 value
= self
->demands_attention
;
3641 else if (state
== OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
))
3642 value
= undecorated
;
3643 action
= value
? OBT_PROP_ATOM(NET_WM_STATE_REMOVE
) :
3644 OBT_PROP_ATOM(NET_WM_STATE_ADD
);
3647 value
= action
== OBT_PROP_ATOM(NET_WM_STATE_ADD
);
3648 if (state
== OBT_PROP_ATOM(NET_WM_STATE_MODAL
)) {
3650 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
)) {
3652 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
)) {
3654 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SHADED
)) {
3656 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
)) {
3657 self
->skip_taskbar
= value
;
3658 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
)) {
3659 self
->skip_pager
= value
;
3660 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
)) {
3662 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
)) {
3664 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_ABOVE
)) {
3666 /* only unset below when setting above, otherwise you can't get to
3670 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_BELOW
)) {
3671 /* and vice versa */
3675 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
)){
3676 demands_attention
= value
;
3677 } else if (state
== OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
)) {
3678 undecorated
= value
;
3682 if (max_horz
!= self
->max_horz
|| max_vert
!= self
->max_vert
) {
3683 if (max_horz
!= self
->max_horz
&& max_vert
!= self
->max_vert
) {
3685 if (max_horz
== max_vert
) { /* both going the same way */
3686 client_maximize(self
, max_horz
, 0);
3688 client_maximize(self
, max_horz
, 1);
3689 client_maximize(self
, max_vert
, 2);
3693 if (max_horz
!= self
->max_horz
)
3694 client_maximize(self
, max_horz
, 1);
3696 client_maximize(self
, max_vert
, 2);
3699 /* change fullscreen state before shading, as it will affect if the window
3701 if (fullscreen
!= self
->fullscreen
)
3702 client_fullscreen(self
, fullscreen
);
3703 if (shaded
!= self
->shaded
)
3704 client_shade(self
, shaded
);
3705 if (undecorated
!= self
->undecorated
)
3706 client_set_undecorated(self
, undecorated
);
3707 if (above
!= self
->above
|| below
!= self
->below
) {
3708 self
->above
= above
;
3709 self
->below
= below
;
3710 client_calc_layer(self
);
3713 if (modal
!= self
->modal
) {
3714 self
->modal
= modal
;
3715 /* when a window changes modality, then its stacking order with its
3716 transients needs to change */
3717 stacking_raise(CLIENT_AS_WINDOW(self
));
3719 /* it also may get focused. if something is focused that shouldn't
3720 be focused anymore, then move the focus */
3721 if (focus_client
&& client_focus_target(focus_client
) != focus_client
)
3722 client_focus(focus_client
);
3725 if (iconic
!= self
->iconic
)
3726 client_iconify(self
, iconic
, FALSE
, FALSE
);
3728 if (demands_attention
!= self
->demands_attention
)
3729 client_hilite(self
, demands_attention
);
3731 client_change_state(self
); /* change the hint to reflect these changes */
3734 ObClient
*client_focus_target(ObClient
*self
)
3736 ObClient
*child
= NULL
;
3738 child
= client_search_modal_child(self
);
3739 if (child
) return child
;
3743 gboolean
client_can_focus(ObClient
*self
)
3745 /* choose the correct target */
3746 self
= client_focus_target(self
);
3748 if (!self
->frame
->visible
)
3751 if (!(self
->can_focus
|| self
->focus_notify
))
3757 gboolean
client_focus(ObClient
*self
)
3759 /* we might not focus this window, so if we have modal children which would
3760 be focused instead, bring them to this desktop */
3761 client_bring_modal_windows(self
);
3763 /* choose the correct target */
3764 self
= client_focus_target(self
);
3766 if (!client_can_focus(self
)) {
3767 ob_debug_type(OB_DEBUG_FOCUS
,
3768 "Client %s can't be focused", self
->title
);
3772 ob_debug_type(OB_DEBUG_FOCUS
,
3773 "Focusing client \"%s\" (0x%x) at time %u",
3774 self
->title
, self
->window
, event_curtime
);
3776 /* if using focus_delay, stop the timer now so that focus doesn't
3778 event_halt_focus_delay();
3780 event_cancel_all_key_grabs();
3782 obt_display_ignore_errors(TRUE
);
3784 if (self
->can_focus
) {
3785 /* This can cause a BadMatch error with CurrentTime, or if an app
3786 passed in a bad time for _NET_WM_ACTIVE_WINDOW. */
3787 XSetInputFocus(obt_display
, self
->window
, RevertToPointerRoot
,
3791 if (self
->focus_notify
) {
3793 ce
.xclient
.type
= ClientMessage
;
3794 ce
.xclient
.message_type
= OBT_PROP_ATOM(WM_PROTOCOLS
);
3795 ce
.xclient
.display
= obt_display
;
3796 ce
.xclient
.window
= self
->window
;
3797 ce
.xclient
.format
= 32;
3798 ce
.xclient
.data
.l
[0] = OBT_PROP_ATOM(WM_TAKE_FOCUS
);
3799 ce
.xclient
.data
.l
[1] = event_curtime
;
3800 ce
.xclient
.data
.l
[2] = 0l;
3801 ce
.xclient
.data
.l
[3] = 0l;
3802 ce
.xclient
.data
.l
[4] = 0l;
3803 XSendEvent(obt_display
, self
->window
, FALSE
, NoEventMask
, &ce
);
3806 obt_display_ignore_errors(FALSE
);
3808 ob_debug_type(OB_DEBUG_FOCUS
, "Error focusing? %d",
3809 obt_display_error_occured
);
3810 return !obt_display_error_occured
;
3813 static void client_present(ObClient
*self
, gboolean here
, gboolean raise
,
3816 if (client_normal(self
) && screen_showing_desktop
)
3817 screen_show_desktop(FALSE
, self
);
3819 client_iconify(self
, FALSE
, here
, FALSE
);
3820 if (self
->desktop
!= DESKTOP_ALL
&&
3821 self
->desktop
!= screen_desktop
)
3824 client_set_desktop(self
, screen_desktop
, FALSE
, TRUE
);
3826 screen_set_desktop(self
->desktop
, FALSE
);
3827 } else if (!self
->frame
->visible
)
3828 /* if its not visible for other reasons, then don't mess
3831 if (self
->shaded
&& unshade
)
3832 client_shade(self
, FALSE
);
3834 stacking_raise(CLIENT_AS_WINDOW(self
));
3839 /* this function exists to map to the net_active_window message in the ewmh */
3840 void client_activate(ObClient
*self
, gboolean here
, gboolean raise
,
3841 gboolean unshade
, gboolean user
)
3843 if (user
|| (self
->desktop
== DESKTOP_ALL
||
3844 self
->desktop
== screen_desktop
))
3845 client_present(self
, here
, raise
, unshade
);
3847 client_hilite(self
, TRUE
);
3850 static void client_bring_windows_recursive(ObClient
*self
,
3858 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3859 client_bring_windows_recursive(it
->data
, desktop
,
3860 helpers
, modals
, iconic
);
3862 if (((helpers
&& client_helper(self
)) ||
3863 (modals
&& self
->modal
)) &&
3864 ((self
->desktop
!= desktop
&& self
->desktop
!= DESKTOP_ALL
) ||
3865 (iconic
&& self
->iconic
)))
3867 if (iconic
&& self
->iconic
)
3868 client_iconify(self
, FALSE
, TRUE
, FALSE
);
3870 client_set_desktop(self
, desktop
, FALSE
, FALSE
);
3874 void client_bring_helper_windows(ObClient
*self
)
3876 client_bring_windows_recursive(self
, self
->desktop
, TRUE
, FALSE
, FALSE
);
3879 void client_bring_modal_windows(ObClient
*self
)
3881 client_bring_windows_recursive(self
, self
->desktop
, FALSE
, TRUE
, TRUE
);
3884 gboolean
client_focused(ObClient
*self
)
3886 return self
== focus_client
;
3889 RrImage
* client_icon(ObClient
*self
)
3891 RrImage
*ret
= NULL
;
3894 ret
= self
->icon_set
;
3895 else if (self
->parents
) {
3897 for (it
= self
->parents
; it
&& !ret
; it
= g_slist_next(it
))
3898 ret
= client_icon(it
->data
);
3901 ret
= client_default_icon
;
3905 void client_set_layer(ObClient
*self
, gint layer
)
3909 self
->above
= FALSE
;
3910 } else if (layer
== 0) {
3911 self
->below
= self
->above
= FALSE
;
3913 self
->below
= FALSE
;
3916 client_calc_layer(self
);
3917 client_change_state(self
); /* reflect this in the state hints */
3920 void client_set_undecorated(ObClient
*self
, gboolean undecorated
)
3922 if (self
->undecorated
!= undecorated
&&
3923 /* don't let it undecorate if the function is missing, but let
3925 (self
->functions
& OB_CLIENT_FUNC_UNDECORATE
|| !undecorated
))
3927 self
->undecorated
= undecorated
;
3928 client_setup_decor_and_functions(self
, TRUE
);
3929 client_change_state(self
); /* reflect this in the state hints */
3931 hooks_queue((undecorated
?
3932 OB_HOOK_WIN_UNDECORATED
: OB_HOOK_WIN_DECORATED
), self
);
3936 guint
client_monitor(ObClient
*self
)
3938 return screen_find_monitor(&self
->frame
->area
);
3941 ObClient
*client_direct_parent(ObClient
*self
)
3943 if (!self
->parents
) return NULL
;
3944 if (self
->transient_for_group
) return NULL
;
3945 return self
->parents
->data
;
3948 ObClient
*client_search_top_direct_parent(ObClient
*self
)
3951 while ((p
= client_direct_parent(self
))) self
= p
;
3955 static GSList
*client_search_all_top_parents_internal(ObClient
*self
,
3957 ObStackingLayer layer
)
3962 /* move up the direct transient chain as far as possible */
3963 while ((p
= client_direct_parent(self
)) &&
3964 (!bylayer
|| p
->layer
== layer
))
3968 ret
= g_slist_prepend(NULL
, self
);
3970 ret
= g_slist_copy(self
->parents
);
3975 GSList
*client_search_all_top_parents(ObClient
*self
)
3977 return client_search_all_top_parents_internal(self
, FALSE
, 0);
3980 GSList
*client_search_all_top_parents_layer(ObClient
*self
)
3982 return client_search_all_top_parents_internal(self
, TRUE
, self
->layer
);
3985 ObClient
*client_search_focus_parent(ObClient
*self
)
3989 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
3990 if (client_focused(it
->data
)) return it
->data
;
3995 ObClient
*client_search_focus_parent_full(ObClient
*self
)
3998 ObClient
*ret
= NULL
;
4000 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
4001 if (client_focused(it
->data
))
4004 ret
= client_search_focus_parent_full(it
->data
);
4010 ObClient
*client_search_parent(ObClient
*self
, ObClient
*search
)
4014 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
4015 if (it
->data
== search
) return search
;
4020 ObClient
*client_search_transient(ObClient
*self
, ObClient
*search
)
4024 for (sit
= self
->transients
; sit
; sit
= g_slist_next(sit
)) {
4025 if (sit
->data
== search
)
4027 if (client_search_transient(sit
->data
, search
))
4033 static void detect_edge(Rect area
, ObDirection dir
,
4034 gint my_head
, gint my_size
,
4035 gint my_edge_start
, gint my_edge_size
,
4036 gint
*dest
, gboolean
*near_edge
)
4038 gint edge_start
, edge_size
, head
, tail
;
4039 gboolean skip_head
= FALSE
, skip_tail
= FALSE
;
4042 case OB_DIRECTION_NORTH
:
4043 case OB_DIRECTION_SOUTH
:
4044 edge_start
= area
.x
;
4045 edge_size
= area
.width
;
4047 case OB_DIRECTION_EAST
:
4048 case OB_DIRECTION_WEST
:
4049 edge_start
= area
.y
;
4050 edge_size
= area
.height
;
4053 g_assert_not_reached();
4056 /* do we collide with this window? */
4057 if (!RANGES_INTERSECT(my_edge_start
, my_edge_size
,
4058 edge_start
, edge_size
))
4062 case OB_DIRECTION_NORTH
:
4063 head
= RECT_BOTTOM(area
);
4064 tail
= RECT_TOP(area
);
4066 case OB_DIRECTION_SOUTH
:
4067 head
= RECT_TOP(area
);
4068 tail
= RECT_BOTTOM(area
);
4070 case OB_DIRECTION_WEST
:
4071 head
= RECT_RIGHT(area
);
4072 tail
= RECT_LEFT(area
);
4074 case OB_DIRECTION_EAST
:
4075 head
= RECT_LEFT(area
);
4076 tail
= RECT_RIGHT(area
);
4079 g_assert_not_reached();
4082 case OB_DIRECTION_NORTH
:
4083 case OB_DIRECTION_WEST
:
4084 /* check if our window is past the head of this window */
4085 if (my_head
<= head
+ 1)
4087 /* check if our window's tail is past the tail of this window */
4088 if (my_head
+ my_size
- 1 <= tail
)
4090 /* check if the head of this window is closer than the previously
4091 chosen edge (take into account that the previously chosen
4092 edge might have been a tail, not a head) */
4093 if (head
+ (*near_edge
? 0 : my_size
) <= *dest
)
4095 /* check if the tail of this window is closer than the previously
4096 chosen edge (take into account that the previously chosen
4097 edge might have been a head, not a tail) */
4098 if (tail
- (!*near_edge
? 0 : my_size
) <= *dest
)
4101 case OB_DIRECTION_SOUTH
:
4102 case OB_DIRECTION_EAST
:
4103 /* check if our window is past the head of this window */
4104 if (my_head
>= head
- 1)
4106 /* check if our window's tail is past the tail of this window */
4107 if (my_head
- my_size
+ 1 >= tail
)
4109 /* check if the head of this window is closer than the previously
4110 chosen edge (take into account that the previously chosen
4111 edge might have been a tail, not a head) */
4112 if (head
- (*near_edge
? 0 : my_size
) >= *dest
)
4114 /* check if the tail of this window is closer than the previously
4115 chosen edge (take into account that the previously chosen
4116 edge might have been a head, not a tail) */
4117 if (tail
+ (!*near_edge
? 0 : my_size
) >= *dest
)
4121 g_assert_not_reached();
4124 ob_debug("my head %d size %d", my_head
, my_size
);
4125 ob_debug("head %d tail %d dest %d", head
, tail
, *dest
);
4127 ob_debug("using near edge %d", head
);
4131 else if (!skip_tail
) {
4132 ob_debug("using far edge %d", tail
);
4138 void client_find_edge_directional(ObClient
*self
, ObDirection dir
,
4139 gint my_head
, gint my_size
,
4140 gint my_edge_start
, gint my_edge_size
,
4141 gint
*dest
, gboolean
*near_edge
)
4148 a
= screen_area(self
->desktop
, SCREEN_AREA_ALL_MONITORS
,
4149 &self
->frame
->area
);
4150 mon
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
,
4151 &self
->frame
->area
);
4154 case OB_DIRECTION_NORTH
:
4155 if (my_head
>= RECT_TOP(*mon
) + 1)
4156 edge
= RECT_TOP(*mon
) - 1;
4158 edge
= RECT_TOP(*a
) - 1;
4160 case OB_DIRECTION_SOUTH
:
4161 if (my_head
<= RECT_BOTTOM(*mon
) - 1)
4162 edge
= RECT_BOTTOM(*mon
) + 1;
4164 edge
= RECT_BOTTOM(*a
) + 1;
4166 case OB_DIRECTION_EAST
:
4167 if (my_head
<= RECT_RIGHT(*mon
) - 1)
4168 edge
= RECT_RIGHT(*mon
) + 1;
4170 edge
= RECT_RIGHT(*a
) + 1;
4172 case OB_DIRECTION_WEST
:
4173 if (my_head
>= RECT_LEFT(*mon
) + 1)
4174 edge
= RECT_LEFT(*mon
) - 1;
4176 edge
= RECT_LEFT(*a
) - 1;
4179 g_assert_not_reached();
4181 /* default to the far edge, then narrow it down */
4185 for (it
= client_list
; it
; it
= g_list_next(it
)) {
4186 ObClient
*cur
= it
->data
;
4188 /* skip windows to not bump into */
4193 if (self
->desktop
!= cur
->desktop
&& cur
->desktop
!= DESKTOP_ALL
&&
4194 cur
->desktop
!= screen_desktop
)
4197 ob_debug("trying window %s", cur
->title
);
4199 detect_edge(cur
->frame
->area
, dir
, my_head
, my_size
, my_edge_start
,
4200 my_edge_size
, dest
, near_edge
);
4202 dock_get_area(&dock_area
);
4203 detect_edge(dock_area
, dir
, my_head
, my_size
, my_edge_start
,
4204 my_edge_size
, dest
, near_edge
);
4209 void client_find_move_directional(ObClient
*self
, ObDirection dir
,
4213 gint e
, e_start
, e_size
;
4217 case OB_DIRECTION_EAST
:
4218 head
= RECT_RIGHT(self
->frame
->area
);
4219 size
= self
->frame
->area
.width
;
4220 e_start
= RECT_TOP(self
->frame
->area
);
4221 e_size
= self
->frame
->area
.height
;
4223 case OB_DIRECTION_WEST
:
4224 head
= RECT_LEFT(self
->frame
->area
);
4225 size
= self
->frame
->area
.width
;
4226 e_start
= RECT_TOP(self
->frame
->area
);
4227 e_size
= self
->frame
->area
.height
;
4229 case OB_DIRECTION_NORTH
:
4230 head
= RECT_TOP(self
->frame
->area
);
4231 size
= self
->frame
->area
.height
;
4232 e_start
= RECT_LEFT(self
->frame
->area
);
4233 e_size
= self
->frame
->area
.width
;
4235 case OB_DIRECTION_SOUTH
:
4236 head
= RECT_BOTTOM(self
->frame
->area
);
4237 size
= self
->frame
->area
.height
;
4238 e_start
= RECT_LEFT(self
->frame
->area
);
4239 e_size
= self
->frame
->area
.width
;
4242 g_assert_not_reached();
4245 client_find_edge_directional(self
, dir
, head
, size
,
4246 e_start
, e_size
, &e
, &near
);
4247 *x
= self
->frame
->area
.x
;
4248 *y
= self
->frame
->area
.y
;
4250 case OB_DIRECTION_EAST
:
4251 if (near
) e
-= self
->frame
->area
.width
;
4255 case OB_DIRECTION_WEST
:
4257 else e
-= self
->frame
->area
.width
;
4260 case OB_DIRECTION_NORTH
:
4262 else e
-= self
->frame
->area
.height
;
4265 case OB_DIRECTION_SOUTH
:
4266 if (near
) e
-= self
->frame
->area
.height
;
4271 g_assert_not_reached();
4273 frame_frame_gravity(self
->frame
, x
, y
);
4276 void client_find_resize_directional(ObClient
*self
, ObDirection side
,
4278 gint
*x
, gint
*y
, gint
*w
, gint
*h
)
4281 gint e
, e_start
, e_size
, delta
;
4286 case OB_DIRECTION_EAST
:
4287 head
= RECT_RIGHT(self
->frame
->area
) +
4288 (self
->size_inc
.width
- 1) * (grow
? 1 : 0);
4289 e_start
= RECT_TOP(self
->frame
->area
);
4290 e_size
= self
->frame
->area
.height
;
4291 dir
= grow
? OB_DIRECTION_EAST
: OB_DIRECTION_WEST
;
4293 case OB_DIRECTION_WEST
:
4294 head
= RECT_LEFT(self
->frame
->area
) -
4295 (self
->size_inc
.width
- 1) * (grow
? 1 : 0);
4296 e_start
= RECT_TOP(self
->frame
->area
);
4297 e_size
= self
->frame
->area
.height
;
4298 dir
= grow
? OB_DIRECTION_WEST
: OB_DIRECTION_EAST
;
4300 case OB_DIRECTION_NORTH
:
4301 head
= RECT_TOP(self
->frame
->area
) -
4302 (self
->size_inc
.height
- 1) * (grow
? 1 : 0);
4303 e_start
= RECT_LEFT(self
->frame
->area
);
4304 e_size
= self
->frame
->area
.width
;
4305 dir
= grow
? OB_DIRECTION_NORTH
: OB_DIRECTION_SOUTH
;
4307 case OB_DIRECTION_SOUTH
:
4308 head
= RECT_BOTTOM(self
->frame
->area
) +
4309 (self
->size_inc
.height
- 1) * (grow
? 1 : 0);
4310 e_start
= RECT_LEFT(self
->frame
->area
);
4311 e_size
= self
->frame
->area
.width
;
4312 dir
= grow
? OB_DIRECTION_SOUTH
: OB_DIRECTION_NORTH
;
4315 g_assert_not_reached();
4318 ob_debug("head %d dir %d", head
, dir
);
4319 client_find_edge_directional(self
, dir
, head
, 1,
4320 e_start
, e_size
, &e
, &near
);
4321 ob_debug("edge %d", e
);
4322 *x
= self
->frame
->area
.x
;
4323 *y
= self
->frame
->area
.y
;
4324 *w
= self
->frame
->area
.width
;
4325 *h
= self
->frame
->area
.height
;
4327 case OB_DIRECTION_EAST
:
4328 if (grow
== near
) --e
;
4329 delta
= e
- RECT_RIGHT(self
->frame
->area
);
4332 case OB_DIRECTION_WEST
:
4333 if (grow
== near
) ++e
;
4334 delta
= RECT_LEFT(self
->frame
->area
) - e
;
4338 case OB_DIRECTION_NORTH
:
4339 if (grow
== near
) ++e
;
4340 delta
= RECT_TOP(self
->frame
->area
) - e
;
4344 case OB_DIRECTION_SOUTH
:
4345 if (grow
== near
) --e
;
4346 delta
= e
- RECT_BOTTOM(self
->frame
->area
);
4350 g_assert_not_reached();
4352 frame_frame_gravity(self
->frame
, x
, y
);
4353 *w
-= self
->frame
->size
.left
+ self
->frame
->size
.right
;
4354 *h
-= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
4357 ObClient
* client_under_pointer(void)
4361 ObClient
*ret
= NULL
;
4363 if (screen_pointer_pos(&x
, &y
)) {
4364 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
4365 if (WINDOW_IS_CLIENT(it
->data
)) {
4366 ObClient
*c
= WINDOW_AS_CLIENT(it
->data
);
4367 if (c
->frame
->visible
&&
4368 /* check the desktop, this is done during desktop
4369 switching and windows are shown/hidden status is not
4371 (c
->desktop
== screen_desktop
||
4372 c
->desktop
== DESKTOP_ALL
) &&
4373 /* ignore all animating windows */
4374 !frame_iconify_animating(c
->frame
) &&
4375 RECT_CONTAINS(c
->frame
->area
, x
, y
))
4386 gboolean
client_has_group_siblings(ObClient
*self
)
4388 return self
->group
&& self
->group
->members
->next
;
4391 /*! Returns TRUE if the client is running on the same machine as Openbox */
4392 gboolean
client_on_localhost(ObClient
*self
)
4394 return self
->client_machine
== NULL
;