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
;
206 ob_debug("Managing window: 0x%lx", window
);
208 map_time
= event_get_server_time();
210 /* choose the events we want to receive on the CLIENT window
211 (ObPrompt windows can request events too) */
212 attrib_set
.event_mask
= CLIENT_EVENTMASK
|
213 (prompt
? prompt
->event_mask
: 0);
214 attrib_set
.do_not_propagate_mask
= CLIENT_NOPROPAGATEMASK
;
215 XChangeWindowAttributes(obt_display
, window
,
216 CWEventMask
|CWDontPropagate
, &attrib_set
);
218 /* create the ObClient struct, and populate it from the hints on the
220 self
= g_new0(ObClient
, 1);
221 self
->obwin
.type
= OB_WINDOW_CLASS_CLIENT
;
222 self
->window
= window
;
223 self
->prompt
= prompt
;
225 /* non-zero defaults */
226 self
->wmstate
= WithdrawnState
; /* make sure it gets updated first time */
227 self
->gravity
= NorthWestGravity
;
228 self
->desktop
= screen_num_desktops
; /* always an invalid value */
230 /* get all the stuff off the window */
231 client_get_all(self
, TRUE
);
233 ob_debug("Window type: %d", self
->type
);
234 ob_debug("Window group: 0x%x", self
->group
?self
->group
->leader
:0);
235 ob_debug("Window name: %s class: %s", self
->name
, self
->class);
237 /* now we have all of the window's information so we can set this up.
238 do this before creating the frame, so it can tell that we are still
239 mapping and doesn't go applying things right away */
240 client_setup_decor_and_functions(self
, FALSE
);
242 /* specify that if we exit, the window should not be destroyed and
243 should be reparented back to root automatically, unless we are managing
244 an internal ObPrompt window */
246 XChangeSaveSet(obt_display
, window
, SetModeInsert
);
248 /* create the decoration frame for the client window */
249 self
->frame
= frame_new(self
);
251 frame_grab_client(self
->frame
);
253 /* we've grabbed everything and set everything that we need to at mapping
257 /* per-app settings override stuff from client_get_all, and return the
258 settings for other uses too. the returned settings is a shallow copy,
259 that needs to be freed with g_free(). */
260 settings
= client_get_settings_state(self
);
261 /* the session should get the last say though */
262 client_restore_session_state(self
);
264 /* tell startup notification that this app started */
265 launch_time
= sn_app_started(self
->startup_id
, self
->class, self
->name
);
267 /* do this after we have a frame.. it uses the frame to help determine the
268 WM_STATE to apply. */
269 client_change_state(self
);
271 /* add ourselves to the focus order */
272 focus_order_add_new(self
);
274 /* do this to add ourselves to the stacking list in a non-intrusive way */
275 client_calc_layer(self
);
277 /* focus the new window? */
278 if (ob_state() != OB_STATE_STARTING
&&
279 (!self
->session
|| self
->session
->focused
) &&
280 /* this means focus=true for window is same as config_focus_new=true */
281 ((config_focus_new
|| (settings
&& settings
->focus
== 1)) ||
282 client_search_focus_tree_full(self
)) &&
283 /* this checks for focus=false for the window */
284 (!settings
|| settings
->focus
!= 0) &&
285 focus_valid_target(self
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
))
290 /* remove the client's border */
291 XSetWindowBorderWidth(obt_display
, self
->window
, 0);
293 /* adjust the frame to the client's size before showing or placing
295 frame_adjust_area(self
->frame
, FALSE
, TRUE
, FALSE
);
296 frame_adjust_client_area(self
->frame
);
298 /* where the frame was placed is where the window was originally */
300 monitor
= screen_physical_area_monitor(screen_find_monitor(&place
));
302 /* figure out placement for the window if the window is new */
303 if (ob_state() == OB_STATE_RUNNING
) {
304 ob_debug("Positioned: %s @ %d %d",
305 (!self
->positioned
? "no" :
306 (self
->positioned
== PPosition
? "program specified" :
307 (self
->positioned
== USPosition
? "user specified" :
308 (self
->positioned
== (PPosition
| USPosition
) ?
309 "program + user specified" :
310 "BADNESS !?")))), place
.x
, place
.y
);
312 ob_debug("Sized: %s @ %d %d",
313 (!self
->sized
? "no" :
314 (self
->sized
== PSize
? "program specified" :
315 (self
->sized
== USSize
? "user specified" :
316 (self
->sized
== (PSize
| USSize
) ?
317 "program + user specified" :
318 "BADNESS !?")))), place
.width
, place
.height
);
320 /* splash screens are also returned as TRUE for transient,
321 and so will be forced on screen below */
322 transient
= place_client(self
, &place
.x
, &place
.y
, settings
);
324 /* make sure the window is visible. */
325 client_find_onscreen(self
, &place
.x
, &place
.y
,
326 place
.width
, place
.height
,
327 /* non-normal clients has less rules, and
328 windows that are being restored from a
329 session do also. we can assume you want
330 it back where you saved it. Clients saying
331 they placed themselves are subjected to
332 harder rules, ones that are placed by
333 place.c or by the user are allowed partially
334 off-screen and on xinerama divides (ie,
335 it is up to the placement routines to avoid
336 the xinerama divides)
338 splash screens get "transient" set to TRUE by
339 the place_client call
341 ob_state() == OB_STATE_RUNNING
&&
343 (!((self
->positioned
& USPosition
) ||
344 (settings
&& settings
->pos_given
)) &&
345 client_normal(self
) &&
347 /* don't move oldschool fullscreen windows to
348 fit inside the struts (fixes Acroread, which
349 makes its fullscreen window fit the screen
350 but it is not USSize'd or USPosition'd) */
351 !(self
->decorations
== 0 &&
352 RECT_EQUAL(place
, *monitor
)))));
355 /* if the window isn't user-sized, then make it fit inside
356 the visible screen area on its monitor. Use basically the same rules
357 for forcing the window on screen in the client_find_onscreen call.
359 do this after place_client, it chooses the monitor!
361 splash screens get "transient" set to TRUE by
362 the place_client call
364 if (ob_state() == OB_STATE_RUNNING
&&
366 (!(self
->sized
& USSize
|| self
->positioned
& USPosition
) &&
367 client_normal(self
) &&
369 /* don't shrink oldschool fullscreen windows to fit inside the
370 struts (fixes Acroread, which makes its fullscreen window
371 fit the screen but it is not USSize'd or USPosition'd) */
372 !(self
->decorations
== 0 && RECT_EQUAL(place
, *monitor
)))))
374 Rect
*a
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
, &place
);
376 /* get the size of the frame */
377 place
.width
+= self
->frame
->size
.left
+ self
->frame
->size
.right
;
378 place
.height
+= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
380 /* fit the window inside the area */
381 place
.width
= MIN(place
.width
, a
->width
);
382 place
.height
= MIN(place
.height
, a
->height
);
384 ob_debug("setting window size to %dx%d", place
.width
, place
.height
);
386 /* get the size of the client back */
387 place
.width
-= self
->frame
->size
.left
+ self
->frame
->size
.right
;
388 place
.height
-= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
393 ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
394 "some restrictions may apply",
395 self
->window
, place
.x
, place
.y
, place
.width
, place
.height
);
397 ob_debug(" but session requested %d, %d %d x %d instead, "
399 self
->session
->x
, self
->session
->y
,
400 self
->session
->w
, self
->session
->h
);
402 /* do this after the window is placed, so the premax/prefullscreen numbers
405 this also places the window
407 client_apply_startup_state(self
, place
.x
, place
.y
,
408 place
.width
, place
.height
);
413 ob_debug_type(OB_DEBUG_FOCUS
, "Going to try activate new window? %s",
414 activate
? "yes" : "no");
416 gboolean raise
= FALSE
;
417 gboolean relative_focused
;
418 gboolean parent_focused
;
420 parent_focused
= (focus_client
!= NULL
&&
421 client_search_focus_parent(self
));
422 relative_focused
= (focus_client
!= NULL
&&
423 (client_search_focus_tree_full(self
) != NULL
||
424 client_search_focus_group_full(self
) != NULL
));
426 /* This is focus stealing prevention */
427 ob_debug_type(OB_DEBUG_FOCUS
,
428 "Want to focus new window 0x%x at time %u "
429 "launched at %u (last user interaction time %u)",
430 self
->window
, map_time
, launch_time
,
431 event_last_user_time
);
432 ob_debug_type(OB_DEBUG_FOCUS
,
433 "Current focus_client: %s",
434 (focus_client
? focus_client
->title
: "(none)"));
435 ob_debug_type(OB_DEBUG_FOCUS
,
436 "parent focuesed: %d relative focused: %d",
437 parent_focused
, relative_focused
);
439 if (menu_frame_visible
|| moveresize_in_progress
) {
442 ob_debug_type(OB_DEBUG_FOCUS
,
443 "Not focusing the window because the user is inside "
444 "an Openbox menu or is move/resizing a window and "
445 "we don't want to interrupt them");
448 /* if it's on another desktop */
449 else if (!(self
->desktop
== screen_desktop
||
450 self
->desktop
== DESKTOP_ALL
) &&
451 /* the timestamp is from before you changed desktops */
452 launch_time
&& screen_desktop_user_time
&&
453 !event_time_after(launch_time
, screen_desktop_user_time
))
457 ob_debug_type(OB_DEBUG_FOCUS
,
458 "Not focusing the window because its on another "
461 /* If something is focused... */
462 else if (focus_client
) {
463 /* If the user is working in another window right now, then don't
465 if (!parent_focused
&&
466 event_last_user_time
&& launch_time
&&
467 event_time_after(event_last_user_time
, launch_time
) &&
468 event_last_user_time
!= launch_time
&&
469 event_time_after(event_last_user_time
,
470 map_time
- OB_EVENT_USER_TIME_DELAY
))
473 ob_debug_type(OB_DEBUG_FOCUS
,
474 "Not focusing the window because the user is "
475 "working in another window that is not "
478 /* If the new window is a transient (and its relatives aren't
480 else if (client_has_parent(self
) && !relative_focused
) {
482 ob_debug_type(OB_DEBUG_FOCUS
,
483 "Not focusing the window because it is a "
484 "transient, and its relatives aren't focused");
486 /* Don't steal focus from globally active clients.
487 I stole this idea from KWin. It seems nice.
489 else if (!(focus_client
->can_focus
||
490 focus_client
->focus_notify
))
493 ob_debug_type(OB_DEBUG_FOCUS
,
494 "Not focusing the window because a globally "
495 "active client has focus");
497 /* Don't move focus if it's not going to go to this window
499 else if (client_focus_target(self
) != self
) {
502 ob_debug_type(OB_DEBUG_FOCUS
,
503 "Not focusing the window because another window "
504 "would get the focus anyway");
506 /* Don't move focus if the window is not visible on the current
507 desktop and none of its relatives are focused */
508 else if (!(self
->desktop
== screen_desktop
||
509 self
->desktop
== DESKTOP_ALL
) &&
514 ob_debug_type(OB_DEBUG_FOCUS
,
515 "Not focusing the window because it is on "
516 "another desktop and no relatives are focused ");
521 ob_debug_type(OB_DEBUG_FOCUS
,
522 "Focus stealing prevention activated for %s at "
523 "time %u (last user interaction time %u)",
524 self
->title
, map_time
, event_last_user_time
);
525 /* if the client isn't focused, then hilite it so the user
527 client_hilite(self
, TRUE
);
528 /* we may want to raise it even tho we're not activating it */
529 if (raise
&& !client_restore_session_stacking(self
))
530 stacking_raise(CLIENT_AS_WINDOW(self
));
534 /* This may look rather odd. Well it's because new windows are added
535 to the stacking order non-intrusively. If we're not going to focus
536 the new window or hilite it, then we raise it to the top. This will
537 take affect for things that don't get focused like splash screens.
538 Also if you don't have focus_new enabled, then it's going to get
539 raised to the top. Legacy begets legacy I guess?
541 if (!client_restore_session_stacking(self
))
542 stacking_raise(CLIENT_AS_WINDOW(self
));
545 mouse_grab_for_client(self
, TRUE
);
547 /* this has to happen before we try focus the window, but we want it to
548 happen after the client's stacking has been determined or it looks bad
552 if (!config_focus_under_mouse
)
553 ignore_start
= event_start_ignore_all_enters();
557 if (!config_focus_under_mouse
)
558 event_end_ignore_all_enters(ignore_start
);
562 gboolean stacked
= client_restore_session_stacking(self
);
563 client_present(self
, FALSE
, !stacked
, TRUE
);
566 /* add to client list/map */
567 client_list
= g_list_append(client_list
, self
);
568 window_add(&self
->window
, CLIENT_AS_WINDOW(self
));
570 /* this has to happen after we're in the client_list */
571 if (STRUT_EXISTS(self
->strut
))
572 screen_update_areas();
574 /* update the list hints */
577 /* free the ObAppSettings shallow copy */
580 ob_debug("Managed window 0x%lx plate 0x%x (%s)",
581 window
, self
->frame
->window
, self
->class);
583 hooks_queue(OB_HOOK_WIN_NEW
, self
);
586 ObClient
*client_fake_manage(Window window
)
589 ObAppSettings
*settings
;
591 ob_debug("Pretend-managing window: %lx", window
);
593 /* do this minimal stuff to figure out the client's decorations */
595 self
= g_new0(ObClient
, 1);
596 self
->window
= window
;
598 client_get_all(self
, FALSE
);
599 /* per-app settings override stuff, and return the settings for other
600 uses too. this returns a shallow copy that needs to be freed */
601 settings
= client_get_settings_state(self
);
603 client_setup_decor_and_functions(self
, FALSE
);
605 /* create the decoration frame for the client window and adjust its size */
606 self
->frame
= frame_new(self
);
607 frame_adjust_area(self
->frame
, FALSE
, TRUE
, TRUE
);
609 ob_debug("gave extents left %d right %d top %d bottom %d",
610 self
->frame
->size
.left
, self
->frame
->size
.right
,
611 self
->frame
->size
.top
, self
->frame
->size
.bottom
);
613 /* free the ObAppSettings shallow copy */
619 void client_unmanage_all(void)
622 client_unmanage(client_list
->data
);
625 void client_unmanage(ObClient
*self
)
630 ob_debug("Unmanaging window: 0x%x plate 0x%x (%s) (%s)",
631 self
->window
, self
->frame
->window
,
632 self
->class, self
->title
? self
->title
: "");
634 g_assert(self
!= NULL
);
636 /* we dont want events no more. do this before hiding the frame so we
637 don't generate more events */
638 XSelectInput(obt_display
, self
->window
, NoEventMask
);
640 /* ignore enter events from the unmap so it doesnt mess with the focus */
641 if (!config_focus_under_mouse
)
642 ignore_start
= event_start_ignore_all_enters();
644 frame_hide(self
->frame
);
645 /* flush to send the hide to the server quickly */
648 if (!config_focus_under_mouse
)
649 event_end_ignore_all_enters(ignore_start
);
651 mouse_grab_for_client(self
, FALSE
);
653 /* remove the window from our save set, unless we are managing an internal
656 XChangeSaveSet(obt_display
, self
->window
, SetModeDelete
);
658 /* this can't be queued to run later */
659 hooks_run(OB_HOOK_WIN_CLOSE
, self
);
661 /* update the focus lists */
662 focus_order_remove(self
);
663 if (client_focused(self
)) {
664 /* don't leave an invalid focus_client */
668 /* if we're prompting to kill the client, close that */
669 prompt_unref(self
->kill_prompt
);
670 self
->kill_prompt
= NULL
;
672 client_list
= g_list_remove(client_list
, self
);
673 stacking_remove(self
);
674 window_remove(self
->window
);
676 /* once the client is out of the list, update the struts to remove its
678 if (STRUT_EXISTS(self
->strut
))
679 screen_update_areas();
681 client_call_notifies(self
, client_destroy_notifies
);
683 /* tell our parent(s) that we're gone */
684 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
685 ((ObClient
*)it
->data
)->transients
=
686 g_slist_remove(((ObClient
*)it
->data
)->transients
,self
);
688 /* tell our transients that we're gone */
689 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
690 ((ObClient
*)it
->data
)->parents
=
691 g_slist_remove(((ObClient
*)it
->data
)->parents
, self
);
692 /* we could be keeping our children in a higher layer */
693 client_calc_layer(it
->data
);
696 /* remove from its group */
698 group_remove(self
->group
, self
);
702 /* restore the window's original geometry so it is not lost */
708 if (self
->fullscreen
)
709 a
= self
->pre_fullscreen_area
;
710 else if (self
->max_horz
|| self
->max_vert
) {
711 if (self
->max_horz
) {
712 a
.x
= self
->pre_max_area
.x
;
713 a
.width
= self
->pre_max_area
.width
;
715 if (self
->max_vert
) {
716 a
.y
= self
->pre_max_area
.y
;
717 a
.height
= self
->pre_max_area
.height
;
721 self
->fullscreen
= self
->max_horz
= self
->max_vert
= FALSE
;
722 /* let it be moved and resized no matter what */
723 self
->functions
= OB_CLIENT_FUNC_MOVE
| OB_CLIENT_FUNC_RESIZE
;
724 self
->decorations
= 0; /* unmanaged windows have no decor */
726 /* give the client its border back */
727 XSetWindowBorderWidth(obt_display
, self
->window
, self
->border_width
);
729 client_move_resize(self
, a
.x
, a
.y
, a
.width
, a
.height
);
732 /* reparent the window out of the frame, and free the frame */
733 frame_release_client(self
->frame
);
734 frame_free(self
->frame
);
737 if (ob_state() != OB_STATE_EXITING
) {
738 /* these values should not be persisted across a window
740 OBT_PROP_ERASE(self
->window
, NET_WM_DESKTOP
);
741 OBT_PROP_ERASE(self
->window
, NET_WM_STATE
);
742 OBT_PROP_ERASE(self
->window
, WM_STATE
);
744 /* if we're left in an unmapped state, the client wont be mapped.
745 this is bad, since we will no longer be managing the window on
747 XMapWindow(obt_display
, self
->window
);
750 /* these should not be left on the window ever. other window managers
751 don't necessarily use them and it will mess them up (like compiz) */
752 OBT_PROP_ERASE(self
->window
, NET_WM_VISIBLE_NAME
);
753 OBT_PROP_ERASE(self
->window
, NET_WM_VISIBLE_ICON_NAME
);
755 /* update the list hints */
758 ob_debug("Unmanaged window 0x%lx", self
->window
);
760 /* free all data allocated in the client struct */
761 RrImageUnref(self
->icon_set
);
762 g_slist_free(self
->transients
);
763 g_free(self
->startup_id
);
764 g_free(self
->wm_command
);
766 g_free(self
->icon_title
);
767 g_free(self
->original_title
);
771 g_free(self
->client_machine
);
772 g_free(self
->sm_client_id
);
776 void client_fake_unmanage(ObClient
*self
)
778 /* this is all that got allocated to get the decorations */
780 frame_free(self
->frame
);
784 /*! Returns a new structure containing the per-app settings for this client.
785 The returned structure needs to be freed with g_free. */
786 static ObAppSettings
*client_get_settings_state(ObClient
*self
)
788 ObAppSettings
*settings
;
791 settings
= config_create_app_settings();
793 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
794 ObAppSettings
*app
= it
->data
;
795 gboolean match
= TRUE
;
797 g_assert(app
->name
!= NULL
|| app
->class != NULL
);
799 /* we know that either name or class is not NULL so it will have to
800 match to use the rule */
802 !g_pattern_match(app
->name
, strlen(self
->name
), self
->name
, NULL
))
804 else if (app
->class &&
805 !g_pattern_match(app
->class,
806 strlen(self
->class), self
->class, NULL
))
808 else if (app
->role
&&
809 !g_pattern_match(app
->role
,
810 strlen(self
->role
), self
->role
, NULL
))
812 else if ((signed)app
->type
>= 0 && app
->type
!= self
->type
)
816 ob_debug("Window matching: %s", app
->name
);
818 /* copy the settings to our struct, overriding the existing
819 settings if they are not defaults */
820 config_app_settings_copy_non_defaults(app
, settings
);
824 if (settings
->shade
!= -1)
825 self
->shaded
= !!settings
->shade
;
826 if (settings
->decor
!= -1)
827 self
->undecorated
= !settings
->decor
;
828 if (settings
->iconic
!= -1)
829 self
->iconic
= !!settings
->iconic
;
830 if (settings
->skip_pager
!= -1)
831 self
->skip_pager
= !!settings
->skip_pager
;
832 if (settings
->skip_taskbar
!= -1)
833 self
->skip_taskbar
= !!settings
->skip_taskbar
;
835 if (settings
->max_vert
!= -1)
836 self
->max_vert
= !!settings
->max_vert
;
837 if (settings
->max_horz
!= -1)
838 self
->max_horz
= !!settings
->max_horz
;
840 if (settings
->fullscreen
!= -1)
841 self
->fullscreen
= !!settings
->fullscreen
;
843 if (settings
->desktop
) {
844 if (settings
->desktop
== DESKTOP_ALL
)
845 self
->desktop
= settings
->desktop
;
846 else if (settings
->desktop
> 0 &&
847 settings
->desktop
<= screen_num_desktops
)
848 self
->desktop
= settings
->desktop
- 1;
851 if (settings
->layer
== -1) {
855 else if (settings
->layer
== 0) {
859 else if (settings
->layer
== 1) {
866 static void client_restore_session_state(ObClient
*self
)
870 ob_debug_type(OB_DEBUG_SM
,
871 "Restore session for client %s", self
->title
);
873 if (!(it
= session_state_find(self
))) {
874 ob_debug_type(OB_DEBUG_SM
,
875 "Session data not found for client %s", self
->title
);
879 self
->session
= it
->data
;
881 ob_debug_type(OB_DEBUG_SM
, "Session data loaded for client %s",
884 RECT_SET_POINT(self
->area
, self
->session
->x
, self
->session
->y
);
885 self
->positioned
= USPosition
;
886 self
->sized
= USSize
;
887 if (self
->session
->w
> 0)
888 self
->area
.width
= self
->session
->w
;
889 if (self
->session
->h
> 0)
890 self
->area
.height
= self
->session
->h
;
891 XResizeWindow(obt_display
, self
->window
,
892 self
->area
.width
, self
->area
.height
);
894 self
->desktop
= (self
->session
->desktop
== DESKTOP_ALL
?
895 self
->session
->desktop
:
896 MIN(screen_num_desktops
- 1, self
->session
->desktop
));
897 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, self
->desktop
);
899 self
->shaded
= self
->session
->shaded
;
900 self
->iconic
= self
->session
->iconic
;
901 self
->skip_pager
= self
->session
->skip_pager
;
902 self
->skip_taskbar
= self
->session
->skip_taskbar
;
903 self
->fullscreen
= self
->session
->fullscreen
;
904 self
->above
= self
->session
->above
;
905 self
->below
= self
->session
->below
;
906 self
->max_horz
= self
->session
->max_horz
;
907 self
->max_vert
= self
->session
->max_vert
;
908 self
->undecorated
= self
->session
->undecorated
;
911 static gboolean
client_restore_session_stacking(ObClient
*self
)
915 if (!self
->session
) return FALSE
;
917 mypos
= g_list_find(session_saved_state
, self
->session
);
918 if (!mypos
) return FALSE
;
920 /* start above me and look for the first client */
921 for (it
= g_list_previous(mypos
); it
; it
= g_list_previous(it
)) {
924 for (cit
= client_list
; cit
; cit
= g_list_next(cit
)) {
925 ObClient
*c
= cit
->data
;
926 /* found a client that was in the session, so go below it */
927 if (c
->session
== it
->data
) {
928 stacking_below(CLIENT_AS_WINDOW(self
),
929 CLIENT_AS_WINDOW(cit
->data
));
937 void client_move_onscreen(ObClient
*self
, gboolean rude
)
939 gint x
= self
->area
.x
;
940 gint y
= self
->area
.y
;
941 if (client_find_onscreen(self
, &x
, &y
,
943 self
->area
.height
, rude
)) {
944 client_move(self
, x
, y
);
948 gboolean
client_find_onscreen(ObClient
*self
, gint
*x
, gint
*y
, gint w
, gint h
,
951 gint ox
= *x
, oy
= *y
;
952 gboolean rudel
= rude
, ruder
= rude
, rudet
= rude
, rudeb
= rude
;
958 RECT_SET(desired
, *x
, *y
, w
, h
);
959 frame_rect_to_frame(self
->frame
, &desired
);
961 /* get where the frame would be */
962 frame_client_gravity(self
->frame
, x
, y
);
964 /* get the requested size of the window with decorations */
965 fw
= self
->frame
->size
.left
+ w
+ self
->frame
->size
.right
;
966 fh
= self
->frame
->size
.top
+ h
+ self
->frame
->size
.bottom
;
968 /* If rudeness wasn't requested, then still be rude in a given direction
969 if the client is not moving, only resizing in that direction */
971 Point oldtl
, oldtr
, oldbl
, oldbr
;
972 Point newtl
, newtr
, newbl
, newbr
;
973 gboolean stationary_l
, stationary_r
, stationary_t
, stationary_b
;
975 POINT_SET(oldtl
, self
->frame
->area
.x
, self
->frame
->area
.y
);
976 POINT_SET(oldbr
, self
->frame
->area
.x
+ self
->frame
->area
.width
- 1,
977 self
->frame
->area
.y
+ self
->frame
->area
.height
- 1);
978 POINT_SET(oldtr
, oldbr
.x
, oldtl
.y
);
979 POINT_SET(oldbl
, oldtl
.x
, oldbr
.y
);
981 POINT_SET(newtl
, *x
, *y
);
982 POINT_SET(newbr
, *x
+ fw
- 1, *y
+ fh
- 1);
983 POINT_SET(newtr
, newbr
.x
, newtl
.y
);
984 POINT_SET(newbl
, newtl
.x
, newbr
.y
);
986 /* is it moving or just resizing from some corner? */
987 stationary_l
= oldtl
.x
== newtl
.x
;
988 stationary_r
= oldtr
.x
== newtr
.x
;
989 stationary_t
= oldtl
.y
== newtl
.y
;
990 stationary_b
= oldbl
.y
== newbl
.y
;
992 /* if left edge is growing and didnt move right edge */
993 if (stationary_r
&& newtl
.x
< oldtl
.x
)
995 /* if right edge is growing and didnt move left edge */
996 if (stationary_l
&& newtr
.x
> oldtr
.x
)
998 /* if top edge is growing and didnt move bottom edge */
999 if (stationary_b
&& newtl
.y
< oldtl
.y
)
1001 /* if bottom edge is growing and didnt move top edge */
1002 if (stationary_t
&& newbl
.y
> oldbl
.y
)
1006 /* we iterate through every monitor that the window is at least partially
1007 on, to make sure it is obeying the rules on them all
1009 if the window does not appear on any monitors, then use the first one
1012 for (i
= 0; i
< screen_num_monitors
; ++i
) {
1015 if (!screen_physical_area_monitor_contains(i
, &desired
)) {
1016 if (i
< screen_num_monitors
- 1 || found_mon
)
1019 /* the window is not inside any monitor! so just use the first
1021 a
= screen_area(self
->desktop
, 0, NULL
);
1024 a
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
, &desired
);
1027 /* This makes sure windows aren't entirely outside of the screen so you
1028 can't see them at all.
1029 It makes sure 10% of the window is on the screen at least. And don't
1030 let it move itself off the top of the screen, which would hide the
1031 titlebar on you. (The user can still do this if they want too, it's
1032 only limiting the application.
1034 if (client_normal(self
)) {
1035 if (!self
->strut
.right
&& *x
+ fw
/10 >= a
->x
+ a
->width
- 1)
1036 *x
= a
->x
+ a
->width
- fw
/10;
1037 if (!self
->strut
.bottom
&& *y
+ fh
/10 >= a
->y
+ a
->height
- 1)
1038 *y
= a
->y
+ a
->height
- fh
/10;
1039 if (!self
->strut
.left
&& *x
+ fw
*9/10 - 1 < a
->x
)
1040 *x
= a
->x
- fw
*9/10;
1041 if (!self
->strut
.top
&& *y
+ fh
*9/10 - 1 < a
->y
)
1042 *y
= a
->y
- fh
*9/10;
1045 /* This here doesn't let windows even a pixel outside the
1046 struts/screen. When called from client_manage, programs placing
1047 themselves are forced completely onscreen, while things like
1048 xterm -geometry resolution-width/2 will work fine. Trying to
1049 place it completely offscreen will be handled in the above code.
1050 Sorry for this confused comment, i am tired. */
1051 if (rudel
&& !self
->strut
.left
&& *x
< a
->x
) *x
= a
->x
;
1052 if (ruder
&& !self
->strut
.right
&& *x
+ fw
> a
->x
+ a
->width
)
1053 *x
= a
->x
+ MAX(0, a
->width
- fw
);
1055 if (rudet
&& !self
->strut
.top
&& *y
< a
->y
) *y
= a
->y
;
1056 if (rudeb
&& !self
->strut
.bottom
&& *y
+ fh
> a
->y
+ a
->height
)
1057 *y
= a
->y
+ MAX(0, a
->height
- fh
);
1062 /* get where the client should be */
1063 frame_frame_gravity(self
->frame
, x
, y
);
1065 return ox
!= *x
|| oy
!= *y
;
1068 static void client_get_all(ObClient
*self
, gboolean real
)
1070 /* this is needed for the frame to set itself up */
1071 client_get_area(self
);
1073 /* these things can change the decor and functions of the window */
1075 client_get_mwm_hints(self
);
1076 /* this can change the mwmhints for special cases */
1077 client_get_type_and_transientness(self
);
1078 client_get_state(self
);
1079 client_update_normal_hints(self
);
1081 /* get the session related properties, these can change decorations
1082 from per-app settings */
1083 client_get_session_ids(self
);
1085 /* now we got everything that can affect the decorations */
1089 /* get this early so we have it for debugging */
1090 client_update_title(self
);
1092 client_update_protocols(self
);
1094 client_update_wmhints(self
);
1095 /* this may have already been called from client_update_wmhints */
1096 if (!self
->parents
&& !self
->transient_for_group
)
1097 client_update_transient_for(self
);
1099 client_get_startup_id(self
);
1100 client_get_desktop(self
);/* uses transient data/group/startup id if a
1101 desktop is not specified */
1102 client_get_shaped(self
);
1105 /* a couple type-based defaults for new windows */
1107 /* this makes sure that these windows appear on all desktops */
1108 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
1109 self
->desktop
= DESKTOP_ALL
;
1113 client_update_sync_request_counter(self
);
1116 client_get_colormap(self
);
1117 client_update_strut(self
);
1118 client_update_icons(self
);
1119 client_update_icon_geometry(self
);
1122 static void client_get_startup_id(ObClient
*self
)
1124 if (!(OBT_PROP_GETS(self
->window
, NET_STARTUP_ID
, utf8
,
1125 &self
->startup_id
)))
1127 OBT_PROP_GETS(self
->group
->leader
,
1128 NET_STARTUP_ID
, utf8
, &self
->startup_id
);
1131 static void client_get_area(ObClient
*self
)
1133 XWindowAttributes wattrib
;
1136 ret
= XGetWindowAttributes(obt_display
, self
->window
, &wattrib
);
1137 g_assert(ret
!= BadWindow
);
1139 RECT_SET(self
->area
, wattrib
.x
, wattrib
.y
, wattrib
.width
, wattrib
.height
);
1140 POINT_SET(self
->root_pos
, wattrib
.x
, wattrib
.y
);
1141 self
->border_width
= wattrib
.border_width
;
1143 ob_debug("client area: %d %d %d %d bw %d", wattrib
.x
, wattrib
.y
,
1144 wattrib
.width
, wattrib
.height
, wattrib
.border_width
);
1147 static void client_get_desktop(ObClient
*self
)
1149 guint32 d
= screen_num_desktops
; /* an always-invalid value */
1151 if (OBT_PROP_GET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, &d
)) {
1152 if (d
>= screen_num_desktops
&& d
!= DESKTOP_ALL
)
1153 self
->desktop
= screen_num_desktops
- 1;
1156 ob_debug("client requested desktop 0x%x", self
->desktop
);
1159 gboolean first
= TRUE
;
1160 guint all
= screen_num_desktops
; /* not a valid value */
1162 /* if they are all on one desktop, then open it on the
1164 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
1165 ObClient
*c
= it
->data
;
1167 if (c
->desktop
== DESKTOP_ALL
) continue;
1173 else if (all
!= c
->desktop
)
1174 all
= screen_num_desktops
; /* make it invalid */
1176 if (all
!= screen_num_desktops
) {
1177 self
->desktop
= all
;
1179 ob_debug("client desktop set from parents: 0x%x",
1182 /* try get from the startup-notification protocol */
1183 else if (sn_get_desktop(self
->startup_id
, &self
->desktop
)) {
1184 if (self
->desktop
>= screen_num_desktops
&&
1185 self
->desktop
!= DESKTOP_ALL
)
1186 self
->desktop
= screen_num_desktops
- 1;
1187 ob_debug("client desktop set from startup-notification: 0x%x",
1190 /* defaults to the current desktop */
1192 self
->desktop
= screen_desktop
;
1193 ob_debug("client desktop set to the current desktop: %d",
1199 static void client_get_state(ObClient
*self
)
1204 if (OBT_PROP_GETA32(self
->window
, NET_WM_STATE
, ATOM
, &state
, &num
)) {
1206 for (i
= 0; i
< num
; ++i
) {
1207 if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MODAL
))
1209 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SHADED
))
1210 self
->shaded
= TRUE
;
1211 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
))
1212 self
->iconic
= TRUE
;
1213 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
))
1214 self
->skip_taskbar
= TRUE
;
1215 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
))
1216 self
->skip_pager
= TRUE
;
1217 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
))
1218 self
->fullscreen
= TRUE
;
1219 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
))
1220 self
->max_vert
= TRUE
;
1221 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
))
1222 self
->max_horz
= TRUE
;
1223 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_ABOVE
))
1225 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_BELOW
))
1227 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
))
1228 self
->demands_attention
= TRUE
;
1229 else if (state
[i
] == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
))
1230 self
->undecorated
= TRUE
;
1237 static void client_get_shaped(ObClient
*self
)
1239 self
->shaped
= FALSE
;
1241 if (obt_display_extension_shape
) {
1246 XShapeSelectInput(obt_display
, self
->window
, ShapeNotifyMask
);
1248 XShapeQueryExtents(obt_display
, self
->window
, &s
, &foo
,
1249 &foo
, &ufoo
, &ufoo
, &foo
, &foo
, &foo
, &ufoo
,
1256 void client_update_transient_for(ObClient
*self
)
1259 ObClient
*target
= NULL
;
1260 gboolean trangroup
= FALSE
;
1262 if (XGetTransientForHint(obt_display
, self
->window
, &t
)) {
1263 if (t
!= self
->window
) { /* can't be transient to itself! */
1264 ObWindow
*tw
= window_find(t
);
1265 /* if this happens then we need to check for it */
1266 g_assert(tw
!= CLIENT_AS_WINDOW(self
));
1267 if (tw
&& WINDOW_IS_CLIENT(tw
)) {
1268 /* watch out for windows with a parent that is something
1269 different, like a dockapp for example */
1270 target
= WINDOW_AS_CLIENT(tw
);
1274 /* Setting the transient_for to Root is actually illegal, however
1275 applications from time have done this to specify transient for
1277 if (!target
&& self
->group
&& t
== obt_root(ob_screen
))
1279 } else if (self
->group
&& self
->transient
)
1282 client_update_transient_tree(self
, self
->group
, self
->group
,
1283 self
->transient_for_group
, trangroup
,
1284 client_direct_parent(self
), target
);
1285 self
->transient_for_group
= trangroup
;
1289 static void client_update_transient_tree(ObClient
*self
,
1290 ObGroup
*oldgroup
, ObGroup
*newgroup
,
1291 gboolean oldgtran
, gboolean newgtran
,
1292 ObClient
* oldparent
,
1293 ObClient
*newparent
)
1298 g_assert(!oldgtran
|| oldgroup
);
1299 g_assert(!newgtran
|| newgroup
);
1300 g_assert((!oldgtran
&& !oldparent
) ||
1301 (oldgtran
&& !oldparent
) ||
1302 (!oldgtran
&& oldparent
));
1303 g_assert((!newgtran
&& !newparent
) ||
1304 (newgtran
&& !newparent
) ||
1305 (!newgtran
&& newparent
));
1308 Group transient windows are not allowed to have other group
1309 transient windows as their children.
1312 /* No change has occured */
1313 if (oldgroup
== newgroup
&&
1314 oldgtran
== newgtran
&&
1315 oldparent
== newparent
) return;
1317 /** Remove the client from the transient tree **/
1319 for (it
= self
->transients
; it
; it
= next
) {
1320 next
= g_slist_next(it
);
1322 self
->transients
= g_slist_delete_link(self
->transients
, it
);
1323 c
->parents
= g_slist_remove(c
->parents
, self
);
1325 for (it
= self
->parents
; it
; it
= next
) {
1326 next
= g_slist_next(it
);
1328 self
->parents
= g_slist_delete_link(self
->parents
, it
);
1329 c
->transients
= g_slist_remove(c
->transients
, self
);
1332 /** Re-add the client to the transient tree **/
1334 /* If we're transient for a group then we need to add ourselves to all our
1337 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1340 !client_search_top_direct_parent(c
)->transient_for_group
&&
1343 c
->transients
= g_slist_prepend(c
->transients
, self
);
1344 self
->parents
= g_slist_prepend(self
->parents
, c
);
1349 /* If we are now transient for a single window we need to add ourselves to
1352 WARNING: Cyclical transient-ness is possible if two windows are
1353 transient for eachother.
1355 else if (newparent
&&
1356 /* don't make ourself its child if it is already our child */
1357 !client_is_direct_child(self
, newparent
) &&
1358 client_normal(newparent
))
1360 newparent
->transients
= g_slist_prepend(newparent
->transients
, self
);
1361 self
->parents
= g_slist_prepend(self
->parents
, newparent
);
1364 /* Add any group transient windows to our children. But if we're transient
1365 for the group, then other group transients are not our children.
1367 WARNING: Cyclical transient-ness is possible. For e.g. if:
1368 A is transient for the group
1369 B is transient for A
1370 C is transient for B
1371 A can't be transient for C or we have a cycle
1373 if (!newgtran
&& newgroup
&&
1375 !client_search_top_direct_parent(newparent
)->transient_for_group
) &&
1376 client_normal(self
))
1378 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1380 if (c
!= self
&& c
->transient_for_group
&&
1381 /* Don't make it our child if it is already our parent */
1382 !client_is_direct_child(c
, self
))
1384 self
->transients
= g_slist_prepend(self
->transients
, c
);
1385 c
->parents
= g_slist_prepend(c
->parents
, self
);
1390 /** If we change our group transient-ness, our children change their
1391 effective group transient-ness, which affects how they relate to other
1394 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
1396 if (!c
->transient_for_group
)
1397 client_update_transient_tree(c
, c
->group
, c
->group
,
1398 c
->transient_for_group
,
1399 c
->transient_for_group
,
1400 client_direct_parent(c
),
1401 client_direct_parent(c
));
1405 static void client_get_mwm_hints(ObClient
*self
)
1410 self
->mwmhints
.flags
= 0; /* default to none */
1412 if (OBT_PROP_GETA32(self
->window
, MOTIF_WM_HINTS
, MOTIF_WM_HINTS
,
1414 if (num
>= OB_MWM_ELEMENTS
) {
1415 self
->mwmhints
.flags
= hints
[0];
1416 self
->mwmhints
.functions
= hints
[1];
1417 self
->mwmhints
.decorations
= hints
[2];
1423 void client_get_type_and_transientness(ObClient
*self
)
1430 self
->transient
= FALSE
;
1432 if (OBT_PROP_GETA32(self
->window
, NET_WM_WINDOW_TYPE
, ATOM
, &val
, &num
)) {
1433 /* use the first value that we know about in the array */
1434 for (i
= 0; i
< num
; ++i
) {
1435 if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DESKTOP
))
1436 self
->type
= OB_CLIENT_TYPE_DESKTOP
;
1437 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK
))
1438 self
->type
= OB_CLIENT_TYPE_DOCK
;
1439 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_TOOLBAR
))
1440 self
->type
= OB_CLIENT_TYPE_TOOLBAR
;
1441 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_MENU
))
1442 self
->type
= OB_CLIENT_TYPE_MENU
;
1443 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_UTILITY
))
1444 self
->type
= OB_CLIENT_TYPE_UTILITY
;
1445 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_SPLASH
))
1446 self
->type
= OB_CLIENT_TYPE_SPLASH
;
1447 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG
))
1448 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1449 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_NORMAL
))
1450 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1451 else if (val
[i
] == OBT_PROP_ATOM(KDE_NET_WM_WINDOW_TYPE_OVERRIDE
))
1453 /* prevent this window from getting any decor or
1455 self
->mwmhints
.flags
&= (OB_MWM_FLAG_FUNCTIONS
|
1456 OB_MWM_FLAG_DECORATIONS
);
1457 self
->mwmhints
.decorations
= 0;
1458 self
->mwmhints
.functions
= 0;
1460 if (self
->type
!= (ObClientType
) -1)
1461 break; /* grab the first legit type */
1466 if (XGetTransientForHint(obt_display
, self
->window
, &t
))
1467 self
->transient
= TRUE
;
1469 if (self
->type
== (ObClientType
) -1) {
1470 /*the window type hint was not set, which means we either classify
1471 ourself as a normal window or a dialog, depending on if we are a
1473 if (self
->transient
)
1474 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1476 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1479 /* then, based on our type, we can update our transientness.. */
1480 if (self
->type
== OB_CLIENT_TYPE_DIALOG
||
1481 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
1482 self
->type
== OB_CLIENT_TYPE_MENU
||
1483 self
->type
== OB_CLIENT_TYPE_UTILITY
)
1485 self
->transient
= TRUE
;
1489 void client_update_protocols(ObClient
*self
)
1494 self
->focus_notify
= FALSE
;
1495 self
->delete_window
= FALSE
;
1497 if (OBT_PROP_GETA32(self
->window
, WM_PROTOCOLS
, ATOM
, &proto
, &num_ret
)) {
1498 for (i
= 0; i
< num_ret
; ++i
) {
1499 if (proto
[i
] == OBT_PROP_ATOM(WM_DELETE_WINDOW
))
1500 /* this means we can request the window to close */
1501 self
->delete_window
= TRUE
;
1502 else if (proto
[i
] == OBT_PROP_ATOM(WM_TAKE_FOCUS
))
1503 /* if this protocol is requested, then the window will be
1504 notified whenever we want it to receive focus */
1505 self
->focus_notify
= TRUE
;
1506 else if (proto
[i
] == OBT_PROP_ATOM(NET_WM_PING
))
1507 /* if this protocol is requested, then the window will allow
1508 pings to determine if it is still alive */
1511 else if (proto
[i
] == OBT_PROP_ATOM(NET_WM_SYNC_REQUEST
))
1512 /* if this protocol is requested, then resizing the
1513 window will be synchronized between the frame and the
1515 self
->sync_request
= TRUE
;
1523 void client_update_sync_request_counter(ObClient
*self
)
1527 if (OBT_PROP_GET32(self
->window
, NET_WM_SYNC_REQUEST_COUNTER
, CARDINAL
,&i
))
1529 self
->sync_counter
= i
;
1531 self
->sync_counter
= None
;
1535 static void client_get_colormap(ObClient
*self
)
1537 XWindowAttributes wa
;
1539 if (XGetWindowAttributes(obt_display
, self
->window
, &wa
))
1540 client_update_colormap(self
, wa
.colormap
);
1543 void client_update_colormap(ObClient
*self
, Colormap colormap
)
1545 if (colormap
== self
->colormap
) return;
1547 ob_debug("Setting client %s colormap: 0x%x", self
->title
, colormap
);
1549 if (client_focused(self
)) {
1550 screen_install_colormap(self
, FALSE
); /* uninstall old one */
1551 self
->colormap
= colormap
;
1552 screen_install_colormap(self
, TRUE
); /* install new one */
1554 self
->colormap
= colormap
;
1557 void client_update_normal_hints(ObClient
*self
)
1563 self
->min_ratio
= 0.0f
;
1564 self
->max_ratio
= 0.0f
;
1565 SIZE_SET(self
->size_inc
, 1, 1);
1566 SIZE_SET(self
->base_size
, -1, -1);
1567 SIZE_SET(self
->min_size
, 0, 0);
1568 SIZE_SET(self
->max_size
, G_MAXINT
, G_MAXINT
);
1570 /* get the hints from the window */
1571 if (XGetWMNormalHints(obt_display
, self
->window
, &size
, &ret
)) {
1572 /* normal windows can't request placement! har har
1573 if (!client_normal(self))
1575 self
->positioned
= (size
.flags
& (PPosition
|USPosition
));
1576 self
->sized
= (size
.flags
& (PSize
|USSize
));
1578 if (size
.flags
& PWinGravity
)
1579 self
->gravity
= size
.win_gravity
;
1581 if (size
.flags
& PAspect
) {
1582 if (size
.min_aspect
.y
)
1584 (gfloat
) size
.min_aspect
.x
/ size
.min_aspect
.y
;
1585 if (size
.max_aspect
.y
)
1587 (gfloat
) size
.max_aspect
.x
/ size
.max_aspect
.y
;
1590 if (size
.flags
& PMinSize
)
1591 SIZE_SET(self
->min_size
, size
.min_width
, size
.min_height
);
1593 if (size
.flags
& PMaxSize
)
1594 SIZE_SET(self
->max_size
, size
.max_width
, size
.max_height
);
1596 if (size
.flags
& PBaseSize
)
1597 SIZE_SET(self
->base_size
, size
.base_width
, size
.base_height
);
1599 if (size
.flags
& PResizeInc
&& size
.width_inc
&& size
.height_inc
)
1600 SIZE_SET(self
->size_inc
, size
.width_inc
, size
.height_inc
);
1602 ob_debug("Normal hints: min size (%d %d) max size (%d %d)",
1603 self
->min_size
.width
, self
->min_size
.height
,
1604 self
->max_size
.width
, self
->max_size
.height
);
1605 ob_debug("size inc (%d %d) base size (%d %d)",
1606 self
->size_inc
.width
, self
->size_inc
.height
,
1607 self
->base_size
.width
, self
->base_size
.height
);
1610 ob_debug("Normal hints: not set");
1613 void client_setup_decor_and_functions(ObClient
*self
, gboolean reconfig
)
1615 /* start with everything (cept fullscreen) */
1617 (OB_FRAME_DECOR_TITLEBAR
|
1618 OB_FRAME_DECOR_HANDLE
|
1619 OB_FRAME_DECOR_GRIPS
|
1620 OB_FRAME_DECOR_BORDER
|
1621 OB_FRAME_DECOR_ICON
|
1622 OB_FRAME_DECOR_ALLDESKTOPS
|
1623 OB_FRAME_DECOR_ICONIFY
|
1624 OB_FRAME_DECOR_MAXIMIZE
|
1625 OB_FRAME_DECOR_SHADE
|
1626 OB_FRAME_DECOR_CLOSE
);
1628 (OB_CLIENT_FUNC_RESIZE
|
1629 OB_CLIENT_FUNC_MOVE
|
1630 OB_CLIENT_FUNC_ICONIFY
|
1631 OB_CLIENT_FUNC_MAXIMIZE
|
1632 OB_CLIENT_FUNC_SHADE
|
1633 OB_CLIENT_FUNC_CLOSE
|
1634 OB_CLIENT_FUNC_BELOW
|
1635 OB_CLIENT_FUNC_ABOVE
|
1636 OB_CLIENT_FUNC_UNDECORATE
);
1638 if (!(self
->min_size
.width
< self
->max_size
.width
||
1639 self
->min_size
.height
< self
->max_size
.height
))
1640 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1642 switch (self
->type
) {
1643 case OB_CLIENT_TYPE_NORMAL
:
1644 /* normal windows retain all of the possible decorations and
1645 functionality, and can be fullscreen */
1646 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1649 case OB_CLIENT_TYPE_DIALOG
:
1650 /* sometimes apps make dialog windows fullscreen for some reason (for
1651 e.g. kpdf does this..) */
1652 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1655 case OB_CLIENT_TYPE_UTILITY
:
1656 /* these windows don't have anything added or removed by default */
1659 case OB_CLIENT_TYPE_MENU
:
1660 case OB_CLIENT_TYPE_TOOLBAR
:
1661 /* these windows can't iconify or maximize */
1662 self
->decorations
&= ~(OB_FRAME_DECOR_ICONIFY
|
1663 OB_FRAME_DECOR_MAXIMIZE
);
1664 self
->functions
&= ~(OB_CLIENT_FUNC_ICONIFY
|
1665 OB_CLIENT_FUNC_MAXIMIZE
);
1668 case OB_CLIENT_TYPE_SPLASH
:
1669 /* these don't get get any decorations, and the only thing you can
1670 do with them is move them */
1671 self
->decorations
= 0;
1672 self
->functions
= OB_CLIENT_FUNC_MOVE
;
1675 case OB_CLIENT_TYPE_DESKTOP
:
1676 /* these windows are not manipulated by the window manager */
1677 self
->decorations
= 0;
1678 self
->functions
= 0;
1681 case OB_CLIENT_TYPE_DOCK
:
1682 /* these windows are not manipulated by the window manager, but they
1683 can set below layer which has a special meaning */
1684 self
->decorations
= 0;
1685 self
->functions
= OB_CLIENT_FUNC_BELOW
;
1689 /* Mwm Hints are applied subtractively to what has already been chosen for
1690 decor and functionality */
1691 if (self
->mwmhints
.flags
& OB_MWM_FLAG_DECORATIONS
) {
1692 if (! (self
->mwmhints
.decorations
& OB_MWM_DECOR_ALL
)) {
1693 if (! ((self
->mwmhints
.decorations
& OB_MWM_DECOR_HANDLE
) ||
1694 (self
->mwmhints
.decorations
& OB_MWM_DECOR_TITLE
)))
1696 /* if the mwm hints request no handle or title, then all
1697 decorations are disabled, but keep the border if that's
1699 if (self
->mwmhints
.decorations
& OB_MWM_DECOR_BORDER
)
1700 self
->decorations
= OB_FRAME_DECOR_BORDER
;
1702 self
->decorations
= 0;
1707 if (self
->mwmhints
.flags
& OB_MWM_FLAG_FUNCTIONS
) {
1708 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_ALL
)) {
1709 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_RESIZE
))
1710 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1711 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_MOVE
))
1712 self
->functions
&= ~OB_CLIENT_FUNC_MOVE
;
1713 /* dont let mwm hints kill any buttons
1714 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1715 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1716 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1717 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1719 /* dont let mwm hints kill the close button
1720 if (! (self->mwmhints.functions & MwmFunc_Close))
1721 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1725 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
))
1726 self
->decorations
&= ~OB_FRAME_DECOR_SHADE
;
1727 if (!(self
->functions
& OB_CLIENT_FUNC_ICONIFY
))
1728 self
->decorations
&= ~OB_FRAME_DECOR_ICONIFY
;
1729 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
))
1730 self
->decorations
&= ~(OB_FRAME_DECOR_GRIPS
| OB_FRAME_DECOR_HANDLE
);
1732 /* can't maximize without moving/resizing */
1733 if (!((self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) &&
1734 (self
->functions
& OB_CLIENT_FUNC_MOVE
) &&
1735 (self
->functions
& OB_CLIENT_FUNC_RESIZE
))) {
1736 self
->functions
&= ~OB_CLIENT_FUNC_MAXIMIZE
;
1737 self
->decorations
&= ~OB_FRAME_DECOR_MAXIMIZE
;
1740 if (self
->max_horz
&& self
->max_vert
) {
1741 /* you can't resize fully maximized windows */
1742 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1743 /* kill the handle on fully maxed windows */
1744 self
->decorations
&= ~(OB_FRAME_DECOR_HANDLE
| OB_FRAME_DECOR_GRIPS
);
1747 /* If there are no decorations to remove, don't allow the user to try
1749 if (self
->decorations
== 0)
1750 self
->functions
&= ~OB_CLIENT_FUNC_UNDECORATE
;
1752 /* finally, the user can have requested no decorations, which overrides
1753 everything (but doesnt give it a border if it doesnt have one) */
1754 if (self
->undecorated
)
1755 self
->decorations
= 0;
1757 /* if we don't have a titlebar, then we cannot shade! */
1758 if (!(self
->decorations
& OB_FRAME_DECOR_TITLEBAR
))
1759 self
->functions
&= ~OB_CLIENT_FUNC_SHADE
;
1761 /* now we need to check against rules for the client's current state */
1762 if (self
->fullscreen
) {
1763 self
->functions
&= (OB_CLIENT_FUNC_CLOSE
|
1764 OB_CLIENT_FUNC_FULLSCREEN
|
1765 OB_CLIENT_FUNC_ICONIFY
);
1766 self
->decorations
= 0;
1769 client_change_allowed_actions(self
);
1772 /* force reconfigure to make sure decorations are updated */
1773 client_reconfigure(self
, TRUE
);
1776 static void client_change_allowed_actions(ObClient
*self
)
1781 /* desktop windows are kept on all desktops */
1782 if (self
->type
!= OB_CLIENT_TYPE_DESKTOP
)
1783 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_CHANGE_DESKTOP
);
1785 if (self
->functions
& OB_CLIENT_FUNC_SHADE
)
1786 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_SHADE
);
1787 if (self
->functions
& OB_CLIENT_FUNC_CLOSE
)
1788 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_CLOSE
);
1789 if (self
->functions
& OB_CLIENT_FUNC_MOVE
)
1790 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MOVE
);
1791 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
)
1792 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MINIMIZE
);
1793 if (self
->functions
& OB_CLIENT_FUNC_RESIZE
)
1794 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_RESIZE
);
1795 if (self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
)
1796 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_FULLSCREEN
);
1797 if (self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) {
1798 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_HORZ
);
1799 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_VERT
);
1801 if (self
->functions
& OB_CLIENT_FUNC_ABOVE
)
1802 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_ABOVE
);
1803 if (self
->functions
& OB_CLIENT_FUNC_BELOW
)
1804 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_BELOW
);
1805 if (self
->functions
& OB_CLIENT_FUNC_UNDECORATE
)
1806 actions
[num
++] = OBT_PROP_ATOM(OB_WM_ACTION_UNDECORATE
);
1808 OBT_PROP_SETA32(self
->window
, NET_WM_ALLOWED_ACTIONS
, ATOM
, actions
, num
);
1810 /* make sure the window isn't breaking any rules now
1812 don't check ICONIFY here. just cuz a window can't iconify doesnt mean
1813 it can't be iconified with its parent
1816 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
) && self
->shaded
) {
1817 if (self
->frame
) client_shade(self
, FALSE
);
1818 else self
->shaded
= FALSE
;
1820 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) && self
->fullscreen
) {
1821 if (self
->frame
) client_fullscreen(self
, FALSE
);
1822 else self
->fullscreen
= FALSE
;
1824 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && (self
->max_horz
||
1826 if (self
->frame
) client_maximize(self
, FALSE
, 0);
1827 else self
->max_vert
= self
->max_horz
= FALSE
;
1831 void client_update_wmhints(ObClient
*self
)
1835 /* assume a window takes input if it doesn't specify */
1836 self
->can_focus
= TRUE
;
1838 if ((hints
= XGetWMHints(obt_display
, self
->window
)) != NULL
) {
1841 if (hints
->flags
& InputHint
)
1842 self
->can_focus
= hints
->input
;
1844 /* only do this when first managing the window *AND* when we aren't
1846 if (ob_state() != OB_STATE_STARTING
&& self
->frame
== NULL
)
1847 if (hints
->flags
& StateHint
)
1848 self
->iconic
= hints
->initial_state
== IconicState
;
1851 self
->urgent
= (hints
->flags
& XUrgencyHint
);
1852 if (self
->urgent
&& !ur
)
1853 client_hilite(self
, TRUE
);
1854 else if (!self
->urgent
&& ur
&& self
->demands_attention
)
1855 client_hilite(self
, FALSE
);
1857 if (!(hints
->flags
& WindowGroupHint
))
1858 hints
->window_group
= None
;
1860 /* did the group state change? */
1861 if (hints
->window_group
!=
1862 (self
->group
? self
->group
->leader
: None
))
1864 ObGroup
*oldgroup
= self
->group
;
1866 /* remove from the old group if there was one */
1868 group_remove(self
->group
, self
);
1872 /* add ourself to the group if we have one */
1873 if (hints
->window_group
!= None
) {
1874 self
->group
= group_add(hints
->window_group
, self
);
1877 /* Put ourselves into the new group's transient tree, and remove
1878 ourselves from the old group's */
1879 client_update_transient_tree(self
, oldgroup
, self
->group
,
1880 self
->transient_for_group
,
1881 self
->transient_for_group
,
1882 client_direct_parent(self
),
1883 client_direct_parent(self
));
1885 /* Lastly, being in a group, or not, can change if the window is
1886 transient for anything.
1888 The logic for this is:
1889 self->transient = TRUE always if the window wants to be
1890 transient for something, even if transient_for was NULL because
1891 it wasn't in a group before.
1893 If parents was NULL and oldgroup was NULL we can assume
1894 that when we add the new group, it will become transient for
1897 If transient_for_group is TRUE, then it must have already
1898 had a group. If it is getting a new group, the above call to
1899 client_update_transient_tree has already taken care of
1900 everything ! If it is losing all group status then it will
1901 no longer be transient for anything and that needs to be
1904 if (self
->transient
&&
1905 ((self
->parents
== NULL
&& oldgroup
== NULL
) ||
1906 (self
->transient_for_group
&& !self
->group
)))
1907 client_update_transient_for(self
);
1910 /* the WM_HINTS can contain an icon */
1911 if (hints
->flags
& IconPixmapHint
)
1912 client_update_icons(self
);
1918 void client_update_title(ObClient
*self
)
1921 gchar
*visible
= NULL
;
1923 g_free(self
->title
);
1924 g_free(self
->original_title
);
1927 if (!OBT_PROP_GETS(self
->window
, NET_WM_NAME
, utf8
, &data
)) {
1928 /* try old x stuff */
1929 if (!(OBT_PROP_GETS(self
->window
, WM_NAME
, locale
, &data
)
1930 || OBT_PROP_GETS(self
->window
, WM_NAME
, utf8
, &data
))) {
1931 if (self
->transient
) {
1933 GNOME alert windows are not given titles:
1934 http://developer.gnome.org/projects/gup/hig/draft_hig_new/windows-alert.html
1936 data
= g_strdup("");
1938 data
= g_strdup(_("Unnamed Window"));
1941 self
->original_title
= g_strdup(data
);
1943 if (self
->client_machine
) {
1944 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1949 if (self
->not_responding
) {
1951 if (self
->kill_level
> 0)
1952 visible
= g_strdup_printf("%s - [%s]", data
, _("Killing..."));
1954 visible
= g_strdup_printf("%s - [%s]", data
, _("Not Responding"));
1958 OBT_PROP_SETS(self
->window
, NET_WM_VISIBLE_NAME
, utf8
, visible
);
1959 self
->title
= visible
;
1962 frame_adjust_title(self
->frame
);
1964 /* update the icon title */
1966 g_free(self
->icon_title
);
1969 if (!OBT_PROP_GETS(self
->window
, NET_WM_ICON_NAME
, utf8
, &data
))
1970 /* try old x stuff */
1971 if (!(OBT_PROP_GETS(self
->window
, WM_ICON_NAME
, locale
, &data
) ||
1972 OBT_PROP_GETS(self
->window
, WM_ICON_NAME
, utf8
, &data
)))
1973 data
= g_strdup(self
->title
);
1975 if (self
->client_machine
) {
1976 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1981 if (self
->not_responding
) {
1983 if (self
->kill_level
> 0)
1984 visible
= g_strdup_printf("%s - [%s]", data
, _("Killing..."));
1986 visible
= g_strdup_printf("%s - [%s]", data
, _("Not Responding"));
1990 OBT_PROP_SETS(self
->window
, NET_WM_VISIBLE_ICON_NAME
, utf8
, visible
);
1991 self
->icon_title
= visible
;
1994 void client_update_strut(ObClient
*self
)
1998 gboolean got
= FALSE
;
2001 if (OBT_PROP_GETA32(self
->window
, NET_WM_STRUT_PARTIAL
, CARDINAL
,
2006 STRUT_PARTIAL_SET(strut
,
2007 data
[0], data
[2], data
[1], data
[3],
2008 data
[4], data
[5], data
[8], data
[9],
2009 data
[6], data
[7], data
[10], data
[11]);
2015 OBT_PROP_GETA32(self
->window
, NET_WM_STRUT
, CARDINAL
, &data
, &num
)) {
2021 /* use the screen's width/height */
2022 a
= screen_physical_area_all_monitors();
2024 STRUT_PARTIAL_SET(strut
,
2025 data
[0], data
[2], data
[1], data
[3],
2026 a
->y
, a
->y
+ a
->height
- 1,
2027 a
->x
, a
->x
+ a
->width
- 1,
2028 a
->y
, a
->y
+ a
->height
- 1,
2029 a
->x
, a
->x
+ a
->width
- 1);
2036 STRUT_PARTIAL_SET(strut
, 0, 0, 0, 0,
2037 0, 0, 0, 0, 0, 0, 0, 0);
2039 if (!STRUT_EQUAL(strut
, self
->strut
)) {
2040 self
->strut
= strut
;
2042 /* updating here is pointless while we're being mapped cuz we're not in
2043 the client list yet */
2045 screen_update_areas();
2049 void client_update_icons(ObClient
*self
)
2054 guint num_seen
; /* number of icons present */
2059 /* grab the server, because we might be setting the window's icon and
2060 we don't want them to set it in between and we overwrite their own
2064 if (OBT_PROP_GETA32(self
->window
, NET_WM_ICON
, CARDINAL
, &data
, &num
)) {
2065 /* figure out how many valid icons are in here */
2068 while (i
+ 2 < num
) { /* +2 is to make sure there is a w and h */
2071 /* watch for the data being too small for the specified size,
2072 or for zero sized icons. */
2073 if (i
+ w
*h
> num
|| w
== 0 || h
== 0) break;
2075 /* convert it to the right bit order for ObRender */
2076 for (j
= 0; j
< w
*h
; ++j
)
2078 (((data
[i
+j
] >> 24) & 0xff) << RrDefaultAlphaOffset
) +
2079 (((data
[i
+j
] >> 16) & 0xff) << RrDefaultRedOffset
) +
2080 (((data
[i
+j
] >> 8) & 0xff) << RrDefaultGreenOffset
) +
2081 (((data
[i
+j
] >> 0) & 0xff) << RrDefaultBlueOffset
);
2083 /* is it in the cache? */
2084 img
= RrImageCacheFind(ob_rr_icons
, &data
[i
], w
, h
);
2085 if (img
) RrImageRef(img
); /* own it */
2090 /* don't bother looping anymore if we already found it in the cache
2091 since we'll just use that! */
2095 /* if it's not in the cache yet, then add it to the cache now.
2096 we have already converted it to the correct bit order above */
2097 if (!img
&& num_seen
> 0) {
2098 img
= RrImageNew(ob_rr_icons
);
2100 for (j
= 0; j
< num_seen
; ++j
) {
2103 RrImageAddPicture(img
, &data
[i
], w
, h
);
2111 /* if we didn't find an image from the NET_WM_ICON stuff, then try the
2116 if ((hints
= XGetWMHints(obt_display
, self
->window
))) {
2117 if (hints
->flags
& IconPixmapHint
) {
2119 obt_display_ignore_errors(TRUE
);
2120 xicon
= RrPixmapToRGBA(ob_rr_inst
,
2122 (hints
->flags
& IconMaskHint
?
2123 hints
->icon_mask
: None
),
2124 (gint
*)&w
, (gint
*)&h
, &data
);
2125 obt_display_ignore_errors(FALSE
);
2128 if (w
> 0 && h
> 0) {
2129 /* is this icon in the cache yet? */
2130 img
= RrImageCacheFind(ob_rr_icons
, data
, w
, h
);
2131 if (img
) RrImageRef(img
); /* own it */
2133 /* if not, then add it */
2135 img
= RrImageNew(ob_rr_icons
);
2136 RrImageAddPicture(img
, data
, w
, h
);
2147 /* set the client's icons to be whatever we found */
2148 RrImageUnref(self
->icon_set
);
2149 self
->icon_set
= img
;
2151 /* if the client has no icon at all, then we set a default icon onto it.
2152 but, if it has parents, then one of them will have an icon already
2154 if (!self
->icon_set
&& !self
->parents
) {
2155 RrPixel32
*icon
= ob_rr_theme
->def_win_icon
;
2156 gulong
*ldata
; /* use a long here to satisfy OBT_PROP_SETA32 */
2158 w
= ob_rr_theme
->def_win_icon_w
;
2159 h
= ob_rr_theme
->def_win_icon_h
;
2160 ldata
= g_new(gulong
, w
*h
+2);
2163 for (i
= 0; i
< w
*h
; ++i
)
2164 ldata
[i
+2] = (((icon
[i
] >> RrDefaultAlphaOffset
) & 0xff) << 24) +
2165 (((icon
[i
] >> RrDefaultRedOffset
) & 0xff) << 16) +
2166 (((icon
[i
] >> RrDefaultGreenOffset
) & 0xff) << 8) +
2167 (((icon
[i
] >> RrDefaultBlueOffset
) & 0xff) << 0);
2168 OBT_PROP_SETA32(self
->window
, NET_WM_ICON
, CARDINAL
, ldata
, w
*h
+2);
2170 } else if (self
->frame
)
2171 /* don't draw the icon empty if we're just setting one now anyways,
2172 we'll get the property change any second */
2173 frame_adjust_icon(self
->frame
);
2178 void client_update_icon_geometry(ObClient
*self
)
2183 RECT_SET(self
->icon_geometry
, 0, 0, 0, 0);
2185 if (OBT_PROP_GETA32(self
->window
, NET_WM_ICON_GEOMETRY
, CARDINAL
,
2189 /* don't let them set it with an area < 0 */
2190 RECT_SET(self
->icon_geometry
, data
[0], data
[1],
2191 MAX(data
[2],0), MAX(data
[3],0));
2196 static void client_get_session_ids(ObClient
*self
)
2203 if (!OBT_PROP_GET32(self
->window
, WM_CLIENT_LEADER
, WINDOW
, &leader
))
2206 /* get the SM_CLIENT_ID */
2209 got
= OBT_PROP_GETS(leader
, SM_CLIENT_ID
, locale
, &self
->sm_client_id
);
2211 OBT_PROP_GETS(self
->window
, SM_CLIENT_ID
, locale
, &self
->sm_client_id
);
2213 /* get the WM_CLASS (name and class). make them "" if they are not
2217 got
= OBT_PROP_GETSS(leader
, WM_CLASS
, locale
, &ss
);
2219 got
= OBT_PROP_GETSS(self
->window
, WM_CLASS
, locale
, &ss
);
2223 self
->name
= g_strdup(ss
[0]);
2225 self
->class = g_strdup(ss
[1]);
2230 if (self
->name
== NULL
) self
->name
= g_strdup("");
2231 if (self
->class == NULL
) self
->class = g_strdup("");
2233 /* get the WM_WINDOW_ROLE. make it "" if it is not provided */
2236 got
= OBT_PROP_GETS(leader
, WM_WINDOW_ROLE
, locale
, &s
);
2238 got
= OBT_PROP_GETS(self
->window
, WM_WINDOW_ROLE
, locale
, &s
);
2243 self
->role
= g_strdup("");
2245 /* get the WM_COMMAND */
2249 got
= OBT_PROP_GETSS(leader
, WM_COMMAND
, locale
, &ss
);
2251 got
= OBT_PROP_GETSS(self
->window
, WM_COMMAND
, locale
, &ss
);
2254 /* merge/mash them all together */
2255 gchar
*merge
= NULL
;
2258 for (i
= 0; ss
[i
]; ++i
) {
2261 merge
= g_strconcat(merge
, ss
[i
], NULL
);
2263 merge
= g_strconcat(ss
[i
], NULL
);
2268 self
->wm_command
= merge
;
2271 /* get the WM_CLIENT_MACHINE */
2274 got
= OBT_PROP_GETS(leader
, WM_CLIENT_MACHINE
, locale
, &s
);
2276 got
= OBT_PROP_GETS(self
->window
, WM_CLIENT_MACHINE
, locale
, &s
);
2279 gchar localhost
[128];
2282 gethostname(localhost
, 127);
2283 localhost
[127] = '\0';
2284 if (strcmp(localhost
, s
) != 0)
2285 self
->client_machine
= s
;
2289 /* see if it has the PID set too (the PID requires that the
2290 WM_CLIENT_MACHINE be set) */
2291 if (OBT_PROP_GET32(self
->window
, NET_WM_PID
, CARDINAL
, &pid
))
2296 static void client_change_wm_state(ObClient
*self
)
2301 old
= self
->wmstate
;
2303 if (self
->shaded
|| self
->iconic
||
2304 (self
->desktop
!= DESKTOP_ALL
&& self
->desktop
!= screen_desktop
))
2306 self
->wmstate
= IconicState
;
2308 self
->wmstate
= NormalState
;
2310 if (old
!= self
->wmstate
) {
2311 OBT_PROP_MSG(ob_screen
, self
->window
, KDE_WM_CHANGE_STATE
,
2312 self
->wmstate
, 1, 0, 0, 0);
2314 state
[0] = self
->wmstate
;
2316 OBT_PROP_SETA32(self
->window
, WM_STATE
, WM_STATE
, state
, 2);
2320 static void client_change_state(ObClient
*self
)
2322 gulong netstate
[12];
2327 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MODAL
);
2329 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SHADED
);
2331 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
);
2332 if (self
->skip_taskbar
)
2333 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
);
2334 if (self
->skip_pager
)
2335 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
);
2336 if (self
->fullscreen
)
2337 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
);
2339 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
);
2341 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
);
2343 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_ABOVE
);
2345 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_BELOW
);
2346 if (self
->demands_attention
)
2347 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
);
2348 if (self
->undecorated
)
2349 netstate
[num
++] = OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
);
2350 OBT_PROP_SETA32(self
->window
, NET_WM_STATE
, ATOM
, netstate
, num
);
2353 frame_adjust_state(self
->frame
);
2356 ObClient
*client_search_focus_tree(ObClient
*self
)
2361 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
2362 if (client_focused(it
->data
)) return it
->data
;
2363 if ((ret
= client_search_focus_tree(it
->data
))) return ret
;
2368 ObClient
*client_search_focus_tree_full(ObClient
*self
)
2370 if (self
->parents
) {
2373 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
2374 ObClient
*c
= it
->data
;
2375 if ((c
= client_search_focus_tree_full(it
->data
))) return c
;
2381 /* this function checks the whole tree, the client_search_focus_tree
2382 does not, so we need to check this window */
2383 if (client_focused(self
))
2385 return client_search_focus_tree(self
);
2389 ObClient
*client_search_focus_group_full(ObClient
*self
)
2394 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
2395 ObClient
*c
= it
->data
;
2397 if (client_focused(c
)) return c
;
2398 if ((c
= client_search_focus_tree(it
->data
))) return c
;
2401 if (client_focused(self
)) return self
;
2405 gboolean
client_has_parent(ObClient
*self
)
2407 return self
->parents
!= NULL
;
2410 static ObStackingLayer
calc_layer(ObClient
*self
)
2415 monitor
= screen_physical_area_monitor(client_monitor(self
));
2417 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
2418 l
= OB_STACKING_LAYER_DESKTOP
;
2419 else if (self
->type
== OB_CLIENT_TYPE_DOCK
) {
2420 if (self
->below
) l
= OB_STACKING_LAYER_NORMAL
;
2421 else l
= OB_STACKING_LAYER_ABOVE
;
2423 else if ((self
->fullscreen
||
2424 /* No decorations and fills the monitor = oldskool fullscreen.
2425 But not for maximized windows.
2427 (self
->decorations
== 0 &&
2428 !(self
->max_horz
&& self
->max_vert
) &&
2429 RECT_EQUAL(self
->area
, *monitor
))) &&
2430 /* you are fullscreen while you or your children are focused.. */
2431 (client_focused(self
) || client_search_focus_tree(self
) ||
2432 /* you can be fullscreen if you're on another desktop */
2433 (self
->desktop
!= screen_desktop
&&
2434 self
->desktop
!= DESKTOP_ALL
) ||
2435 /* and you can also be fullscreen if the focused client is on
2436 another monitor, or nothing else is focused */
2438 client_monitor(focus_client
) != client_monitor(self
))))
2439 l
= OB_STACKING_LAYER_FULLSCREEN
;
2440 else if (self
->above
) l
= OB_STACKING_LAYER_ABOVE
;
2441 else if (self
->below
) l
= OB_STACKING_LAYER_BELOW
;
2442 else l
= OB_STACKING_LAYER_NORMAL
;
2449 static void client_calc_layer_recursive(ObClient
*self
, ObClient
*orig
,
2450 ObStackingLayer min
)
2452 ObStackingLayer old
, own
;
2456 own
= calc_layer(self
);
2457 self
->layer
= MAX(own
, min
);
2459 if (self
->layer
!= old
) {
2460 stacking_remove(CLIENT_AS_WINDOW(self
));
2461 stacking_add_nonintrusive(CLIENT_AS_WINDOW(self
));
2464 /* we've been restacked */
2465 self
->visited
= TRUE
;
2467 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
2468 client_calc_layer_recursive(it
->data
, orig
,
2472 static void client_calc_layer_internal(ObClient
*self
)
2476 /* transients take on the layer of their parents */
2477 sit
= client_search_all_top_parents(self
);
2479 for (; sit
; sit
= g_slist_next(sit
))
2480 client_calc_layer_recursive(sit
->data
, self
, 0);
2483 void client_calc_layer(ObClient
*self
)
2487 /* skip over stuff above fullscreen layer */
2488 for (it
= stacking_list
; it
; it
= g_list_next(it
))
2489 if (window_layer(it
->data
) <= OB_STACKING_LAYER_FULLSCREEN
) break;
2491 /* find the windows in the fullscreen layer, and mark them not-visited */
2492 for (; it
; it
= g_list_next(it
)) {
2493 if (window_layer(it
->data
) < OB_STACKING_LAYER_FULLSCREEN
) break;
2494 else if (WINDOW_IS_CLIENT(it
->data
))
2495 WINDOW_AS_CLIENT(it
->data
)->visited
= FALSE
;
2498 client_calc_layer_internal(self
);
2500 /* skip over stuff above fullscreen layer */
2501 for (it
= stacking_list
; it
; it
= g_list_next(it
))
2502 if (window_layer(it
->data
) <= OB_STACKING_LAYER_FULLSCREEN
) break;
2504 /* now recalc any windows in the fullscreen layer which have not
2505 had their layer recalced already */
2506 for (; it
; it
= g_list_next(it
)) {
2507 if (window_layer(it
->data
) < OB_STACKING_LAYER_FULLSCREEN
) break;
2508 else if (WINDOW_IS_CLIENT(it
->data
) &&
2509 !WINDOW_AS_CLIENT(it
->data
)->visited
)
2510 client_calc_layer_internal(it
->data
);
2514 gboolean
client_should_show(ObClient
*self
)
2518 if (client_normal(self
) && screen_showing_desktop
)
2520 if (self
->desktop
== screen_desktop
|| self
->desktop
== DESKTOP_ALL
)
2526 gboolean
client_show(ObClient
*self
)
2528 gboolean show
= FALSE
;
2530 if (client_should_show(self
)) {
2531 /* replay pending pointer event before showing the window, in case it
2532 should be going to something under the window */
2533 mouse_replay_pointer();
2535 frame_show(self
->frame
);
2538 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible,
2539 it needs to be in IconicState. This includes when it is on another
2542 client_change_wm_state(self
);
2544 hooks_queue(OB_HOOK_WIN_VISIBLE
, self
);
2549 gboolean
client_hide(ObClient
*self
)
2551 gboolean hide
= FALSE
;
2553 if (!client_should_show(self
)) {
2554 if (self
== focus_client
) {
2555 event_cancel_all_key_grabs();
2558 /* We don't need to ignore enter events here.
2559 The window can hide/iconify in 3 different ways:
2560 1 - through an x message. in this case we ignore all enter events
2561 caused by responding to the x message (unless underMouse)
2562 2 - by a keyboard action. in this case we ignore all enter events
2563 caused by the action
2564 3 - by a mouse action. in this case they are doing stuff with the
2565 mouse and focus _should_ move.
2567 Also in action_end, we simulate an enter event that can't be ignored
2568 so trying to ignore them is futile in case 3 anyways
2571 /* replay pending pointer event before hiding the window, in case it
2572 should be going to the window */
2573 mouse_replay_pointer();
2575 frame_hide(self
->frame
);
2578 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible,
2579 it needs to be in IconicState. This includes when it is on another
2582 client_change_wm_state(self
);
2584 hooks_queue(OB_HOOK_WIN_INVISIBLE
, self
);
2589 void client_showhide(ObClient
*self
)
2591 if (!client_show(self
))
2595 gboolean
client_normal(ObClient
*self
) {
2596 return ! (self
->type
== OB_CLIENT_TYPE_DESKTOP
||
2597 self
->type
== OB_CLIENT_TYPE_DOCK
||
2598 self
->type
== OB_CLIENT_TYPE_SPLASH
);
2601 gboolean
client_helper(ObClient
*self
)
2603 return (self
->type
== OB_CLIENT_TYPE_UTILITY
||
2604 self
->type
== OB_CLIENT_TYPE_MENU
||
2605 self
->type
== OB_CLIENT_TYPE_TOOLBAR
);
2608 gboolean
client_mouse_focusable(ObClient
*self
)
2610 return !(self
->type
== OB_CLIENT_TYPE_MENU
||
2611 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
2612 self
->type
== OB_CLIENT_TYPE_SPLASH
||
2613 self
->type
== OB_CLIENT_TYPE_DOCK
);
2616 gboolean
client_enter_focusable(ObClient
*self
)
2618 /* you can focus desktops but it shouldn't on enter */
2619 return (client_mouse_focusable(self
) &&
2620 self
->type
!= OB_CLIENT_TYPE_DESKTOP
);
2623 static void client_apply_startup_state(ObClient
*self
,
2624 gint x
, gint y
, gint w
, gint h
)
2626 /* save the states that we are going to apply */
2627 gboolean iconic
= self
->iconic
;
2628 gboolean fullscreen
= self
->fullscreen
;
2629 gboolean undecorated
= self
->undecorated
;
2630 gboolean shaded
= self
->shaded
;
2631 gboolean demands_attention
= self
->demands_attention
;
2632 gboolean max_horz
= self
->max_horz
;
2633 gboolean max_vert
= self
->max_vert
;
2637 /* turn them all off in the client, so they won't affect the window
2639 self
->iconic
= self
->fullscreen
= self
->undecorated
= self
->shaded
=
2640 self
->demands_attention
= self
->max_horz
= self
->max_vert
= FALSE
;
2642 /* move the client to its placed position, or it it's already there,
2643 generate a ConfigureNotify telling the client where it is.
2645 do this after adjusting the frame. otherwise it gets all weird and
2646 clients don't work right
2648 do this before applying the states so they have the correct
2649 pre-max/pre-fullscreen values
2651 client_try_configure(self
, &x
, &y
, &w
, &h
, &l
, &l
, FALSE
);
2652 ob_debug("placed window 0x%x at %d, %d with size %d x %d",
2653 self
->window
, x
, y
, w
, h
);
2654 /* save the area, and make it where it should be for the premax stuff */
2655 oldarea
= self
->area
;
2656 RECT_SET(self
->area
, x
, y
, w
, h
);
2658 /* apply the states. these are in a carefully crafted order.. */
2661 client_iconify(self
, TRUE
, FALSE
, TRUE
);
2663 client_fullscreen(self
, TRUE
);
2665 client_set_undecorated(self
, TRUE
);
2667 client_shade(self
, TRUE
);
2668 if (demands_attention
)
2669 client_hilite(self
, TRUE
);
2671 if (max_vert
&& max_horz
)
2672 client_maximize(self
, TRUE
, 0);
2674 client_maximize(self
, TRUE
, 2);
2676 client_maximize(self
, TRUE
, 1);
2678 /* if the window hasn't been configured yet, then do so now, in fact the
2679 x,y,w,h may _not_ be the same as the area rect, which can end up
2680 meaning that the client isn't properly moved/resized by the fullscreen
2682 pho can cause this because it maps at size of the screen but not 0,0
2683 so openbox moves it on screen to 0,0 (thus x,y=0,0 and area.x,y don't).
2684 then fullscreen'ing makes it go to 0,0 which it thinks it already is at
2685 cuz thats where the pre-fullscreen will be. however the actual area is
2686 not, so this needs to be called even if we have fullscreened/maxed
2688 self
->area
= oldarea
;
2689 client_configure(self
, x
, y
, w
, h
, FALSE
, TRUE
, FALSE
);
2691 /* set the desktop hint, to make sure that it always exists */
2692 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, self
->desktop
);
2694 /* nothing to do for the other states:
2703 void client_gravity_resize_w(ObClient
*self
, gint
*x
, gint oldw
, gint neww
)
2705 /* these should be the current values. this is for when you're not moving,
2707 g_assert(*x
== self
->area
.x
);
2708 g_assert(oldw
== self
->area
.width
);
2711 switch (self
->gravity
) {
2713 case NorthWestGravity
:
2715 case SouthWestGravity
:
2722 *x
-= (neww
- oldw
) / 2;
2724 case NorthEastGravity
:
2726 case SouthEastGravity
:
2732 void client_gravity_resize_h(ObClient
*self
, gint
*y
, gint oldh
, gint newh
)
2734 /* these should be the current values. this is for when you're not moving,
2736 g_assert(*y
== self
->area
.y
);
2737 g_assert(oldh
== self
->area
.height
);
2740 switch (self
->gravity
) {
2742 case NorthWestGravity
:
2744 case NorthEastGravity
:
2751 *y
-= (newh
- oldh
) / 2;
2753 case SouthWestGravity
:
2755 case SouthEastGravity
:
2761 void client_try_configure(ObClient
*self
, gint
*x
, gint
*y
, gint
*w
, gint
*h
,
2762 gint
*logicalw
, gint
*logicalh
,
2765 Rect desired
= {*x
, *y
, *w
, *h
};
2766 frame_rect_to_frame(self
->frame
, &desired
);
2768 /* make the frame recalculate its dimensions n shit without changing
2769 anything visible for real, this way the constraints below can work with
2770 the updated frame dimensions. */
2771 frame_adjust_area(self
->frame
, FALSE
, TRUE
, TRUE
);
2773 /* gets the frame's position */
2774 frame_client_gravity(self
->frame
, x
, y
);
2776 /* these positions are frame positions, not client positions */
2778 /* set the size and position if fullscreen */
2779 if (self
->fullscreen
) {
2783 i
= screen_find_monitor(&desired
);
2784 a
= screen_physical_area_monitor(i
);
2791 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2795 } else if (self
->max_horz
|| self
->max_vert
) {
2799 /* use all possible struts when maximizing to the full screen */
2800 i
= screen_find_monitor(&desired
);
2801 a
= screen_area(self
->desktop
, i
,
2802 (self
->max_horz
&& self
->max_vert
? NULL
: &desired
));
2804 /* set the size and position if maximized */
2805 if (self
->max_horz
) {
2807 *w
= a
->width
- self
->frame
->size
.left
- self
->frame
->size
.right
;
2809 if (self
->max_vert
) {
2811 *h
= a
->height
- self
->frame
->size
.top
- self
->frame
->size
.bottom
;
2814 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2820 /* gets the client's position */
2821 frame_frame_gravity(self
->frame
, x
, y
);
2823 /* work within the preferred sizes given by the window, these may have
2824 changed rather than it's requested width and height, so always run
2825 through this code */
2827 gint basew
, baseh
, minw
, minh
;
2829 gfloat minratio
, maxratio
;
2831 incw
= self
->fullscreen
|| self
->max_horz
? 1 : self
->size_inc
.width
;
2832 inch
= self
->fullscreen
|| self
->max_vert
? 1 : self
->size_inc
.height
;
2833 minratio
= self
->fullscreen
|| (self
->max_horz
&& self
->max_vert
) ?
2834 0 : self
->min_ratio
;
2835 maxratio
= self
->fullscreen
|| (self
->max_horz
&& self
->max_vert
) ?
2836 0 : self
->max_ratio
;
2838 /* base size is substituted with min size if not specified */
2839 if (self
->base_size
.width
>= 0 || self
->base_size
.height
>= 0) {
2840 basew
= self
->base_size
.width
;
2841 baseh
= self
->base_size
.height
;
2843 basew
= self
->min_size
.width
;
2844 baseh
= self
->min_size
.height
;
2846 /* min size is substituted with base size if not specified */
2847 if (self
->min_size
.width
|| self
->min_size
.height
) {
2848 minw
= self
->min_size
.width
;
2849 minh
= self
->min_size
.height
;
2851 minw
= self
->base_size
.width
;
2852 minh
= self
->base_size
.height
;
2855 /* This comment is no longer true */
2856 /* if this is a user-requested resize, then check against min/max
2859 /* smaller than min size or bigger than max size? */
2860 if (*w
> self
->max_size
.width
) *w
= self
->max_size
.width
;
2861 if (*w
< minw
) *w
= minw
;
2862 if (*h
> self
->max_size
.height
) *h
= self
->max_size
.height
;
2863 if (*h
< minh
) *h
= minh
;
2868 /* keep to the increments */
2872 /* you cannot resize to nothing */
2873 if (basew
+ *w
< 1) *w
= 1 - basew
;
2874 if (baseh
+ *h
< 1) *h
= 1 - baseh
;
2876 /* save the logical size */
2877 *logicalw
= incw
> 1 ? *w
: *w
+ basew
;
2878 *logicalh
= inch
> 1 ? *h
: *h
+ baseh
;
2886 /* adjust the height to match the width for the aspect ratios.
2887 for this, min size is not substituted for base size ever. */
2888 *w
-= self
->base_size
.width
;
2889 *h
-= self
->base_size
.height
;
2892 if (*h
* minratio
> *w
) {
2893 *h
= (gint
)(*w
/ minratio
);
2895 /* you cannot resize to nothing */
2898 *w
= (gint
)(*h
* minratio
);
2902 if (*h
* maxratio
< *w
) {
2903 *h
= (gint
)(*w
/ maxratio
);
2905 /* you cannot resize to nothing */
2908 *w
= (gint
)(*h
* minratio
);
2912 *w
+= self
->base_size
.width
;
2913 *h
+= self
->base_size
.height
;
2916 /* these override the above states! if you cant move you can't move! */
2918 if (!(self
->functions
& OB_CLIENT_FUNC_MOVE
)) {
2922 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
)) {
2923 *w
= self
->area
.width
;
2924 *h
= self
->area
.height
;
2932 void client_configure(ObClient
*self
, gint x
, gint y
, gint w
, gint h
,
2933 gboolean user
, gboolean final
, gboolean force_reply
)
2937 gboolean send_resize_client
;
2938 gboolean moved
= FALSE
, resized
= FALSE
, rootmoved
= FALSE
;
2939 gboolean fmoved
, fresized
;
2940 guint fdecor
= self
->frame
->decorations
;
2941 gboolean fhorz
= self
->frame
->max_horz
;
2942 gboolean fvert
= self
->frame
->max_vert
;
2943 gint logicalw
, logicalh
;
2945 /* find the new x, y, width, and height (and logical size) */
2946 client_try_configure(self
, &x
, &y
, &w
, &h
, &logicalw
, &logicalh
, user
);
2948 /* set the logical size if things changed */
2949 if (!(w
== self
->area
.width
&& h
== self
->area
.height
))
2950 SIZE_SET(self
->logical_size
, logicalw
, logicalh
);
2952 /* figure out if we moved or resized or what */
2953 moved
= (x
!= self
->area
.x
|| y
!= self
->area
.y
);
2954 resized
= (w
!= self
->area
.width
|| h
!= self
->area
.height
);
2956 oldw
= self
->area
.width
;
2957 oldh
= self
->area
.height
;
2958 oldframe
= self
->frame
->area
;
2959 RECT_SET(self
->area
, x
, y
, w
, h
);
2961 /* for app-requested resizes, always resize if 'resized' is true.
2962 for user-requested ones, only resize if final is true, or when
2963 resizing in redraw mode */
2964 send_resize_client
= ((!user
&& resized
) ||
2966 (resized
&& config_resize_redraw
))));
2968 /* if the client is enlarging, then resize the client before the frame */
2969 if (send_resize_client
&& (w
> oldw
|| h
> oldh
)) {
2970 XMoveResizeWindow(obt_display
, self
->window
,
2971 self
->frame
->size
.left
, self
->frame
->size
.top
,
2972 MAX(w
, oldw
), MAX(h
, oldh
));
2973 frame_adjust_client_area(self
->frame
);
2976 /* find the frame's dimensions and move/resize it */
2980 /* if decorations changed, then readjust everything for the frame */
2981 if (self
->decorations
!= fdecor
||
2982 self
->max_horz
!= fhorz
|| self
->max_vert
!= fvert
)
2984 fmoved
= fresized
= TRUE
;
2987 /* adjust the frame */
2988 if (fmoved
|| fresized
) {
2989 gulong ignore_start
;
2991 ignore_start
= event_start_ignore_all_enters();
2993 /* replay pending pointer event before move the window, in case it
2994 would change what window gets the event */
2995 mouse_replay_pointer();
2997 frame_adjust_area(self
->frame
, fmoved
, fresized
, FALSE
);
3000 event_end_ignore_all_enters(ignore_start
);
3003 if (!user
|| final
) {
3004 gint oldrx
= self
->root_pos
.x
;
3005 gint oldry
= self
->root_pos
.y
;
3006 /* we have reset the client to 0 border width, so don't include
3007 it in these coords */
3008 POINT_SET(self
->root_pos
,
3009 self
->frame
->area
.x
+ self
->frame
->size
.left
-
3011 self
->frame
->area
.y
+ self
->frame
->size
.top
-
3012 self
->border_width
);
3013 if (self
->root_pos
.x
!= oldrx
|| self
->root_pos
.y
!= oldry
)
3017 /* This is kinda tricky and should not be changed.. let me explain!
3019 When user = FALSE, then the request is coming from the application
3020 itself, and we are more strict about when to send a synthetic
3021 ConfigureNotify. We strictly follow the rules of the ICCCM sec 4.1.5
3022 in this case (if force_reply is true)
3024 When user = TRUE, then the request is coming from "us", like when we
3025 maximize a window or something. In this case we are more lenient. We
3026 used to follow the same rules as above, but _Java_ Swing can't handle
3027 this. So just to appease Swing, when user = TRUE, we always send
3028 a synthetic ConfigureNotify to give the window its root coordinates.
3030 if ((!user
&& !resized
&& (rootmoved
|| force_reply
)) ||
3031 (user
&& final
&& rootmoved
))
3035 event
.type
= ConfigureNotify
;
3036 event
.xconfigure
.display
= obt_display
;
3037 event
.xconfigure
.event
= self
->window
;
3038 event
.xconfigure
.window
= self
->window
;
3040 ob_debug("Sending ConfigureNotify to %s for %d,%d %dx%d",
3041 self
->title
, self
->root_pos
.x
, self
->root_pos
.y
, w
, h
);
3043 /* root window real coords */
3044 event
.xconfigure
.x
= self
->root_pos
.x
;
3045 event
.xconfigure
.y
= self
->root_pos
.y
;
3046 event
.xconfigure
.width
= w
;
3047 event
.xconfigure
.height
= h
;
3048 event
.xconfigure
.border_width
= self
->border_width
;
3049 event
.xconfigure
.above
= None
;
3050 event
.xconfigure
.override_redirect
= FALSE
;
3051 XSendEvent(event
.xconfigure
.display
, event
.xconfigure
.window
,
3052 FALSE
, StructureNotifyMask
, &event
);
3055 /* if the client is shrinking, then resize the frame before the client.
3057 both of these resize sections may run, because the top one only resizes
3058 in the direction that is growing
3060 if (send_resize_client
&& (w
<= oldw
|| h
<= oldh
)) {
3061 frame_adjust_client_area(self
->frame
);
3062 XMoveResizeWindow(obt_display
, self
->window
,
3063 self
->frame
->size
.left
, self
->frame
->size
.top
, w
, h
);
3066 XFlush(obt_display
);
3068 /* if it moved between monitors, then this can affect the stacking
3069 layer of this window or others - for fullscreen windows */
3070 if (screen_find_monitor(&self
->frame
->area
) !=
3071 screen_find_monitor(&oldframe
))
3073 client_calc_layer(self
);
3077 void client_fullscreen(ObClient
*self
, gboolean fs
)
3081 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) || /* can't */
3082 self
->fullscreen
== fs
) return; /* already done */
3084 self
->fullscreen
= fs
;
3085 client_change_state(self
); /* change the state hints on the client */
3088 self
->pre_fullscreen_area
= self
->area
;
3089 /* if the window is maximized, its area isn't all that meaningful.
3090 save its premax area instead. */
3091 if (self
->max_horz
) {
3092 self
->pre_fullscreen_area
.x
= self
->pre_max_area
.x
;
3093 self
->pre_fullscreen_area
.width
= self
->pre_max_area
.width
;
3095 if (self
->max_vert
) {
3096 self
->pre_fullscreen_area
.y
= self
->pre_max_area
.y
;
3097 self
->pre_fullscreen_area
.height
= self
->pre_max_area
.height
;
3100 /* these will help configure_full figure out where to fullscreen
3104 w
= self
->area
.width
;
3105 h
= self
->area
.height
;
3107 g_assert(self
->pre_fullscreen_area
.width
> 0 &&
3108 self
->pre_fullscreen_area
.height
> 0);
3110 x
= self
->pre_fullscreen_area
.x
;
3111 y
= self
->pre_fullscreen_area
.y
;
3112 w
= self
->pre_fullscreen_area
.width
;
3113 h
= self
->pre_fullscreen_area
.height
;
3114 RECT_SET(self
->pre_fullscreen_area
, 0, 0, 0, 0);
3117 ob_debug("Window %s going fullscreen (%d)",
3118 self
->title
, self
->fullscreen
);
3120 client_setup_decor_and_functions(self
, FALSE
);
3121 client_move_resize(self
, x
, y
, w
, h
);
3123 /* and adjust our layer/stacking. do this after resizing the window,
3124 and applying decorations, because windows which fill the screen are
3125 considered "fullscreen" and it affects their layer */
3126 client_calc_layer(self
);
3129 /* try focus us when we go into fullscreen mode */
3134 static void client_iconify_recursive(ObClient
*self
,
3135 gboolean iconic
, gboolean curdesk
,
3136 gboolean hide_animation
)
3139 gboolean changed
= FALSE
;
3141 if (self
->iconic
!= iconic
) {
3142 ob_debug("%sconifying window: 0x%lx", (iconic
? "I" : "Uni"),
3146 /* don't let non-normal windows iconify along with their parents
3148 if (client_normal(self
)) {
3149 self
->iconic
= iconic
;
3151 /* update the focus lists.. iconic windows go to the bottom of
3153 focus_order_to_bottom(self
);
3158 self
->iconic
= iconic
;
3160 if (curdesk
&& self
->desktop
!= screen_desktop
&&
3161 self
->desktop
!= DESKTOP_ALL
)
3162 client_set_desktop(self
, screen_desktop
, FALSE
, FALSE
);
3164 /* this puts it after the current focused window */
3165 focus_order_remove(self
);
3166 focus_order_add_new(self
);
3173 client_change_state(self
);
3174 if (config_animate_iconify
&& !hide_animation
)
3175 frame_begin_iconify_animation(self
->frame
, iconic
);
3176 /* do this after starting the animation so it doesn't flash */
3177 client_showhide(self
);
3179 hooks_queue((iconic
? OB_HOOK_WIN_ICONIC
: OB_HOOK_WIN_UNICONIC
),
3183 /* iconify all direct transients, and deiconify all transients
3185 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3186 if (it
->data
!= self
)
3187 if (client_is_direct_child(self
, it
->data
) || !iconic
)
3188 client_iconify_recursive(it
->data
, iconic
, curdesk
,
3192 void client_iconify(ObClient
*self
, gboolean iconic
, gboolean curdesk
,
3193 gboolean hide_animation
)
3195 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
|| !iconic
) {
3196 /* move up the transient chain as far as possible first */
3197 self
= client_search_top_direct_parent(self
);
3198 client_iconify_recursive(self
, iconic
, curdesk
, hide_animation
);
3202 void client_maximize(ObClient
*self
, gboolean max
, gint dir
)
3206 g_assert(dir
== 0 || dir
== 1 || dir
== 2);
3207 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && max
) return;/* can't */
3209 /* check if already done */
3211 if (dir
== 0 && self
->max_horz
&& self
->max_vert
) return;
3212 if (dir
== 1 && self
->max_horz
) return;
3213 if (dir
== 2 && self
->max_vert
) return;
3215 if (dir
== 0 && !self
->max_horz
&& !self
->max_vert
) return;
3216 if (dir
== 1 && !self
->max_horz
) return;
3217 if (dir
== 2 && !self
->max_vert
) return;
3220 /* these will help configure_full figure out which screen to fill with
3224 w
= self
->area
.width
;
3225 h
= self
->area
.height
;
3228 if ((dir
== 0 || dir
== 1) && !self
->max_horz
) { /* horz */
3229 RECT_SET(self
->pre_max_area
,
3230 self
->area
.x
, self
->pre_max_area
.y
,
3231 self
->area
.width
, self
->pre_max_area
.height
);
3233 if ((dir
== 0 || dir
== 2) && !self
->max_vert
) { /* vert */
3234 RECT_SET(self
->pre_max_area
,
3235 self
->pre_max_area
.x
, self
->area
.y
,
3236 self
->pre_max_area
.width
, self
->area
.height
);
3239 if ((dir
== 0 || dir
== 1) && self
->max_horz
) { /* horz */
3240 g_assert(self
->pre_max_area
.width
> 0);
3242 x
= self
->pre_max_area
.x
;
3243 w
= self
->pre_max_area
.width
;
3245 RECT_SET(self
->pre_max_area
, 0, self
->pre_max_area
.y
,
3246 0, self
->pre_max_area
.height
);
3248 if ((dir
== 0 || dir
== 2) && self
->max_vert
) { /* vert */
3249 g_assert(self
->pre_max_area
.height
> 0);
3251 y
= self
->pre_max_area
.y
;
3252 h
= self
->pre_max_area
.height
;
3254 RECT_SET(self
->pre_max_area
, self
->pre_max_area
.x
, 0,
3255 self
->pre_max_area
.width
, 0);
3259 if (dir
== 0 || dir
== 1) /* horz */
3260 self
->max_horz
= max
;
3261 if (dir
== 0 || dir
== 2) /* vert */
3262 self
->max_vert
= max
;
3264 client_change_state(self
); /* change the state hints on the client */
3266 client_setup_decor_and_functions(self
, FALSE
);
3267 client_move_resize(self
, x
, y
, w
, h
);
3269 hooks_queue((max
? OB_HOOK_WIN_MAX
: OB_HOOK_WIN_UNMAX
), self
);
3272 void client_shade(ObClient
*self
, gboolean shade
)
3274 if ((!(self
->functions
& OB_CLIENT_FUNC_SHADE
) &&
3275 shade
) || /* can't shade */
3276 self
->shaded
== shade
) return; /* already done */
3278 self
->shaded
= shade
;
3279 client_change_state(self
);
3280 client_change_wm_state(self
); /* the window is being hidden/shown */
3281 /* resize the frame to just the titlebar */
3282 frame_adjust_area(self
->frame
, FALSE
, TRUE
, FALSE
);
3284 hooks_queue((shade
? OB_HOOK_WIN_SHADE
: OB_HOOK_WIN_UNSHADE
), self
);
3287 static void client_ping_event(ObClient
*self
, gboolean dead
)
3289 if (self
->not_responding
!= dead
) {
3290 self
->not_responding
= dead
;
3291 client_update_title(self
);
3294 /* the client isn't responding, so ask to kill it */
3295 client_prompt_kill(self
);
3297 /* it came back to life ! */
3299 if (self
->kill_prompt
) {
3300 prompt_unref(self
->kill_prompt
);
3301 self
->kill_prompt
= NULL
;
3304 self
->kill_level
= 0;
3309 void client_close(ObClient
*self
)
3311 if (!(self
->functions
& OB_CLIENT_FUNC_CLOSE
)) return;
3313 /* if closing an internal obprompt, that is just cancelling it */
3315 prompt_cancel(self
->prompt
);
3319 /* in the case that the client provides no means to requesting that it
3320 close, we just kill it */
3321 if (!self
->delete_window
)
3322 /* don't use client_kill(), we should only kill based on PID in
3323 response to a lack of PING replies */
3324 XKillClient(obt_display
, self
->window
);
3326 /* request the client to close with WM_DELETE_WINDOW */
3327 OBT_PROP_MSG_TO(self
->window
, self
->window
, WM_PROTOCOLS
,
3328 OBT_PROP_ATOM(WM_DELETE_WINDOW
), event_curtime
,
3329 0, 0, 0, NoEventMask
);
3331 /* we're trying to close the window, so see if it is responding. if it
3332 is not, then we will let them kill the window */
3334 ping_start(self
, client_ping_event
);
3336 /* if we already know the window isn't responding (maybe they clicked
3337 no in the kill dialog but it hasn't come back to life), then show
3339 if (self
->not_responding
)
3340 client_prompt_kill(self
);
3344 #define OB_KILL_RESULT_NO 0
3345 #define OB_KILL_RESULT_YES 1
3347 static gboolean
client_kill_requested(ObPrompt
*p
, gint result
, gpointer data
)
3349 ObClient
*self
= data
;
3351 if (result
== OB_KILL_RESULT_YES
)
3353 return TRUE
; /* call the cleanup func */
3356 static void client_kill_cleanup(ObPrompt
*p
, gpointer data
)
3358 ObClient
*self
= data
;
3360 g_assert(p
== self
->kill_prompt
);
3362 prompt_unref(self
->kill_prompt
);
3363 self
->kill_prompt
= NULL
;
3366 static void client_prompt_kill(ObClient
*self
)
3368 /* check if we're already prompting */
3369 if (!self
->kill_prompt
) {
3370 ObPromptAnswer answers
[] = {
3371 { 0, OB_KILL_RESULT_NO
},
3372 { 0, OB_KILL_RESULT_YES
}
3375 const gchar
*y
, *title
;
3377 title
= self
->original_title
;
3378 if (title
[0] == '\0') {
3379 /* empty string, so use its parent */
3380 ObClient
*p
= client_search_top_direct_parent(self
);
3381 if (p
) title
= p
->original_title
;
3384 if (client_on_localhost(self
)) {
3387 if (self
->kill_level
== 0)
3393 (_("The window \"%s\" does not seem to be responding. Do you want to force it to exit by sending the %s signal?"),
3395 y
= _("End Process");
3399 (_("The window \"%s\" does not seem to be responding. Do you want to disconnect it from the X server?"),
3401 y
= _("Disconnect");
3403 /* set the dialog buttons' text */
3404 answers
[0].text
= _("Cancel"); /* "no" */
3405 answers
[1].text
= y
; /* "yes" */
3407 self
->kill_prompt
= prompt_new(m
, NULL
, answers
,
3408 sizeof(answers
)/sizeof(answers
[0]),
3409 OB_KILL_RESULT_NO
, /* default = no */
3410 OB_KILL_RESULT_NO
, /* cancel = no */
3411 client_kill_requested
,
3412 client_kill_cleanup
,
3417 prompt_show(self
->kill_prompt
, self
, TRUE
);
3420 void client_kill(ObClient
*self
)
3422 /* don't kill our own windows */
3423 if (self
->prompt
) return;
3425 if (client_on_localhost(self
) && self
->pid
) {
3426 /* running on the local host */
3427 if (self
->kill_level
== 0) {
3428 ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
3429 self
->window
, self
->pid
);
3430 kill(self
->pid
, SIGTERM
);
3433 /* show that we're trying to kill it */
3434 client_update_title(self
);
3437 ob_debug("killing window 0x%x with pid %lu, with SIGKILL",
3438 self
->window
, self
->pid
);
3439 kill(self
->pid
, SIGKILL
); /* kill -9 */
3443 /* running on a remote host */
3444 XKillClient(obt_display
, self
->window
);
3448 void client_hilite(ObClient
*self
, gboolean hilite
)
3450 if (self
->demands_attention
== hilite
)
3451 return; /* no change */
3453 /* don't allow focused windows to hilite */
3454 self
->demands_attention
= hilite
&& !client_focused(self
);
3455 if (self
->frame
!= NULL
) { /* if we're mapping, just set the state */
3456 if (self
->demands_attention
)
3457 frame_flash_start(self
->frame
);
3459 frame_flash_stop(self
->frame
);
3460 client_change_state(self
);
3464 static void client_set_desktop_recursive(ObClient
*self
,
3472 if (target
!= self
->desktop
&& self
->type
!= OB_CLIENT_TYPE_DESKTOP
) {
3474 ob_debug("Setting desktop %u", target
+1);
3476 g_assert(target
< screen_num_desktops
|| target
== DESKTOP_ALL
);
3478 old
= self
->desktop
;
3479 self
->desktop
= target
;
3480 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, target
);
3481 /* the frame can display the current desktop state */
3482 frame_adjust_state(self
->frame
);
3483 /* 'move' the window to the new desktop */
3487 /* raise if it was not already on the desktop */
3488 if (old
!= DESKTOP_ALL
&& !dontraise
)
3489 stacking_raise(CLIENT_AS_WINDOW(self
));
3490 if (STRUT_EXISTS(self
->strut
))
3491 screen_update_areas();
3493 /* the new desktop's geometry may be different, so we may need to
3494 resize, for example if we are maximized */
3495 client_reconfigure(self
, FALSE
);
3497 if (old
!= self
->desktop
)
3498 hooks_queue(OB_HOOK_WIN_DESK_CHANGE
, self
);
3501 /* move all transients */
3502 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3503 if (it
->data
!= self
)
3504 if (client_is_direct_child(self
, it
->data
))
3505 client_set_desktop_recursive(it
->data
, target
,
3506 donthide
, dontraise
);
3509 void client_set_desktop(ObClient
*self
, guint target
,
3510 gboolean donthide
, gboolean dontraise
)
3512 self
= client_search_top_direct_parent(self
);
3513 client_set_desktop_recursive(self
, target
, donthide
, dontraise
);
3516 gboolean
client_is_direct_child(ObClient
*parent
, ObClient
*child
)
3518 while (child
!= parent
&& (child
= client_direct_parent(child
)));
3519 return child
== parent
;
3522 ObClient
*client_search_modal_child(ObClient
*self
)
3527 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
3528 ObClient
*c
= it
->data
;
3529 if ((ret
= client_search_modal_child(c
))) return ret
;
3530 if (c
->modal
) return c
;
3535 gboolean
client_validate(ObClient
*self
)
3539 XSync(obt_display
, FALSE
); /* get all events on the server */
3541 if (XCheckTypedWindowEvent(obt_display
, self
->window
, DestroyNotify
, &e
) ||
3542 XCheckTypedWindowEvent(obt_display
, self
->window
, UnmapNotify
, &e
))
3544 XPutBackEvent(obt_display
, &e
);
3551 void client_set_wm_state(ObClient
*self
, glong state
)
3553 if (state
== self
->wmstate
) return; /* no change */
3557 client_iconify(self
, TRUE
, TRUE
, FALSE
);
3560 client_iconify(self
, FALSE
, TRUE
, FALSE
);
3565 void client_set_state(ObClient
*self
, Atom action
, glong data1
, glong data2
)
3567 gboolean shaded
= self
->shaded
;
3568 gboolean fullscreen
= self
->fullscreen
;
3569 gboolean undecorated
= self
->undecorated
;
3570 gboolean max_horz
= self
->max_horz
;
3571 gboolean max_vert
= self
->max_vert
;
3572 gboolean modal
= self
->modal
;
3573 gboolean iconic
= self
->iconic
;
3574 gboolean demands_attention
= self
->demands_attention
;
3575 gboolean above
= self
->above
;
3576 gboolean below
= self
->below
;
3580 if (!(action
== OBT_PROP_ATOM(NET_WM_STATE_ADD
) ||
3581 action
== OBT_PROP_ATOM(NET_WM_STATE_REMOVE
) ||
3582 action
== OBT_PROP_ATOM(NET_WM_STATE_TOGGLE
)))
3583 /* an invalid action was passed to the client message, ignore it */
3586 for (i
= 0; i
< 2; ++i
) {
3587 Atom state
= i
== 0 ? data1
: data2
;
3589 if (!state
) continue;
3591 /* if toggling, then pick whether we're adding or removing */
3592 if (action
== OBT_PROP_ATOM(NET_WM_STATE_TOGGLE
)) {
3593 if (state
== OBT_PROP_ATOM(NET_WM_STATE_MODAL
))
3595 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
))
3596 value
= self
->max_vert
;
3597 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
))
3598 value
= self
->max_horz
;
3599 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SHADED
))
3601 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
))
3602 value
= self
->skip_taskbar
;
3603 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
))
3604 value
= self
->skip_pager
;
3605 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
))
3606 value
= self
->iconic
;
3607 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
))
3609 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_ABOVE
))
3610 value
= self
->above
;
3611 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_BELOW
))
3612 value
= self
->below
;
3613 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
))
3614 value
= self
->demands_attention
;
3615 else if (state
== OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
))
3616 value
= undecorated
;
3617 action
= value
? OBT_PROP_ATOM(NET_WM_STATE_REMOVE
) :
3618 OBT_PROP_ATOM(NET_WM_STATE_ADD
);
3621 value
= action
== OBT_PROP_ATOM(NET_WM_STATE_ADD
);
3622 if (state
== OBT_PROP_ATOM(NET_WM_STATE_MODAL
)) {
3624 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
)) {
3626 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
)) {
3628 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SHADED
)) {
3630 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
)) {
3631 self
->skip_taskbar
= value
;
3632 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
)) {
3633 self
->skip_pager
= value
;
3634 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
)) {
3636 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
)) {
3638 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_ABOVE
)) {
3640 /* only unset below when setting above, otherwise you can't get to
3644 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_BELOW
)) {
3645 /* and vice versa */
3649 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
)){
3650 demands_attention
= value
;
3651 } else if (state
== OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
)) {
3652 undecorated
= value
;
3656 if (max_horz
!= self
->max_horz
|| max_vert
!= self
->max_vert
) {
3657 if (max_horz
!= self
->max_horz
&& max_vert
!= self
->max_vert
) {
3659 if (max_horz
== max_vert
) { /* both going the same way */
3660 client_maximize(self
, max_horz
, 0);
3662 client_maximize(self
, max_horz
, 1);
3663 client_maximize(self
, max_vert
, 2);
3667 if (max_horz
!= self
->max_horz
)
3668 client_maximize(self
, max_horz
, 1);
3670 client_maximize(self
, max_vert
, 2);
3673 /* change fullscreen state before shading, as it will affect if the window
3675 if (fullscreen
!= self
->fullscreen
)
3676 client_fullscreen(self
, fullscreen
);
3677 if (shaded
!= self
->shaded
)
3678 client_shade(self
, shaded
);
3679 if (undecorated
!= self
->undecorated
)
3680 client_set_undecorated(self
, undecorated
);
3681 if (above
!= self
->above
|| below
!= self
->below
) {
3682 self
->above
= above
;
3683 self
->below
= below
;
3684 client_calc_layer(self
);
3687 if (modal
!= self
->modal
) {
3688 self
->modal
= modal
;
3689 /* when a window changes modality, then its stacking order with its
3690 transients needs to change */
3691 stacking_raise(CLIENT_AS_WINDOW(self
));
3693 /* it also may get focused. if something is focused that shouldn't
3694 be focused anymore, then move the focus */
3695 if (focus_client
&& client_focus_target(focus_client
) != focus_client
)
3696 client_focus(focus_client
);
3699 if (iconic
!= self
->iconic
)
3700 client_iconify(self
, iconic
, FALSE
, FALSE
);
3702 if (demands_attention
!= self
->demands_attention
)
3703 client_hilite(self
, demands_attention
);
3705 client_change_state(self
); /* change the hint to reflect these changes */
3708 ObClient
*client_focus_target(ObClient
*self
)
3710 ObClient
*child
= NULL
;
3712 child
= client_search_modal_child(self
);
3713 if (child
) return child
;
3717 gboolean
client_can_focus(ObClient
*self
)
3719 /* choose the correct target */
3720 self
= client_focus_target(self
);
3722 if (!self
->frame
->visible
)
3725 if (!(self
->can_focus
|| self
->focus_notify
))
3731 gboolean
client_focus(ObClient
*self
)
3733 /* we might not focus this window, so if we have modal children which would
3734 be focused instead, bring them to this desktop */
3735 client_bring_modal_windows(self
);
3737 /* choose the correct target */
3738 self
= client_focus_target(self
);
3740 if (!client_can_focus(self
)) {
3741 ob_debug_type(OB_DEBUG_FOCUS
,
3742 "Client %s can't be focused", self
->title
);
3746 ob_debug_type(OB_DEBUG_FOCUS
,
3747 "Focusing client \"%s\" (0x%x) at time %u",
3748 self
->title
, self
->window
, event_curtime
);
3750 /* if using focus_delay, stop the timer now so that focus doesn't
3752 event_halt_focus_delay();
3754 event_cancel_all_key_grabs();
3756 obt_display_ignore_errors(TRUE
);
3758 if (self
->can_focus
) {
3759 /* This can cause a BadMatch error with CurrentTime, or if an app
3760 passed in a bad time for _NET_WM_ACTIVE_WINDOW. */
3761 XSetInputFocus(obt_display
, self
->window
, RevertToPointerRoot
,
3765 if (self
->focus_notify
) {
3767 ce
.xclient
.type
= ClientMessage
;
3768 ce
.xclient
.message_type
= OBT_PROP_ATOM(WM_PROTOCOLS
);
3769 ce
.xclient
.display
= obt_display
;
3770 ce
.xclient
.window
= self
->window
;
3771 ce
.xclient
.format
= 32;
3772 ce
.xclient
.data
.l
[0] = OBT_PROP_ATOM(WM_TAKE_FOCUS
);
3773 ce
.xclient
.data
.l
[1] = event_curtime
;
3774 ce
.xclient
.data
.l
[2] = 0l;
3775 ce
.xclient
.data
.l
[3] = 0l;
3776 ce
.xclient
.data
.l
[4] = 0l;
3777 XSendEvent(obt_display
, self
->window
, FALSE
, NoEventMask
, &ce
);
3780 obt_display_ignore_errors(FALSE
);
3782 ob_debug_type(OB_DEBUG_FOCUS
, "Error focusing? %d",
3783 obt_display_error_occured
);
3784 return !obt_display_error_occured
;
3787 static void client_present(ObClient
*self
, gboolean here
, gboolean raise
,
3790 if (client_normal(self
) && screen_showing_desktop
)
3791 screen_show_desktop(FALSE
, self
);
3793 client_iconify(self
, FALSE
, here
, FALSE
);
3794 if (self
->desktop
!= DESKTOP_ALL
&&
3795 self
->desktop
!= screen_desktop
)
3798 client_set_desktop(self
, screen_desktop
, FALSE
, TRUE
);
3800 screen_set_desktop(self
->desktop
, FALSE
);
3801 } else if (!self
->frame
->visible
)
3802 /* if its not visible for other reasons, then don't mess
3805 if (self
->shaded
&& unshade
)
3806 client_shade(self
, FALSE
);
3808 stacking_raise(CLIENT_AS_WINDOW(self
));
3813 /* this function exists to map to the client_activate message in the ewmh,
3814 the user arg is unused because nobody uses it correctly anyway. */
3815 void client_activate(ObClient
*self
, gboolean here
, gboolean raise
,
3816 gboolean unshade
, gboolean user
)
3818 client_present(self
, here
, raise
, unshade
);
3821 static void client_bring_windows_recursive(ObClient
*self
,
3829 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3830 client_bring_windows_recursive(it
->data
, desktop
,
3831 helpers
, modals
, iconic
);
3833 if (((helpers
&& client_helper(self
)) ||
3834 (modals
&& self
->modal
)) &&
3835 ((self
->desktop
!= desktop
&& self
->desktop
!= DESKTOP_ALL
) ||
3836 (iconic
&& self
->iconic
)))
3838 if (iconic
&& self
->iconic
)
3839 client_iconify(self
, FALSE
, TRUE
, FALSE
);
3841 client_set_desktop(self
, desktop
, FALSE
, FALSE
);
3845 void client_bring_helper_windows(ObClient
*self
)
3847 client_bring_windows_recursive(self
, self
->desktop
, TRUE
, FALSE
, FALSE
);
3850 void client_bring_modal_windows(ObClient
*self
)
3852 client_bring_windows_recursive(self
, self
->desktop
, FALSE
, TRUE
, TRUE
);
3855 gboolean
client_focused(ObClient
*self
)
3857 return self
== focus_client
;
3860 RrImage
* client_icon(ObClient
*self
)
3862 RrImage
*ret
= NULL
;
3865 ret
= self
->icon_set
;
3866 else if (self
->parents
) {
3868 for (it
= self
->parents
; it
&& !ret
; it
= g_slist_next(it
))
3869 ret
= client_icon(it
->data
);
3872 ret
= client_default_icon
;
3876 void client_set_layer(ObClient
*self
, gint layer
)
3880 self
->above
= FALSE
;
3881 } else if (layer
== 0) {
3882 self
->below
= self
->above
= FALSE
;
3884 self
->below
= FALSE
;
3887 client_calc_layer(self
);
3888 client_change_state(self
); /* reflect this in the state hints */
3891 void client_set_undecorated(ObClient
*self
, gboolean undecorated
)
3893 if (self
->undecorated
!= undecorated
&&
3894 /* don't let it undecorate if the function is missing, but let
3896 (self
->functions
& OB_CLIENT_FUNC_UNDECORATE
|| !undecorated
))
3898 self
->undecorated
= undecorated
;
3899 client_setup_decor_and_functions(self
, TRUE
);
3900 client_change_state(self
); /* reflect this in the state hints */
3902 hooks_queue((undecorated
?
3903 OB_HOOK_WIN_UNDECORATED
: OB_HOOK_WIN_DECORATED
), self
);
3907 guint
client_monitor(ObClient
*self
)
3909 return screen_find_monitor(&self
->frame
->area
);
3912 ObClient
*client_direct_parent(ObClient
*self
)
3914 if (!self
->parents
) return NULL
;
3915 if (self
->transient_for_group
) return NULL
;
3916 return self
->parents
->data
;
3919 ObClient
*client_search_top_direct_parent(ObClient
*self
)
3922 while ((p
= client_direct_parent(self
))) self
= p
;
3926 static GSList
*client_search_all_top_parents_internal(ObClient
*self
,
3928 ObStackingLayer layer
)
3933 /* move up the direct transient chain as far as possible */
3934 while ((p
= client_direct_parent(self
)) &&
3935 (!bylayer
|| p
->layer
== layer
))
3939 ret
= g_slist_prepend(NULL
, self
);
3941 ret
= g_slist_copy(self
->parents
);
3946 GSList
*client_search_all_top_parents(ObClient
*self
)
3948 return client_search_all_top_parents_internal(self
, FALSE
, 0);
3951 GSList
*client_search_all_top_parents_layer(ObClient
*self
)
3953 return client_search_all_top_parents_internal(self
, TRUE
, self
->layer
);
3956 ObClient
*client_search_focus_parent(ObClient
*self
)
3960 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
3961 if (client_focused(it
->data
)) return it
->data
;
3966 ObClient
*client_search_focus_parent_full(ObClient
*self
)
3969 ObClient
*ret
= NULL
;
3971 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
3972 if (client_focused(it
->data
))
3975 ret
= client_search_focus_parent_full(it
->data
);
3981 ObClient
*client_search_parent(ObClient
*self
, ObClient
*search
)
3985 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
3986 if (it
->data
== search
) return search
;
3991 ObClient
*client_search_transient(ObClient
*self
, ObClient
*search
)
3995 for (sit
= self
->transients
; sit
; sit
= g_slist_next(sit
)) {
3996 if (sit
->data
== search
)
3998 if (client_search_transient(sit
->data
, search
))
4004 static void detect_edge(Rect area
, ObDirection dir
,
4005 gint my_head
, gint my_size
,
4006 gint my_edge_start
, gint my_edge_size
,
4007 gint
*dest
, gboolean
*near_edge
)
4009 gint edge_start
, edge_size
, head
, tail
;
4010 gboolean skip_head
= FALSE
, skip_tail
= FALSE
;
4013 case OB_DIRECTION_NORTH
:
4014 case OB_DIRECTION_SOUTH
:
4015 edge_start
= area
.x
;
4016 edge_size
= area
.width
;
4018 case OB_DIRECTION_EAST
:
4019 case OB_DIRECTION_WEST
:
4020 edge_start
= area
.y
;
4021 edge_size
= area
.height
;
4024 g_assert_not_reached();
4027 /* do we collide with this window? */
4028 if (!RANGES_INTERSECT(my_edge_start
, my_edge_size
,
4029 edge_start
, edge_size
))
4033 case OB_DIRECTION_NORTH
:
4034 head
= RECT_BOTTOM(area
);
4035 tail
= RECT_TOP(area
);
4037 case OB_DIRECTION_SOUTH
:
4038 head
= RECT_TOP(area
);
4039 tail
= RECT_BOTTOM(area
);
4041 case OB_DIRECTION_WEST
:
4042 head
= RECT_RIGHT(area
);
4043 tail
= RECT_LEFT(area
);
4045 case OB_DIRECTION_EAST
:
4046 head
= RECT_LEFT(area
);
4047 tail
= RECT_RIGHT(area
);
4050 g_assert_not_reached();
4053 case OB_DIRECTION_NORTH
:
4054 case OB_DIRECTION_WEST
:
4055 /* check if our window is past the head of this window */
4056 if (my_head
<= head
+ 1)
4058 /* check if our window's tail is past the tail of this window */
4059 if (my_head
+ my_size
- 1 <= tail
)
4061 /* check if the head of this window is closer than the previously
4062 chosen edge (take into account that the previously chosen
4063 edge might have been a tail, not a head) */
4064 if (head
+ (*near_edge
? 0 : my_size
) <= *dest
)
4066 /* check if the tail of this window is closer than the previously
4067 chosen edge (take into account that the previously chosen
4068 edge might have been a head, not a tail) */
4069 if (tail
- (!*near_edge
? 0 : my_size
) <= *dest
)
4072 case OB_DIRECTION_SOUTH
:
4073 case OB_DIRECTION_EAST
:
4074 /* check if our window is past the head of this window */
4075 if (my_head
>= head
- 1)
4077 /* check if our window's tail is past the tail of this window */
4078 if (my_head
- my_size
+ 1 >= tail
)
4080 /* check if the head of this window is closer than the previously
4081 chosen edge (take into account that the previously chosen
4082 edge might have been a tail, not a head) */
4083 if (head
- (*near_edge
? 0 : my_size
) >= *dest
)
4085 /* check if the tail of this window is closer than the previously
4086 chosen edge (take into account that the previously chosen
4087 edge might have been a head, not a tail) */
4088 if (tail
+ (!*near_edge
? 0 : my_size
) >= *dest
)
4092 g_assert_not_reached();
4095 ob_debug("my head %d size %d", my_head
, my_size
);
4096 ob_debug("head %d tail %d dest %d", head
, tail
, *dest
);
4098 ob_debug("using near edge %d", head
);
4102 else if (!skip_tail
) {
4103 ob_debug("using far edge %d", tail
);
4109 void client_find_edge_directional(ObClient
*self
, ObDirection dir
,
4110 gint my_head
, gint my_size
,
4111 gint my_edge_start
, gint my_edge_size
,
4112 gint
*dest
, gboolean
*near_edge
)
4119 a
= screen_area(self
->desktop
, SCREEN_AREA_ALL_MONITORS
,
4120 &self
->frame
->area
);
4121 mon
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
,
4122 &self
->frame
->area
);
4125 case OB_DIRECTION_NORTH
:
4126 if (my_head
>= RECT_TOP(*mon
) + 1)
4127 edge
= RECT_TOP(*mon
) - 1;
4129 edge
= RECT_TOP(*a
) - 1;
4131 case OB_DIRECTION_SOUTH
:
4132 if (my_head
<= RECT_BOTTOM(*mon
) - 1)
4133 edge
= RECT_BOTTOM(*mon
) + 1;
4135 edge
= RECT_BOTTOM(*a
) + 1;
4137 case OB_DIRECTION_EAST
:
4138 if (my_head
<= RECT_RIGHT(*mon
) - 1)
4139 edge
= RECT_RIGHT(*mon
) + 1;
4141 edge
= RECT_RIGHT(*a
) + 1;
4143 case OB_DIRECTION_WEST
:
4144 if (my_head
>= RECT_LEFT(*mon
) + 1)
4145 edge
= RECT_LEFT(*mon
) - 1;
4147 edge
= RECT_LEFT(*a
) - 1;
4150 g_assert_not_reached();
4152 /* default to the far edge, then narrow it down */
4156 for (it
= client_list
; it
; it
= g_list_next(it
)) {
4157 ObClient
*cur
= it
->data
;
4159 /* skip windows to not bump into */
4164 if (self
->desktop
!= cur
->desktop
&& cur
->desktop
!= DESKTOP_ALL
&&
4165 cur
->desktop
!= screen_desktop
)
4168 ob_debug("trying window %s", cur
->title
);
4170 detect_edge(cur
->frame
->area
, dir
, my_head
, my_size
, my_edge_start
,
4171 my_edge_size
, dest
, near_edge
);
4173 dock_get_area(&dock_area
);
4174 detect_edge(dock_area
, dir
, my_head
, my_size
, my_edge_start
,
4175 my_edge_size
, dest
, near_edge
);
4180 void client_find_move_directional(ObClient
*self
, ObDirection dir
,
4184 gint e
, e_start
, e_size
;
4188 case OB_DIRECTION_EAST
:
4189 head
= RECT_RIGHT(self
->frame
->area
);
4190 size
= self
->frame
->area
.width
;
4191 e_start
= RECT_TOP(self
->frame
->area
);
4192 e_size
= self
->frame
->area
.height
;
4194 case OB_DIRECTION_WEST
:
4195 head
= RECT_LEFT(self
->frame
->area
);
4196 size
= self
->frame
->area
.width
;
4197 e_start
= RECT_TOP(self
->frame
->area
);
4198 e_size
= self
->frame
->area
.height
;
4200 case OB_DIRECTION_NORTH
:
4201 head
= RECT_TOP(self
->frame
->area
);
4202 size
= self
->frame
->area
.height
;
4203 e_start
= RECT_LEFT(self
->frame
->area
);
4204 e_size
= self
->frame
->area
.width
;
4206 case OB_DIRECTION_SOUTH
:
4207 head
= RECT_BOTTOM(self
->frame
->area
);
4208 size
= self
->frame
->area
.height
;
4209 e_start
= RECT_LEFT(self
->frame
->area
);
4210 e_size
= self
->frame
->area
.width
;
4213 g_assert_not_reached();
4216 client_find_edge_directional(self
, dir
, head
, size
,
4217 e_start
, e_size
, &e
, &near
);
4218 *x
= self
->frame
->area
.x
;
4219 *y
= self
->frame
->area
.y
;
4221 case OB_DIRECTION_EAST
:
4222 if (near
) e
-= self
->frame
->area
.width
;
4226 case OB_DIRECTION_WEST
:
4228 else e
-= self
->frame
->area
.width
;
4231 case OB_DIRECTION_NORTH
:
4233 else e
-= self
->frame
->area
.height
;
4236 case OB_DIRECTION_SOUTH
:
4237 if (near
) e
-= self
->frame
->area
.height
;
4242 g_assert_not_reached();
4244 frame_frame_gravity(self
->frame
, x
, y
);
4247 void client_find_resize_directional(ObClient
*self
, ObDirection side
,
4249 gint
*x
, gint
*y
, gint
*w
, gint
*h
)
4252 gint e
, e_start
, e_size
, delta
;
4257 case OB_DIRECTION_EAST
:
4258 head
= RECT_RIGHT(self
->frame
->area
) +
4259 (self
->size_inc
.width
- 1) * (grow
? 1 : 0);
4260 e_start
= RECT_TOP(self
->frame
->area
);
4261 e_size
= self
->frame
->area
.height
;
4262 dir
= grow
? OB_DIRECTION_EAST
: OB_DIRECTION_WEST
;
4264 case OB_DIRECTION_WEST
:
4265 head
= RECT_LEFT(self
->frame
->area
) -
4266 (self
->size_inc
.width
- 1) * (grow
? 1 : 0);
4267 e_start
= RECT_TOP(self
->frame
->area
);
4268 e_size
= self
->frame
->area
.height
;
4269 dir
= grow
? OB_DIRECTION_WEST
: OB_DIRECTION_EAST
;
4271 case OB_DIRECTION_NORTH
:
4272 head
= RECT_TOP(self
->frame
->area
) -
4273 (self
->size_inc
.height
- 1) * (grow
? 1 : 0);
4274 e_start
= RECT_LEFT(self
->frame
->area
);
4275 e_size
= self
->frame
->area
.width
;
4276 dir
= grow
? OB_DIRECTION_NORTH
: OB_DIRECTION_SOUTH
;
4278 case OB_DIRECTION_SOUTH
:
4279 head
= RECT_BOTTOM(self
->frame
->area
) +
4280 (self
->size_inc
.height
- 1) * (grow
? 1 : 0);
4281 e_start
= RECT_LEFT(self
->frame
->area
);
4282 e_size
= self
->frame
->area
.width
;
4283 dir
= grow
? OB_DIRECTION_SOUTH
: OB_DIRECTION_NORTH
;
4286 g_assert_not_reached();
4289 ob_debug("head %d dir %d", head
, dir
);
4290 client_find_edge_directional(self
, dir
, head
, 1,
4291 e_start
, e_size
, &e
, &near
);
4292 ob_debug("edge %d", e
);
4293 *x
= self
->frame
->area
.x
;
4294 *y
= self
->frame
->area
.y
;
4295 *w
= self
->frame
->area
.width
;
4296 *h
= self
->frame
->area
.height
;
4298 case OB_DIRECTION_EAST
:
4299 if (grow
== near
) --e
;
4300 delta
= e
- RECT_RIGHT(self
->frame
->area
);
4303 case OB_DIRECTION_WEST
:
4304 if (grow
== near
) ++e
;
4305 delta
= RECT_LEFT(self
->frame
->area
) - e
;
4309 case OB_DIRECTION_NORTH
:
4310 if (grow
== near
) ++e
;
4311 delta
= RECT_TOP(self
->frame
->area
) - e
;
4315 case OB_DIRECTION_SOUTH
:
4316 if (grow
== near
) --e
;
4317 delta
= e
- RECT_BOTTOM(self
->frame
->area
);
4321 g_assert_not_reached();
4323 frame_frame_gravity(self
->frame
, x
, y
);
4324 *w
-= self
->frame
->size
.left
+ self
->frame
->size
.right
;
4325 *h
-= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
4328 ObClient
* client_under_pointer(void)
4332 ObClient
*ret
= NULL
;
4334 if (screen_pointer_pos(&x
, &y
)) {
4335 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
4336 if (WINDOW_IS_CLIENT(it
->data
)) {
4337 ObClient
*c
= WINDOW_AS_CLIENT(it
->data
);
4338 if (c
->frame
->visible
&&
4339 /* check the desktop, this is done during desktop
4340 switching and windows are shown/hidden status is not
4342 (c
->desktop
== screen_desktop
||
4343 c
->desktop
== DESKTOP_ALL
) &&
4344 /* ignore all animating windows */
4345 !frame_iconify_animating(c
->frame
) &&
4346 RECT_CONTAINS(c
->frame
->area
, x
, y
))
4357 gboolean
client_has_group_siblings(ObClient
*self
)
4359 return self
->group
&& self
->group
->members
->next
;
4362 /*! Returns TRUE if the client is running on the same machine as Openbox */
4363 gboolean
client_on_localhost(ObClient
*self
)
4365 return self
->client_machine
== NULL
;