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"
38 #include "menuframe.h"
41 #include "render/render.h"
43 #include "obt/display.h"
51 # include <signal.h> /* for kill() */
55 #include <X11/Xutil.h>
57 /*! The event mask to grab on client windows */
58 #define CLIENT_EVENTMASK (PropertyChangeMask | StructureNotifyMask | \
61 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
66 ObClientCallback func
;
70 GList
*client_list
= NULL
;
72 static GSList
*client_destroy_notifies
= NULL
;
73 static RrImage
*client_default_icon
= NULL
;
75 static void client_get_all(ObClient
*self
, gboolean real
);
76 static void client_get_startup_id(ObClient
*self
);
77 static void client_get_session_ids(ObClient
*self
);
78 static void client_save_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_colormap(ObClient
*self
);
84 static void client_set_desktop_recursive(ObClient
*self
,
88 static void client_change_allowed_actions(ObClient
*self
);
89 static void client_change_state(ObClient
*self
);
90 static void client_change_wm_state(ObClient
*self
);
91 static void client_apply_startup_state(ObClient
*self
,
92 gint x
, gint y
, gint w
, gint h
);
93 static void client_restore_session_state(ObClient
*self
);
94 static gboolean
client_restore_session_stacking(ObClient
*self
);
95 static ObAppSettings
*client_get_settings_state(ObClient
*self
);
96 static void client_update_transient_tree(ObClient
*self
,
97 ObGroup
*oldgroup
, ObGroup
*newgroup
,
98 gboolean oldgtran
, gboolean newgtran
,
100 ObClient
*newparent
);
101 static void client_present(ObClient
*self
, gboolean here
, gboolean raise
,
103 static GSList
*client_search_all_top_parents_internal(ObClient
*self
,
105 ObStackingLayer layer
);
106 static void client_call_notifies(ObClient
*self
, GSList
*list
);
107 static void client_ping_event(ObClient
*self
, gboolean dead
);
108 static void client_prompt_kill(ObClient
*self
);
109 static gboolean
client_can_steal_focus(ObClient
*self
, Time steal_time
,
112 void client_startup(gboolean reconfig
)
114 if ((client_default_icon
= RrImageCacheFind(ob_rr_icons
,
115 ob_rr_theme
->def_win_icon
,
116 ob_rr_theme
->def_win_icon_w
,
117 ob_rr_theme
->def_win_icon_h
)))
118 RrImageRef(client_default_icon
);
120 client_default_icon
= RrImageNew(ob_rr_icons
);
121 RrImageAddPicture(client_default_icon
,
122 ob_rr_theme
->def_win_icon
,
123 ob_rr_theme
->def_win_icon_w
,
124 ob_rr_theme
->def_win_icon_h
);
127 if (reconfig
) return;
132 void client_shutdown(gboolean reconfig
)
134 RrImageUnref(client_default_icon
);
135 client_default_icon
= NULL
;
137 if (reconfig
) return;
140 static void client_call_notifies(ObClient
*self
, GSList
*list
)
144 for (it
= list
; it
; it
= g_slist_next(it
)) {
145 ClientCallback
*d
= it
->data
;
146 d
->func(self
, d
->data
);
150 void client_add_destroy_notify(ObClientCallback func
, gpointer data
)
152 ClientCallback
*d
= g_new(ClientCallback
, 1);
155 client_destroy_notifies
= g_slist_prepend(client_destroy_notifies
, d
);
158 void client_remove_destroy_notify(ObClientCallback func
)
162 for (it
= client_destroy_notifies
; it
; it
= g_slist_next(it
)) {
163 ClientCallback
*d
= it
->data
;
164 if (d
->func
== func
) {
166 client_destroy_notifies
=
167 g_slist_delete_link(client_destroy_notifies
, it
);
173 void client_set_list(void)
175 Window
*windows
, *win_it
;
177 guint size
= g_list_length(client_list
);
179 /* create an array of the window ids */
181 windows
= g_new(Window
, size
);
183 for (it
= client_list
; it
; it
= g_list_next(it
), ++win_it
)
184 *win_it
= ((ObClient
*)it
->data
)->window
;
188 OBT_PROP_SETA32(obt_root(ob_screen
), NET_CLIENT_LIST
, WINDOW
,
189 (gulong
*)windows
, size
);
197 void client_manage(Window window
, ObPrompt
*prompt
)
200 XSetWindowAttributes attrib_set
;
201 gboolean activate
= FALSE
;
202 ObAppSettings
*settings
;
203 gboolean transient
= FALSE
;
204 Rect place
, *monitor
;
205 Time launch_time
, map_time
;
208 ob_debug("Managing window: 0x%lx", window
);
210 map_time
= event_get_server_time();
212 /* choose the events we want to receive on the CLIENT window
213 (ObPrompt windows can request events too) */
214 attrib_set
.event_mask
= CLIENT_EVENTMASK
|
215 (prompt
? prompt
->event_mask
: 0);
216 attrib_set
.do_not_propagate_mask
= CLIENT_NOPROPAGATEMASK
;
217 XChangeWindowAttributes(obt_display
, window
,
218 CWEventMask
|CWDontPropagate
, &attrib_set
);
220 /* create the ObClient struct, and populate it from the hints on the
222 self
= g_new0(ObClient
, 1);
223 self
->obwin
.type
= OB_WINDOW_CLASS_CLIENT
;
224 self
->window
= window
;
225 self
->prompt
= prompt
;
227 /* non-zero defaults */
228 self
->wmstate
= WithdrawnState
; /* make sure it gets updated first time */
229 self
->gravity
= NorthWestGravity
;
230 self
->desktop
= screen_num_desktops
; /* always an invalid value */
232 /* get all the stuff off the window */
233 client_get_all(self
, TRUE
);
235 ob_debug("Window type: %d", self
->type
);
236 ob_debug("Window group: 0x%x", self
->group
?self
->group
->leader
:0);
237 ob_debug("Window name: %s class: %s role: %s", self
->name
, self
->class, self
->role
);
239 /* per-app settings override stuff from client_get_all, and return the
240 settings for other uses too. the returned settings is a shallow copy,
241 that needs to be freed with g_free(). */
242 settings
= client_get_settings_state(self
);
244 /* now we have all of the window's information so we can set this up.
245 do this before creating the frame, so it can tell that we are still
246 mapping and doesn't go applying things right away */
247 client_setup_decor_and_functions(self
, FALSE
);
249 /* specify that if we exit, the window should not be destroyed and
250 should be reparented back to root automatically, unless we are managing
251 an internal ObPrompt window */
253 XChangeSaveSet(obt_display
, window
, SetModeInsert
);
255 /* create the decoration frame for the client window */
256 self
->frame
= frame_new(self
);
258 frame_grab_client(self
->frame
);
260 /* we've grabbed everything and set everything that we need to at mapping
264 /* the session should get the last say though */
265 client_restore_session_state(self
);
267 /* tell startup notification that this app started */
268 launch_time
= sn_app_started(self
->startup_id
, self
->class, self
->name
);
270 if (!OBT_PROP_GET32(self
->window
, NET_WM_USER_TIME
, CARDINAL
, &user_time
))
271 user_time
= map_time
;
273 /* do this after we have a frame.. it uses the frame to help determine the
274 WM_STATE to apply. */
275 client_change_state(self
);
277 /* add ourselves to the focus order */
278 focus_order_add_new(self
);
280 /* do this to add ourselves to the stacking list in a non-intrusive way */
281 client_calc_layer(self
);
283 /* focus the new window? */
284 if (ob_state() != OB_STATE_STARTING
&&
285 (!self
->session
|| self
->session
->focused
) &&
286 /* this means focus=true for window is same as config_focus_new=true */
287 ((config_focus_new
|| (settings
&& settings
->focus
== 1)) ||
288 client_search_focus_tree_full(self
)) &&
289 /* NET_WM_USER_TIME 0 when mapping means don't focus */
291 /* this checks for focus=false for the window */
292 (!settings
|| settings
->focus
!= 0) &&
293 focus_valid_target(self
, FALSE
, FALSE
, TRUE
, FALSE
, FALSE
,
294 settings
->focus
== 1))
299 /* remove the client's border */
300 XSetWindowBorderWidth(obt_display
, self
->window
, 0);
302 /* adjust the frame to the client's size before showing or placing
304 frame_adjust_area(self
->frame
, FALSE
, TRUE
, FALSE
);
305 frame_adjust_client_area(self
->frame
);
307 /* where the frame was placed is where the window was originally */
309 monitor
= screen_physical_area_monitor(screen_find_monitor(&place
));
311 /* figure out placement for the window if the window is new */
312 if (ob_state() == OB_STATE_RUNNING
) {
313 ob_debug("Positioned: %s @ %d %d",
314 (!self
->positioned
? "no" :
315 (self
->positioned
== PPosition
? "program specified" :
316 (self
->positioned
== USPosition
? "user specified" :
317 (self
->positioned
== (PPosition
| USPosition
) ?
318 "program + user specified" :
319 "BADNESS !?")))), place
.x
, place
.y
);
321 ob_debug("Sized: %s @ %d %d",
322 (!self
->sized
? "no" :
323 (self
->sized
== PSize
? "program specified" :
324 (self
->sized
== USSize
? "user specified" :
325 (self
->sized
== (PSize
| USSize
) ?
326 "program + user specified" :
327 "BADNESS !?")))), place
.width
, place
.height
);
329 /* splash screens are also returned as TRUE for transient,
330 and so will be forced on screen below */
331 transient
= place_client(self
, &place
.x
, &place
.y
, settings
);
333 /* make sure the window is visible. */
334 client_find_onscreen(self
, &place
.x
, &place
.y
,
335 place
.width
, place
.height
,
336 /* non-normal clients has less rules, and
337 windows that are being restored from a
338 session do also. we can assume you want
339 it back where you saved it. Clients saying
340 they placed themselves are subjected to
341 harder rules, ones that are placed by
342 place.c or by the user are allowed partially
343 off-screen and on xinerama divides (ie,
344 it is up to the placement routines to avoid
345 the xinerama divides)
347 splash screens get "transient" set to TRUE by
348 the place_client call
350 ob_state() == OB_STATE_RUNNING
&&
352 (!((self
->positioned
& USPosition
) ||
353 (settings
&& settings
->pos_given
)) &&
354 client_normal(self
) &&
356 /* don't move oldschool fullscreen windows to
357 fit inside the struts (fixes Acroread, which
358 makes its fullscreen window fit the screen
359 but it is not USSize'd or USPosition'd) */
360 !(self
->decorations
== 0 &&
361 RECT_EQUAL(place
, *monitor
)))));
364 /* if the window isn't user-sized, then make it fit inside
365 the visible screen area on its monitor. Use basically the same rules
366 for forcing the window on screen in the client_find_onscreen call.
368 do this after place_client, it chooses the monitor!
370 splash screens get "transient" set to TRUE by
371 the place_client call
373 if (ob_state() == OB_STATE_RUNNING
&&
375 (!(self
->sized
& USSize
|| self
->positioned
& USPosition
) &&
376 client_normal(self
) &&
378 /* don't shrink oldschool fullscreen windows to fit inside the
379 struts (fixes Acroread, which makes its fullscreen window
380 fit the screen but it is not USSize'd or USPosition'd) */
381 !(self
->decorations
== 0 && RECT_EQUAL(place
, *monitor
)))))
383 Rect
*a
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
, &place
);
385 /* get the size of the frame */
386 place
.width
+= self
->frame
->size
.left
+ self
->frame
->size
.right
;
387 place
.height
+= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
389 /* fit the window inside the area */
390 place
.width
= MIN(place
.width
, a
->width
);
391 place
.height
= MIN(place
.height
, a
->height
);
393 ob_debug("setting window size to %dx%d", place
.width
, place
.height
);
395 /* get the size of the client back */
396 place
.width
-= self
->frame
->size
.left
+ self
->frame
->size
.right
;
397 place
.height
-= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
402 ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
403 "some restrictions may apply",
404 self
->window
, place
.x
, place
.y
, place
.width
, place
.height
);
406 ob_debug(" but session requested %d, %d %d x %d instead, "
408 self
->session
->x
, self
->session
->y
,
409 self
->session
->w
, self
->session
->h
);
411 /* do this after the window is placed, so the premax/prefullscreen numbers
414 this also places the window
416 client_apply_startup_state(self
, place
.x
, place
.y
,
417 place
.width
, place
.height
);
422 ob_debug_type(OB_DEBUG_FOCUS
, "Going to try activate new window? %s",
423 activate
? "yes" : "no");
425 activate
= client_can_steal_focus(self
, map_time
, launch_time
);
428 /* if the client isn't stealing focus, then hilite it so the user
429 knows it is there, but don't do this if we're restoring from a
431 if (!client_restore_session_stacking(self
))
432 client_hilite(self
, TRUE
);
436 /* This may look rather odd. Well it's because new windows are added
437 to the stacking order non-intrusively. If we're not going to focus
438 the new window or hilite it, then we raise it to the top. This will
439 take affect for things that don't get focused like splash screens.
440 Also if you don't have focus_new enabled, then it's going to get
441 raised to the top. Legacy begets legacy I guess?
443 if (!client_restore_session_stacking(self
))
444 stacking_raise(CLIENT_AS_WINDOW(self
));
447 mouse_grab_for_client(self
, TRUE
);
449 /* this has to happen before we try focus the window, but we want it to
450 happen after the client's stacking has been determined or it looks bad
454 if (!config_focus_under_mouse
)
455 ignore_start
= event_start_ignore_all_enters();
459 if (!config_focus_under_mouse
)
460 event_end_ignore_all_enters(ignore_start
);
464 gboolean stacked
= client_restore_session_stacking(self
);
465 client_present(self
, FALSE
, !stacked
, TRUE
);
468 /* add to client list/map */
469 client_list
= g_list_append(client_list
, self
);
470 window_add(&self
->window
, CLIENT_AS_WINDOW(self
));
472 /* this has to happen after we're in the client_list */
473 if (STRUT_EXISTS(self
->strut
))
474 screen_update_areas();
476 /* update the list hints */
479 /* free the ObAppSettings shallow copy */
482 ob_debug("Managed window 0x%lx plate 0x%x (%s)",
483 window
, self
->frame
->window
, self
->class);
486 ObClient
*client_fake_manage(Window window
)
489 ObAppSettings
*settings
;
491 ob_debug("Pretend-managing window: %lx", window
);
493 /* do this minimal stuff to figure out the client's decorations */
495 self
= g_new0(ObClient
, 1);
496 self
->window
= window
;
498 client_get_all(self
, FALSE
);
499 /* per-app settings override stuff, and return the settings for other
500 uses too. this returns a shallow copy that needs to be freed */
501 settings
= client_get_settings_state(self
);
503 client_setup_decor_and_functions(self
, FALSE
);
505 /* create the decoration frame for the client window and adjust its size */
506 self
->frame
= frame_new(self
);
507 frame_adjust_area(self
->frame
, FALSE
, TRUE
, TRUE
);
509 ob_debug("gave extents left %d right %d top %d bottom %d",
510 self
->frame
->size
.left
, self
->frame
->size
.right
,
511 self
->frame
->size
.top
, self
->frame
->size
.bottom
);
513 /* free the ObAppSettings shallow copy */
519 void client_unmanage_all(void)
522 client_unmanage(client_list
->data
);
525 void client_unmanage(ObClient
*self
)
530 ob_debug("Unmanaging window: 0x%x plate 0x%x (%s) (%s)",
531 self
->window
, self
->frame
->window
,
532 self
->class, self
->title
? self
->title
: "");
534 g_assert(self
!= NULL
);
536 /* we dont want events no more. do this before hiding the frame so we
537 don't generate more events */
538 XSelectInput(obt_display
, self
->window
, NoEventMask
);
540 /* ignore enter events from the unmap so it doesnt mess with the focus */
541 if (!config_focus_under_mouse
)
542 ignore_start
= event_start_ignore_all_enters();
544 frame_hide(self
->frame
);
545 /* flush to send the hide to the server quickly */
548 if (!config_focus_under_mouse
)
549 event_end_ignore_all_enters(ignore_start
);
551 mouse_grab_for_client(self
, FALSE
);
553 /* remove the window from our save set, unless we are managing an internal
556 XChangeSaveSet(obt_display
, self
->window
, SetModeDelete
);
558 /* update the focus lists */
559 focus_order_remove(self
);
560 if (client_focused(self
)) {
561 /* don't leave an invalid focus_client */
565 /* if we're prompting to kill the client, close that */
566 prompt_unref(self
->kill_prompt
);
567 self
->kill_prompt
= NULL
;
569 client_list
= g_list_remove(client_list
, self
);
570 stacking_remove(self
);
571 window_remove(self
->window
);
573 /* once the client is out of the list, update the struts to remove its
575 if (STRUT_EXISTS(self
->strut
))
576 screen_update_areas();
578 client_call_notifies(self
, client_destroy_notifies
);
580 /* tell our parent(s) that we're gone */
581 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
582 ((ObClient
*)it
->data
)->transients
=
583 g_slist_remove(((ObClient
*)it
->data
)->transients
,self
);
585 /* tell our transients that we're gone */
586 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
587 ((ObClient
*)it
->data
)->parents
=
588 g_slist_remove(((ObClient
*)it
->data
)->parents
, self
);
589 /* we could be keeping our children in a higher layer */
590 client_calc_layer(it
->data
);
593 /* remove from its group */
595 group_remove(self
->group
, self
);
599 /* restore the window's original geometry so it is not lost */
605 if (self
->fullscreen
)
606 a
= self
->pre_fullscreen_area
;
607 else if (self
->max_horz
|| self
->max_vert
) {
608 if (self
->max_horz
) {
609 a
.x
= self
->pre_max_area
.x
;
610 a
.width
= self
->pre_max_area
.width
;
612 if (self
->max_vert
) {
613 a
.y
= self
->pre_max_area
.y
;
614 a
.height
= self
->pre_max_area
.height
;
618 self
->fullscreen
= self
->max_horz
= self
->max_vert
= FALSE
;
619 /* let it be moved and resized no matter what */
620 self
->functions
= OB_CLIENT_FUNC_MOVE
| OB_CLIENT_FUNC_RESIZE
;
621 self
->decorations
= 0; /* unmanaged windows have no decor */
623 /* give the client its border back */
624 XSetWindowBorderWidth(obt_display
, self
->window
, self
->border_width
);
626 client_move_resize(self
, a
.x
, a
.y
, a
.width
, a
.height
);
629 /* reparent the window out of the frame, and free the frame */
630 frame_release_client(self
->frame
);
631 frame_free(self
->frame
);
634 if (ob_state() != OB_STATE_EXITING
) {
635 /* these values should not be persisted across a window
637 OBT_PROP_ERASE(self
->window
, NET_WM_DESKTOP
);
638 OBT_PROP_ERASE(self
->window
, NET_WM_STATE
);
639 OBT_PROP_ERASE(self
->window
, WM_STATE
);
641 /* if we're left in an unmapped state, the client wont be mapped.
642 this is bad, since we will no longer be managing the window on
644 XMapWindow(obt_display
, self
->window
);
647 /* these should not be left on the window ever. other window managers
648 don't necessarily use them and it will mess them up (like compiz) */
649 OBT_PROP_ERASE(self
->window
, NET_WM_VISIBLE_NAME
);
650 OBT_PROP_ERASE(self
->window
, NET_WM_VISIBLE_ICON_NAME
);
652 /* update the list hints */
655 ob_debug("Unmanaged window 0x%lx", self
->window
);
657 /* free all data allocated in the client struct */
658 RrImageUnref(self
->icon_set
);
659 g_slist_free(self
->transients
);
660 g_free(self
->startup_id
);
661 g_free(self
->wm_command
);
663 g_free(self
->icon_title
);
664 g_free(self
->original_title
);
668 g_free(self
->client_machine
);
669 g_free(self
->sm_client_id
);
673 void client_fake_unmanage(ObClient
*self
)
675 /* this is all that got allocated to get the decorations */
677 frame_free(self
->frame
);
681 static gboolean
client_can_steal_focus(ObClient
*self
, Time steal_time
,
685 gboolean relative_focused
;
686 gboolean parent_focused
;
690 parent_focused
= (focus_client
!= NULL
&&
691 client_search_focus_parent(self
));
692 relative_focused
= (focus_client
!= NULL
&&
693 (client_search_focus_tree_full(self
) != NULL
||
694 client_search_focus_group_full(self
) != NULL
));
696 /* This is focus stealing prevention */
697 ob_debug_type(OB_DEBUG_FOCUS
,
698 "Want to focus new window 0x%x at time %u "
699 "launched at %u (last user interaction time %u)",
700 self
->window
, steal_time
, launch_time
,
701 event_last_user_time
);
703 /* if it's on another desktop */
704 if (!(self
->desktop
== screen_desktop
||
705 self
->desktop
== DESKTOP_ALL
) &&
706 /* the timestamp is from before you changed desktops */
707 launch_time
&& screen_desktop_user_time
&&
708 !event_time_after(launch_time
, screen_desktop_user_time
))
711 ob_debug_type(OB_DEBUG_FOCUS
,
712 "Not focusing the window because its on another "
715 /* If something is focused... */
716 else if (focus_client
) {
717 /* If the user is working in another window right now, then don't
719 if (!parent_focused
&&
720 event_last_user_time
&& launch_time
&&
721 event_time_after(event_last_user_time
, launch_time
) &&
722 event_last_user_time
!= launch_time
&&
723 event_time_after(event_last_user_time
,
724 steal_time
- OB_EVENT_USER_TIME_DELAY
))
727 ob_debug_type(OB_DEBUG_FOCUS
,
728 "Not focusing the window because the user is "
729 "working in another window that is not "
732 /* If the new window is a transient (and its relatives aren't
734 else if (client_has_parent(self
) && !relative_focused
) {
736 ob_debug_type(OB_DEBUG_FOCUS
,
737 "Not focusing the window because it is a "
738 "transient, and its relatives aren't focused");
740 /* Don't steal focus from globally active clients.
741 I stole this idea from KWin. It seems nice.
743 else if (!(focus_client
->can_focus
||
744 focus_client
->focus_notify
))
747 ob_debug_type(OB_DEBUG_FOCUS
,
748 "Not focusing the window because a globally "
749 "active client has focus");
751 /* Don't move focus if it's not going to go to this window
753 else if (client_focus_target(self
) != self
) {
755 ob_debug_type(OB_DEBUG_FOCUS
,
756 "Not focusing the window because another window "
757 "would get the focus anyway");
759 /* Don't move focus if the window is not visible on the current
760 desktop and none of its relatives are focused */
761 else if (!(self
->desktop
== screen_desktop
||
762 self
->desktop
== DESKTOP_ALL
) &&
766 ob_debug_type(OB_DEBUG_FOCUS
,
767 "Not focusing the window because it is on "
768 "another desktop and no relatives are focused ");
773 ob_debug_type(OB_DEBUG_FOCUS
,
774 "Focus stealing prevention activated for %s at "
775 "time %u (last user interaction time %u)",
776 self
->title
, steal_time
, event_last_user_time
);
780 /*! Returns a new structure containing the per-app settings for this client.
781 The returned structure needs to be freed with g_free. */
782 static ObAppSettings
*client_get_settings_state(ObClient
*self
)
784 ObAppSettings
*settings
;
787 settings
= config_create_app_settings();
789 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
790 ObAppSettings
*app
= it
->data
;
791 gboolean match
= TRUE
;
793 g_assert(app
->name
!= NULL
|| app
->class != NULL
);
795 /* we know that either name or class is not NULL so it will have to
796 match to use the rule */
798 !g_pattern_match(app
->name
, strlen(self
->name
), self
->name
, NULL
))
800 else if (app
->class &&
801 !g_pattern_match(app
->class,
802 strlen(self
->class), self
->class, NULL
))
804 else if (app
->role
&&
805 !g_pattern_match(app
->role
,
806 strlen(self
->role
), self
->role
, NULL
))
808 else if ((signed)app
->type
>= 0 && app
->type
!= self
->type
)
812 ob_debug("Window matching: %s", app
->name
);
814 /* copy the settings to our struct, overriding the existing
815 settings if they are not defaults */
816 config_app_settings_copy_non_defaults(app
, settings
);
820 if (settings
->shade
!= -1)
821 self
->shaded
= !!settings
->shade
;
822 if (settings
->decor
!= -1)
823 self
->undecorated
= !settings
->decor
;
824 if (settings
->iconic
!= -1)
825 self
->iconic
= !!settings
->iconic
;
826 if (settings
->skip_pager
!= -1)
827 self
->skip_pager
= !!settings
->skip_pager
;
828 if (settings
->skip_taskbar
!= -1)
829 self
->skip_taskbar
= !!settings
->skip_taskbar
;
831 if (settings
->max_vert
!= -1)
832 self
->max_vert
= !!settings
->max_vert
;
833 if (settings
->max_horz
!= -1)
834 self
->max_horz
= !!settings
->max_horz
;
836 if (settings
->fullscreen
!= -1)
837 self
->fullscreen
= !!settings
->fullscreen
;
839 if (settings
->desktop
) {
840 if (settings
->desktop
== DESKTOP_ALL
)
841 self
->desktop
= settings
->desktop
;
842 else if (settings
->desktop
> 0 &&
843 settings
->desktop
<= screen_num_desktops
)
844 self
->desktop
= settings
->desktop
- 1;
847 if (settings
->layer
== -1) {
851 else if (settings
->layer
== 0) {
855 else if (settings
->layer
== 1) {
862 static void client_restore_session_state(ObClient
*self
)
866 ob_debug_type(OB_DEBUG_SM
,
867 "Restore session for client %s", self
->title
);
869 if (!(it
= session_state_find(self
))) {
870 ob_debug_type(OB_DEBUG_SM
,
871 "Session data not found for client %s", self
->title
);
875 self
->session
= it
->data
;
877 ob_debug_type(OB_DEBUG_SM
, "Session data loaded for client %s",
880 RECT_SET_POINT(self
->area
, self
->session
->x
, self
->session
->y
);
881 self
->positioned
= USPosition
;
882 self
->sized
= USSize
;
883 if (self
->session
->w
> 0)
884 self
->area
.width
= self
->session
->w
;
885 if (self
->session
->h
> 0)
886 self
->area
.height
= self
->session
->h
;
887 XResizeWindow(obt_display
, self
->window
,
888 self
->area
.width
, self
->area
.height
);
890 self
->desktop
= (self
->session
->desktop
== DESKTOP_ALL
?
891 self
->session
->desktop
:
892 MIN(screen_num_desktops
- 1, self
->session
->desktop
));
893 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, self
->desktop
);
895 self
->shaded
= self
->session
->shaded
;
896 self
->iconic
= self
->session
->iconic
;
897 self
->skip_pager
= self
->session
->skip_pager
;
898 self
->skip_taskbar
= self
->session
->skip_taskbar
;
899 self
->fullscreen
= self
->session
->fullscreen
;
900 self
->above
= self
->session
->above
;
901 self
->below
= self
->session
->below
;
902 self
->max_horz
= self
->session
->max_horz
;
903 self
->max_vert
= self
->session
->max_vert
;
904 self
->undecorated
= self
->session
->undecorated
;
907 static gboolean
client_restore_session_stacking(ObClient
*self
)
911 if (!self
->session
) return FALSE
;
913 mypos
= g_list_find(session_saved_state
, self
->session
);
914 if (!mypos
) return FALSE
;
916 /* start above me and look for the first client */
917 for (it
= g_list_previous(mypos
); it
; it
= g_list_previous(it
)) {
920 for (cit
= client_list
; cit
; cit
= g_list_next(cit
)) {
921 ObClient
*c
= cit
->data
;
922 /* found a client that was in the session, so go below it */
923 if (c
->session
== it
->data
) {
924 stacking_below(CLIENT_AS_WINDOW(self
),
925 CLIENT_AS_WINDOW(cit
->data
));
933 void client_move_onscreen(ObClient
*self
, gboolean rude
)
935 gint x
= self
->area
.x
;
936 gint y
= self
->area
.y
;
937 if (client_find_onscreen(self
, &x
, &y
,
939 self
->area
.height
, rude
)) {
940 client_move(self
, x
, y
);
944 gboolean
client_find_onscreen(ObClient
*self
, gint
*x
, gint
*y
, gint w
, gint h
,
947 gint ox
= *x
, oy
= *y
;
948 gboolean rudel
= rude
, ruder
= rude
, rudet
= rude
, rudeb
= rude
;
954 RECT_SET(desired
, *x
, *y
, w
, h
);
955 frame_rect_to_frame(self
->frame
, &desired
);
957 /* get where the frame would be */
958 frame_client_gravity(self
->frame
, x
, y
);
960 /* get the requested size of the window with decorations */
961 fw
= self
->frame
->size
.left
+ w
+ self
->frame
->size
.right
;
962 fh
= self
->frame
->size
.top
+ h
+ self
->frame
->size
.bottom
;
964 /* If rudeness wasn't requested, then still be rude in a given direction
965 if the client is not moving, only resizing in that direction */
967 Point oldtl
, oldtr
, oldbl
, oldbr
;
968 Point newtl
, newtr
, newbl
, newbr
;
969 gboolean stationary_l
, stationary_r
, stationary_t
, stationary_b
;
971 POINT_SET(oldtl
, self
->frame
->area
.x
, self
->frame
->area
.y
);
972 POINT_SET(oldbr
, self
->frame
->area
.x
+ self
->frame
->area
.width
- 1,
973 self
->frame
->area
.y
+ self
->frame
->area
.height
- 1);
974 POINT_SET(oldtr
, oldbr
.x
, oldtl
.y
);
975 POINT_SET(oldbl
, oldtl
.x
, oldbr
.y
);
977 POINT_SET(newtl
, *x
, *y
);
978 POINT_SET(newbr
, *x
+ fw
- 1, *y
+ fh
- 1);
979 POINT_SET(newtr
, newbr
.x
, newtl
.y
);
980 POINT_SET(newbl
, newtl
.x
, newbr
.y
);
982 /* is it moving or just resizing from some corner? */
983 stationary_l
= oldtl
.x
== newtl
.x
;
984 stationary_r
= oldtr
.x
== newtr
.x
;
985 stationary_t
= oldtl
.y
== newtl
.y
;
986 stationary_b
= oldbl
.y
== newbl
.y
;
988 /* if left edge is growing and didnt move right edge */
989 if (stationary_r
&& newtl
.x
< oldtl
.x
)
991 /* if right edge is growing and didnt move left edge */
992 if (stationary_l
&& newtr
.x
> oldtr
.x
)
994 /* if top edge is growing and didnt move bottom edge */
995 if (stationary_b
&& newtl
.y
< oldtl
.y
)
997 /* if bottom edge is growing and didnt move top edge */
998 if (stationary_t
&& newbl
.y
> oldbl
.y
)
1002 /* we iterate through every monitor that the window is at least partially
1003 on, to make sure it is obeying the rules on them all
1005 if the window does not appear on any monitors, then use the first one
1008 for (i
= 0; i
< screen_num_monitors
; ++i
) {
1011 if (!screen_physical_area_monitor_contains(i
, &desired
)) {
1012 if (i
< screen_num_monitors
- 1 || found_mon
)
1015 /* the window is not inside any monitor! so just use the first
1017 a
= screen_area(self
->desktop
, 0, NULL
);
1020 a
= screen_area(self
->desktop
, SCREEN_AREA_ONE_MONITOR
, &desired
);
1023 /* This makes sure windows aren't entirely outside of the screen so you
1024 can't see them at all.
1025 It makes sure 10% of the window is on the screen at least. And don't
1026 let it move itself off the top of the screen, which would hide the
1027 titlebar on you. (The user can still do this if they want too, it's
1028 only limiting the application.
1030 if (client_normal(self
)) {
1031 if (!self
->strut
.right
&& *x
+ fw
/10 >= a
->x
+ a
->width
- 1)
1032 *x
= a
->x
+ a
->width
- fw
/10;
1033 if (!self
->strut
.bottom
&& *y
+ fh
/10 >= a
->y
+ a
->height
- 1)
1034 *y
= a
->y
+ a
->height
- fh
/10;
1035 if (!self
->strut
.left
&& *x
+ fw
*9/10 - 1 < a
->x
)
1036 *x
= a
->x
- fw
*9/10;
1037 if (!self
->strut
.top
&& *y
+ fh
*9/10 - 1 < a
->y
)
1038 *y
= a
->y
- fh
*9/10;
1041 /* This here doesn't let windows even a pixel outside the
1042 struts/screen. When called from client_manage, programs placing
1043 themselves are forced completely onscreen, while things like
1044 xterm -geometry resolution-width/2 will work fine. Trying to
1045 place it completely offscreen will be handled in the above code.
1046 Sorry for this confused comment, i am tired. */
1047 if (rudel
&& !self
->strut
.left
&& *x
< a
->x
) *x
= a
->x
;
1048 if (ruder
&& !self
->strut
.right
&& *x
+ fw
> a
->x
+ a
->width
)
1049 *x
= a
->x
+ MAX(0, a
->width
- fw
);
1051 if (rudet
&& !self
->strut
.top
&& *y
< a
->y
) *y
= a
->y
;
1052 if (rudeb
&& !self
->strut
.bottom
&& *y
+ fh
> a
->y
+ a
->height
)
1053 *y
= a
->y
+ MAX(0, a
->height
- fh
);
1058 /* get where the client should be */
1059 frame_frame_gravity(self
->frame
, x
, y
);
1061 return ox
!= *x
|| oy
!= *y
;
1064 static void client_get_all(ObClient
*self
, gboolean real
)
1066 /* this is needed for the frame to set itself up */
1067 client_get_area(self
);
1069 /* these things can change the decor and functions of the window */
1071 client_get_mwm_hints(self
);
1072 /* this can change the mwmhints for special cases */
1073 client_get_type_and_transientness(self
);
1074 client_get_state(self
);
1075 client_update_normal_hints(self
);
1077 /* get the session related properties, these can change decorations
1078 from per-app settings */
1079 client_get_session_ids(self
);
1080 client_save_session_ids(self
);
1082 /* now we got everything that can affect the decorations */
1086 /* get this early so we have it for debugging */
1087 client_update_title(self
);
1089 client_update_protocols(self
);
1091 client_update_wmhints(self
);
1092 /* this may have already been called from client_update_wmhints */
1093 if (!self
->parents
&& !self
->transient_for_group
)
1094 client_update_transient_for(self
);
1096 client_get_startup_id(self
);
1097 client_get_desktop(self
);/* uses transient data/group/startup id if a
1098 desktop is not specified */
1099 client_get_shaped(self
);
1102 /* a couple type-based defaults for new windows */
1104 /* this makes sure that these windows appear on all desktops */
1105 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
1106 self
->desktop
= DESKTOP_ALL
;
1110 client_update_sync_request_counter(self
);
1113 client_get_colormap(self
);
1114 client_update_strut(self
);
1115 client_update_icons(self
);
1116 client_update_icon_geometry(self
);
1119 static void client_get_startup_id(ObClient
*self
)
1121 if (!(OBT_PROP_GETS(self
->window
, NET_STARTUP_ID
, utf8
,
1122 &self
->startup_id
)))
1124 OBT_PROP_GETS(self
->group
->leader
,
1125 NET_STARTUP_ID
, utf8
, &self
->startup_id
);
1128 static void client_get_area(ObClient
*self
)
1130 XWindowAttributes wattrib
;
1133 ret
= XGetWindowAttributes(obt_display
, self
->window
, &wattrib
);
1134 g_assert(ret
!= BadWindow
);
1136 RECT_SET(self
->area
, wattrib
.x
, wattrib
.y
, wattrib
.width
, wattrib
.height
);
1137 POINT_SET(self
->root_pos
, wattrib
.x
, wattrib
.y
);
1138 self
->border_width
= wattrib
.border_width
;
1140 ob_debug("client area: %d %d %d %d bw %d", wattrib
.x
, wattrib
.y
,
1141 wattrib
.width
, wattrib
.height
, wattrib
.border_width
);
1144 static void client_get_desktop(ObClient
*self
)
1146 guint32 d
= screen_num_desktops
; /* an always-invalid value */
1148 if (OBT_PROP_GET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, &d
)) {
1149 if (d
>= screen_num_desktops
&& d
!= DESKTOP_ALL
)
1150 self
->desktop
= screen_num_desktops
- 1;
1153 ob_debug("client requested desktop 0x%x", self
->desktop
);
1156 gboolean first
= TRUE
;
1157 guint all
= screen_num_desktops
; /* not a valid value */
1159 /* if they are all on one desktop, then open it on the
1161 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
1162 ObClient
*c
= it
->data
;
1164 if (c
->desktop
== DESKTOP_ALL
) continue;
1170 else if (all
!= c
->desktop
)
1171 all
= screen_num_desktops
; /* make it invalid */
1173 if (all
!= screen_num_desktops
) {
1174 self
->desktop
= all
;
1176 ob_debug("client desktop set from parents: 0x%x",
1179 /* try get from the startup-notification protocol */
1180 else if (sn_get_desktop(self
->startup_id
, &self
->desktop
)) {
1181 if (self
->desktop
>= screen_num_desktops
&&
1182 self
->desktop
!= DESKTOP_ALL
)
1183 self
->desktop
= screen_num_desktops
- 1;
1184 ob_debug("client desktop set from startup-notification: 0x%x",
1187 /* defaults to the current desktop */
1189 self
->desktop
= screen_desktop
;
1190 ob_debug("client desktop set to the current desktop: %d",
1196 static void client_get_state(ObClient
*self
)
1201 if (OBT_PROP_GETA32(self
->window
, NET_WM_STATE
, ATOM
, &state
, &num
)) {
1203 for (i
= 0; i
< num
; ++i
) {
1204 if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MODAL
))
1206 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SHADED
))
1207 self
->shaded
= TRUE
;
1208 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
))
1209 self
->iconic
= TRUE
;
1210 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
))
1211 self
->skip_taskbar
= TRUE
;
1212 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
))
1213 self
->skip_pager
= TRUE
;
1214 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
))
1215 self
->fullscreen
= TRUE
;
1216 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
))
1217 self
->max_vert
= TRUE
;
1218 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
))
1219 self
->max_horz
= TRUE
;
1220 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_ABOVE
))
1222 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_BELOW
))
1224 else if (state
[i
] == OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
))
1225 self
->demands_attention
= TRUE
;
1226 else if (state
[i
] == OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
))
1227 self
->undecorated
= TRUE
;
1234 static void client_get_shaped(ObClient
*self
)
1236 self
->shaped
= FALSE
;
1238 if (obt_display_extension_shape
) {
1243 XShapeSelectInput(obt_display
, self
->window
, ShapeNotifyMask
);
1245 XShapeQueryExtents(obt_display
, self
->window
, &s
, &foo
,
1246 &foo
, &ufoo
, &ufoo
, &foo
, &foo
, &foo
, &ufoo
,
1253 void client_update_transient_for(ObClient
*self
)
1256 ObClient
*target
= NULL
;
1257 gboolean trangroup
= FALSE
;
1259 if (XGetTransientForHint(obt_display
, self
->window
, &t
)) {
1260 if (t
!= self
->window
) { /* can't be transient to itself! */
1261 ObWindow
*tw
= window_find(t
);
1262 /* if this happens then we need to check for it */
1263 g_assert(tw
!= CLIENT_AS_WINDOW(self
));
1264 if (tw
&& WINDOW_IS_CLIENT(tw
)) {
1265 /* watch out for windows with a parent that is something
1266 different, like a dockapp for example */
1267 target
= WINDOW_AS_CLIENT(tw
);
1271 /* Setting the transient_for to Root is actually illegal, however
1272 applications from time have done this to specify transient for
1274 if (!target
&& self
->group
&& t
== obt_root(ob_screen
))
1276 } else if (self
->group
&& self
->transient
)
1279 client_update_transient_tree(self
, self
->group
, self
->group
,
1280 self
->transient_for_group
, trangroup
,
1281 client_direct_parent(self
), target
);
1282 self
->transient_for_group
= trangroup
;
1286 static void client_update_transient_tree(ObClient
*self
,
1287 ObGroup
*oldgroup
, ObGroup
*newgroup
,
1288 gboolean oldgtran
, gboolean newgtran
,
1289 ObClient
* oldparent
,
1290 ObClient
*newparent
)
1295 g_assert(!oldgtran
|| oldgroup
);
1296 g_assert(!newgtran
|| newgroup
);
1297 g_assert((!oldgtran
&& !oldparent
) ||
1298 (oldgtran
&& !oldparent
) ||
1299 (!oldgtran
&& oldparent
));
1300 g_assert((!newgtran
&& !newparent
) ||
1301 (newgtran
&& !newparent
) ||
1302 (!newgtran
&& newparent
));
1305 Group transient windows are not allowed to have other group
1306 transient windows as their children.
1309 /* No change has occured */
1310 if (oldgroup
== newgroup
&&
1311 oldgtran
== newgtran
&&
1312 oldparent
== newparent
) return;
1314 /** Remove the client from the transient tree **/
1316 for (it
= self
->transients
; it
; it
= next
) {
1317 next
= g_slist_next(it
);
1319 self
->transients
= g_slist_delete_link(self
->transients
, it
);
1320 c
->parents
= g_slist_remove(c
->parents
, self
);
1322 for (it
= self
->parents
; it
; it
= next
) {
1323 next
= g_slist_next(it
);
1325 self
->parents
= g_slist_delete_link(self
->parents
, it
);
1326 c
->transients
= g_slist_remove(c
->transients
, self
);
1329 /** Re-add the client to the transient tree **/
1331 /* If we're transient for a group then we need to add ourselves to all our
1334 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1337 !client_search_top_direct_parent(c
)->transient_for_group
&&
1340 c
->transients
= g_slist_prepend(c
->transients
, self
);
1341 self
->parents
= g_slist_prepend(self
->parents
, c
);
1346 /* If we are now transient for a single window we need to add ourselves to
1349 WARNING: Cyclical transient-ness is possible if two windows are
1350 transient for eachother.
1352 else if (newparent
&&
1353 /* don't make ourself its child if it is already our child */
1354 !client_is_direct_child(self
, newparent
) &&
1355 client_normal(newparent
))
1357 newparent
->transients
= g_slist_prepend(newparent
->transients
, self
);
1358 self
->parents
= g_slist_prepend(self
->parents
, newparent
);
1361 /* Add any group transient windows to our children. But if we're transient
1362 for the group, then other group transients are not our children.
1364 WARNING: Cyclical transient-ness is possible. For e.g. if:
1365 A is transient for the group
1366 B is transient for A
1367 C is transient for B
1368 A can't be transient for C or we have a cycle
1370 if (!newgtran
&& newgroup
&&
1372 !client_search_top_direct_parent(newparent
)->transient_for_group
) &&
1373 client_normal(self
))
1375 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1377 if (c
!= self
&& c
->transient_for_group
&&
1378 /* Don't make it our child if it is already our parent */
1379 !client_is_direct_child(c
, self
))
1381 self
->transients
= g_slist_prepend(self
->transients
, c
);
1382 c
->parents
= g_slist_prepend(c
->parents
, self
);
1387 /** If we change our group transient-ness, our children change their
1388 effective group transient-ness, which affects how they relate to other
1391 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
1393 if (!c
->transient_for_group
)
1394 client_update_transient_tree(c
, c
->group
, c
->group
,
1395 c
->transient_for_group
,
1396 c
->transient_for_group
,
1397 client_direct_parent(c
),
1398 client_direct_parent(c
));
1402 void client_get_mwm_hints(ObClient
*self
)
1407 self
->mwmhints
.flags
= 0; /* default to none */
1409 if (OBT_PROP_GETA32(self
->window
, MOTIF_WM_HINTS
, MOTIF_WM_HINTS
,
1411 if (num
>= OB_MWM_ELEMENTS
) {
1412 self
->mwmhints
.flags
= hints
[0];
1413 self
->mwmhints
.functions
= hints
[1];
1414 self
->mwmhints
.decorations
= hints
[2];
1420 void client_get_type_and_transientness(ObClient
*self
)
1427 self
->transient
= FALSE
;
1429 if (OBT_PROP_GETA32(self
->window
, NET_WM_WINDOW_TYPE
, ATOM
, &val
, &num
)) {
1430 /* use the first value that we know about in the array */
1431 for (i
= 0; i
< num
; ++i
) {
1432 if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DESKTOP
))
1433 self
->type
= OB_CLIENT_TYPE_DESKTOP
;
1434 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK
))
1435 self
->type
= OB_CLIENT_TYPE_DOCK
;
1436 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_TOOLBAR
))
1437 self
->type
= OB_CLIENT_TYPE_TOOLBAR
;
1438 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_MENU
))
1439 self
->type
= OB_CLIENT_TYPE_MENU
;
1440 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_UTILITY
))
1441 self
->type
= OB_CLIENT_TYPE_UTILITY
;
1442 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_SPLASH
))
1443 self
->type
= OB_CLIENT_TYPE_SPLASH
;
1444 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG
))
1445 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1446 else if (val
[i
] == OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_NORMAL
))
1447 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1448 else if (val
[i
] == OBT_PROP_ATOM(KDE_NET_WM_WINDOW_TYPE_OVERRIDE
))
1450 /* prevent this window from getting any decor or
1452 self
->mwmhints
.flags
&= (OB_MWM_FLAG_FUNCTIONS
|
1453 OB_MWM_FLAG_DECORATIONS
);
1454 self
->mwmhints
.decorations
= 0;
1455 self
->mwmhints
.functions
= 0;
1457 if (self
->type
!= (ObClientType
) -1)
1458 break; /* grab the first legit type */
1463 if (XGetTransientForHint(obt_display
, self
->window
, &t
))
1464 self
->transient
= TRUE
;
1466 if (self
->type
== (ObClientType
) -1) {
1467 /*the window type hint was not set, which means we either classify
1468 ourself as a normal window or a dialog, depending on if we are a
1470 if (self
->transient
)
1471 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1473 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1476 /* then, based on our type, we can update our transientness.. */
1477 if (self
->type
== OB_CLIENT_TYPE_DIALOG
||
1478 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
1479 self
->type
== OB_CLIENT_TYPE_MENU
||
1480 self
->type
== OB_CLIENT_TYPE_UTILITY
)
1482 self
->transient
= TRUE
;
1486 void client_update_protocols(ObClient
*self
)
1491 self
->focus_notify
= FALSE
;
1492 self
->delete_window
= FALSE
;
1494 if (OBT_PROP_GETA32(self
->window
, WM_PROTOCOLS
, ATOM
, &proto
, &num_ret
)) {
1495 for (i
= 0; i
< num_ret
; ++i
) {
1496 if (proto
[i
] == OBT_PROP_ATOM(WM_DELETE_WINDOW
))
1497 /* this means we can request the window to close */
1498 self
->delete_window
= TRUE
;
1499 else if (proto
[i
] == OBT_PROP_ATOM(WM_TAKE_FOCUS
))
1500 /* if this protocol is requested, then the window will be
1501 notified whenever we want it to receive focus */
1502 self
->focus_notify
= TRUE
;
1503 else if (proto
[i
] == OBT_PROP_ATOM(NET_WM_PING
))
1504 /* if this protocol is requested, then the window will allow
1505 pings to determine if it is still alive */
1508 else if (proto
[i
] == OBT_PROP_ATOM(NET_WM_SYNC_REQUEST
))
1509 /* if this protocol is requested, then resizing the
1510 window will be synchronized between the frame and the
1512 self
->sync_request
= TRUE
;
1520 void client_update_sync_request_counter(ObClient
*self
)
1524 if (OBT_PROP_GET32(self
->window
, NET_WM_SYNC_REQUEST_COUNTER
, CARDINAL
,&i
))
1526 self
->sync_counter
= i
;
1528 self
->sync_counter
= None
;
1532 static void client_get_colormap(ObClient
*self
)
1534 XWindowAttributes wa
;
1536 if (XGetWindowAttributes(obt_display
, self
->window
, &wa
))
1537 client_update_colormap(self
, wa
.colormap
);
1540 void client_update_colormap(ObClient
*self
, Colormap colormap
)
1542 if (colormap
== self
->colormap
) return;
1544 ob_debug("Setting client %s colormap: 0x%x", self
->title
, colormap
);
1546 if (client_focused(self
)) {
1547 screen_install_colormap(self
, FALSE
); /* uninstall old one */
1548 self
->colormap
= colormap
;
1549 screen_install_colormap(self
, TRUE
); /* install new one */
1551 self
->colormap
= colormap
;
1554 void client_update_normal_hints(ObClient
*self
)
1560 self
->min_ratio
= 0.0f
;
1561 self
->max_ratio
= 0.0f
;
1562 SIZE_SET(self
->size_inc
, 1, 1);
1563 SIZE_SET(self
->base_size
, -1, -1);
1564 SIZE_SET(self
->min_size
, 0, 0);
1565 SIZE_SET(self
->max_size
, G_MAXINT
, G_MAXINT
);
1567 /* get the hints from the window */
1568 if (XGetWMNormalHints(obt_display
, self
->window
, &size
, &ret
)) {
1569 /* normal windows can't request placement! har har
1570 if (!client_normal(self))
1572 self
->positioned
= (size
.flags
& (PPosition
|USPosition
));
1573 self
->sized
= (size
.flags
& (PSize
|USSize
));
1575 if (size
.flags
& PWinGravity
)
1576 self
->gravity
= size
.win_gravity
;
1578 if (size
.flags
& PAspect
) {
1579 if (size
.min_aspect
.y
)
1581 (gfloat
) size
.min_aspect
.x
/ size
.min_aspect
.y
;
1582 if (size
.max_aspect
.y
)
1584 (gfloat
) size
.max_aspect
.x
/ size
.max_aspect
.y
;
1587 if (size
.flags
& PMinSize
)
1588 SIZE_SET(self
->min_size
, size
.min_width
, size
.min_height
);
1590 if (size
.flags
& PMaxSize
)
1591 SIZE_SET(self
->max_size
, size
.max_width
, size
.max_height
);
1593 if (size
.flags
& PBaseSize
)
1594 SIZE_SET(self
->base_size
, size
.base_width
, size
.base_height
);
1596 if (size
.flags
& PResizeInc
&& size
.width_inc
&& size
.height_inc
)
1597 SIZE_SET(self
->size_inc
, size
.width_inc
, size
.height_inc
);
1599 ob_debug("Normal hints: min size (%d %d) max size (%d %d)",
1600 self
->min_size
.width
, self
->min_size
.height
,
1601 self
->max_size
.width
, self
->max_size
.height
);
1602 ob_debug("size inc (%d %d) base size (%d %d)",
1603 self
->size_inc
.width
, self
->size_inc
.height
,
1604 self
->base_size
.width
, self
->base_size
.height
);
1607 ob_debug("Normal hints: not set");
1610 void client_setup_decor_and_functions(ObClient
*self
, gboolean reconfig
)
1612 /* start with everything (cept fullscreen) */
1614 (OB_FRAME_DECOR_TITLEBAR
|
1615 OB_FRAME_DECOR_HANDLE
|
1616 OB_FRAME_DECOR_GRIPS
|
1617 OB_FRAME_DECOR_BORDER
|
1618 OB_FRAME_DECOR_ICON
|
1619 OB_FRAME_DECOR_ALLDESKTOPS
|
1620 OB_FRAME_DECOR_ICONIFY
|
1621 OB_FRAME_DECOR_MAXIMIZE
|
1622 OB_FRAME_DECOR_SHADE
|
1623 OB_FRAME_DECOR_CLOSE
);
1625 (OB_CLIENT_FUNC_RESIZE
|
1626 OB_CLIENT_FUNC_MOVE
|
1627 OB_CLIENT_FUNC_ICONIFY
|
1628 OB_CLIENT_FUNC_MAXIMIZE
|
1629 OB_CLIENT_FUNC_SHADE
|
1630 OB_CLIENT_FUNC_CLOSE
|
1631 OB_CLIENT_FUNC_BELOW
|
1632 OB_CLIENT_FUNC_ABOVE
|
1633 OB_CLIENT_FUNC_UNDECORATE
);
1635 if (!(self
->min_size
.width
< self
->max_size
.width
||
1636 self
->min_size
.height
< self
->max_size
.height
))
1637 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1639 switch (self
->type
) {
1640 case OB_CLIENT_TYPE_NORMAL
:
1641 /* normal windows retain all of the possible decorations and
1642 functionality, and can be fullscreen */
1643 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1646 case OB_CLIENT_TYPE_DIALOG
:
1647 /* sometimes apps make dialog windows fullscreen for some reason (for
1648 e.g. kpdf does this..) */
1649 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1652 case OB_CLIENT_TYPE_UTILITY
:
1653 /* these windows don't have anything added or removed by default */
1656 case OB_CLIENT_TYPE_MENU
:
1657 case OB_CLIENT_TYPE_TOOLBAR
:
1658 /* these windows can't iconify or maximize */
1659 self
->decorations
&= ~(OB_FRAME_DECOR_ICONIFY
|
1660 OB_FRAME_DECOR_MAXIMIZE
);
1661 self
->functions
&= ~(OB_CLIENT_FUNC_ICONIFY
|
1662 OB_CLIENT_FUNC_MAXIMIZE
);
1665 case OB_CLIENT_TYPE_SPLASH
:
1666 /* these don't get get any decorations, and the only thing you can
1667 do with them is move them */
1668 self
->decorations
= 0;
1669 self
->functions
= OB_CLIENT_FUNC_MOVE
;
1672 case OB_CLIENT_TYPE_DESKTOP
:
1673 /* these windows are not manipulated by the window manager */
1674 self
->decorations
= 0;
1675 self
->functions
= 0;
1678 case OB_CLIENT_TYPE_DOCK
:
1679 /* these windows are not manipulated by the window manager, but they
1680 can set below layer which has a special meaning */
1681 self
->decorations
= 0;
1682 self
->functions
= OB_CLIENT_FUNC_BELOW
;
1686 /* Mwm Hints are applied subtractively to what has already been chosen for
1687 decor and functionality */
1688 if (self
->mwmhints
.flags
& OB_MWM_FLAG_DECORATIONS
) {
1689 if (! (self
->mwmhints
.decorations
& OB_MWM_DECOR_ALL
)) {
1690 if (! ((self
->mwmhints
.decorations
& OB_MWM_DECOR_HANDLE
) ||
1691 (self
->mwmhints
.decorations
& OB_MWM_DECOR_TITLE
)))
1693 /* if the mwm hints request no handle or title, then all
1694 decorations are disabled, but keep the border if that's
1696 if (self
->mwmhints
.decorations
& OB_MWM_DECOR_BORDER
)
1697 self
->decorations
= OB_FRAME_DECOR_BORDER
;
1699 self
->decorations
= 0;
1704 if (self
->mwmhints
.flags
& OB_MWM_FLAG_FUNCTIONS
) {
1705 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_ALL
)) {
1706 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_RESIZE
))
1707 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1708 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_MOVE
))
1709 self
->functions
&= ~OB_CLIENT_FUNC_MOVE
;
1710 /* dont let mwm hints kill any buttons
1711 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1712 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1713 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1714 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1716 /* dont let mwm hints kill the close button
1717 if (! (self->mwmhints.functions & MwmFunc_Close))
1718 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1722 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
))
1723 self
->decorations
&= ~OB_FRAME_DECOR_SHADE
;
1724 if (!(self
->functions
& OB_CLIENT_FUNC_ICONIFY
))
1725 self
->decorations
&= ~OB_FRAME_DECOR_ICONIFY
;
1726 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
))
1727 self
->decorations
&= ~(OB_FRAME_DECOR_GRIPS
| OB_FRAME_DECOR_HANDLE
);
1729 /* can't maximize without moving/resizing */
1730 if (!((self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) &&
1731 (self
->functions
& OB_CLIENT_FUNC_MOVE
) &&
1732 (self
->functions
& OB_CLIENT_FUNC_RESIZE
))) {
1733 self
->functions
&= ~OB_CLIENT_FUNC_MAXIMIZE
;
1734 self
->decorations
&= ~OB_FRAME_DECOR_MAXIMIZE
;
1737 if (self
->max_horz
&& self
->max_vert
) {
1738 /* you can't resize fully maximized windows */
1739 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1740 /* kill the handle on fully maxed windows */
1741 self
->decorations
&= ~(OB_FRAME_DECOR_HANDLE
| OB_FRAME_DECOR_GRIPS
);
1744 /* If there are no decorations to remove, don't allow the user to try
1746 if (self
->decorations
== 0)
1747 self
->functions
&= ~OB_CLIENT_FUNC_UNDECORATE
;
1749 /* finally, the user can have requested no decorations, which overrides
1750 everything (but doesnt give it a border if it doesnt have one) */
1751 if (self
->undecorated
)
1752 self
->decorations
&= (config_theme_keepborder
?
1753 OB_FRAME_DECOR_BORDER
: 0);
1755 /* if we don't have a titlebar, then we cannot shade! */
1756 if (!(self
->decorations
& OB_FRAME_DECOR_TITLEBAR
))
1757 self
->functions
&= ~OB_CLIENT_FUNC_SHADE
;
1759 /* now we need to check against rules for the client's current state */
1760 if (self
->fullscreen
) {
1761 self
->functions
&= (OB_CLIENT_FUNC_CLOSE
|
1762 OB_CLIENT_FUNC_FULLSCREEN
|
1763 OB_CLIENT_FUNC_ICONIFY
);
1764 self
->decorations
= 0;
1767 client_change_allowed_actions(self
);
1770 /* force reconfigure to make sure decorations are updated */
1771 client_reconfigure(self
, TRUE
);
1774 static void client_change_allowed_actions(ObClient
*self
)
1779 /* desktop windows are kept on all desktops */
1780 if (self
->type
!= OB_CLIENT_TYPE_DESKTOP
)
1781 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_CHANGE_DESKTOP
);
1783 if (self
->functions
& OB_CLIENT_FUNC_SHADE
)
1784 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_SHADE
);
1785 if (self
->functions
& OB_CLIENT_FUNC_CLOSE
)
1786 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_CLOSE
);
1787 if (self
->functions
& OB_CLIENT_FUNC_MOVE
)
1788 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MOVE
);
1789 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
)
1790 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MINIMIZE
);
1791 if (self
->functions
& OB_CLIENT_FUNC_RESIZE
)
1792 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_RESIZE
);
1793 if (self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
)
1794 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_FULLSCREEN
);
1795 if (self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) {
1796 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_HORZ
);
1797 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_MAXIMIZE_VERT
);
1799 if (self
->functions
& OB_CLIENT_FUNC_ABOVE
)
1800 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_ABOVE
);
1801 if (self
->functions
& OB_CLIENT_FUNC_BELOW
)
1802 actions
[num
++] = OBT_PROP_ATOM(NET_WM_ACTION_BELOW
);
1803 if (self
->functions
& OB_CLIENT_FUNC_UNDECORATE
)
1804 actions
[num
++] = OBT_PROP_ATOM(OB_WM_ACTION_UNDECORATE
);
1806 OBT_PROP_SETA32(self
->window
, NET_WM_ALLOWED_ACTIONS
, ATOM
, actions
, num
);
1808 /* make sure the window isn't breaking any rules now
1810 don't check ICONIFY here. just cuz a window can't iconify doesnt mean
1811 it can't be iconified with its parent
1814 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
) && self
->shaded
) {
1815 if (self
->frame
) client_shade(self
, FALSE
);
1816 else self
->shaded
= FALSE
;
1818 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) && self
->fullscreen
) {
1819 if (self
->frame
) client_fullscreen(self
, FALSE
);
1820 else self
->fullscreen
= FALSE
;
1822 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && (self
->max_horz
||
1824 if (self
->frame
) client_maximize(self
, FALSE
, 0);
1825 else self
->max_vert
= self
->max_horz
= FALSE
;
1829 void client_update_wmhints(ObClient
*self
)
1833 /* assume a window takes input if it doesn't specify */
1834 self
->can_focus
= TRUE
;
1836 if ((hints
= XGetWMHints(obt_display
, self
->window
)) != NULL
) {
1839 if (hints
->flags
& InputHint
)
1840 self
->can_focus
= hints
->input
;
1842 /* only do this when first managing the window *AND* when we aren't
1844 if (ob_state() != OB_STATE_STARTING
&& self
->frame
== NULL
)
1845 if (hints
->flags
& StateHint
)
1846 self
->iconic
= hints
->initial_state
== IconicState
;
1849 self
->urgent
= (hints
->flags
& XUrgencyHint
);
1850 if (self
->urgent
&& !ur
)
1851 client_hilite(self
, TRUE
);
1852 else if (!self
->urgent
&& ur
&& self
->demands_attention
)
1853 client_hilite(self
, FALSE
);
1855 if (!(hints
->flags
& WindowGroupHint
))
1856 hints
->window_group
= None
;
1858 /* did the group state change? */
1859 if (hints
->window_group
!=
1860 (self
->group
? self
->group
->leader
: None
))
1862 ObGroup
*oldgroup
= self
->group
;
1864 /* remove from the old group if there was one */
1866 group_remove(self
->group
, self
);
1870 /* add ourself to the group if we have one */
1871 if (hints
->window_group
!= None
) {
1872 self
->group
= group_add(hints
->window_group
, self
);
1875 /* Put ourselves into the new group's transient tree, and remove
1876 ourselves from the old group's */
1877 client_update_transient_tree(self
, oldgroup
, self
->group
,
1878 self
->transient_for_group
,
1879 self
->transient_for_group
,
1880 client_direct_parent(self
),
1881 client_direct_parent(self
));
1883 /* Lastly, being in a group, or not, can change if the window is
1884 transient for anything.
1886 The logic for this is:
1887 self->transient = TRUE always if the window wants to be
1888 transient for something, even if transient_for was NULL because
1889 it wasn't in a group before.
1891 If parents was NULL and oldgroup was NULL we can assume
1892 that when we add the new group, it will become transient for
1895 If transient_for_group is TRUE, then it must have already
1896 had a group. If it is getting a new group, the above call to
1897 client_update_transient_tree has already taken care of
1898 everything ! If it is losing all group status then it will
1899 no longer be transient for anything and that needs to be
1902 if (self
->transient
&&
1903 ((self
->parents
== NULL
&& oldgroup
== NULL
) ||
1904 (self
->transient_for_group
&& !self
->group
)))
1905 client_update_transient_for(self
);
1908 /* the WM_HINTS can contain an icon */
1909 if (hints
->flags
& IconPixmapHint
)
1910 client_update_icons(self
);
1916 void client_update_title(ObClient
*self
)
1919 gchar
*visible
= NULL
;
1921 g_free(self
->title
);
1922 g_free(self
->original_title
);
1925 if (!OBT_PROP_GETS(self
->window
, NET_WM_NAME
, utf8
, &data
)) {
1926 /* try old x stuff */
1927 if (!(OBT_PROP_GETS(self
->window
, WM_NAME
, locale
, &data
)
1928 || OBT_PROP_GETS(self
->window
, WM_NAME
, utf8
, &data
))) {
1929 if (self
->transient
) {
1931 GNOME alert windows are not given titles:
1932 http://developer.gnome.org/projects/gup/hig/draft_hig_new/windows-alert.html
1934 data
= g_strdup("");
1936 data
= g_strdup(_("Unnamed Window"));
1939 self
->original_title
= g_strdup(data
);
1941 if (self
->client_machine
) {
1942 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1947 if (self
->not_responding
) {
1949 if (self
->kill_level
> 0)
1950 visible
= g_strdup_printf("%s - [%s]", data
, _("Killing..."));
1952 visible
= g_strdup_printf("%s - [%s]", data
, _("Not Responding"));
1956 OBT_PROP_SETS(self
->window
, NET_WM_VISIBLE_NAME
, utf8
, visible
);
1957 self
->title
= visible
;
1960 frame_adjust_title(self
->frame
);
1962 /* update the icon title */
1964 g_free(self
->icon_title
);
1967 if (!OBT_PROP_GETS(self
->window
, NET_WM_ICON_NAME
, utf8
, &data
))
1968 /* try old x stuff */
1969 if (!(OBT_PROP_GETS(self
->window
, WM_ICON_NAME
, locale
, &data
) ||
1970 OBT_PROP_GETS(self
->window
, WM_ICON_NAME
, utf8
, &data
)))
1971 data
= g_strdup(self
->title
);
1973 if (self
->client_machine
) {
1974 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1979 if (self
->not_responding
) {
1981 if (self
->kill_level
> 0)
1982 visible
= g_strdup_printf("%s - [%s]", data
, _("Killing..."));
1984 visible
= g_strdup_printf("%s - [%s]", data
, _("Not Responding"));
1988 OBT_PROP_SETS(self
->window
, NET_WM_VISIBLE_ICON_NAME
, utf8
, visible
);
1989 self
->icon_title
= visible
;
1992 void client_update_strut(ObClient
*self
)
1996 gboolean got
= FALSE
;
1999 if (OBT_PROP_GETA32(self
->window
, NET_WM_STRUT_PARTIAL
, CARDINAL
,
2004 STRUT_PARTIAL_SET(strut
,
2005 data
[0], data
[2], data
[1], data
[3],
2006 data
[4], data
[5], data
[8], data
[9],
2007 data
[6], data
[7], data
[10], data
[11]);
2013 OBT_PROP_GETA32(self
->window
, NET_WM_STRUT
, CARDINAL
, &data
, &num
)) {
2019 /* use the screen's width/height */
2020 a
= screen_physical_area_all_monitors();
2022 STRUT_PARTIAL_SET(strut
,
2023 data
[0], data
[2], data
[1], data
[3],
2024 a
->y
, a
->y
+ a
->height
- 1,
2025 a
->x
, a
->x
+ a
->width
- 1,
2026 a
->y
, a
->y
+ a
->height
- 1,
2027 a
->x
, a
->x
+ a
->width
- 1);
2034 STRUT_PARTIAL_SET(strut
, 0, 0, 0, 0,
2035 0, 0, 0, 0, 0, 0, 0, 0);
2037 if (!PARTIAL_STRUT_EQUAL(strut
, self
->strut
)) {
2038 self
->strut
= strut
;
2040 /* updating here is pointless while we're being mapped cuz we're not in
2041 the client list yet */
2043 screen_update_areas();
2047 void client_update_icons(ObClient
*self
)
2052 guint num_seen
; /* number of icons present */
2057 /* grab the server, because we might be setting the window's icon and
2058 we don't want them to set it in between and we overwrite their own
2062 if (OBT_PROP_GETA32(self
->window
, NET_WM_ICON
, CARDINAL
, &data
, &num
)) {
2063 /* figure out how many valid icons are in here */
2066 while (i
+ 2 < num
) { /* +2 is to make sure there is a w and h */
2069 /* watch for the data being too small for the specified size,
2070 or for zero sized icons. */
2071 if (i
+ w
*h
> num
|| w
== 0 || h
== 0) break;
2073 /* convert it to the right bit order for ObRender */
2074 for (j
= 0; j
< w
*h
; ++j
)
2076 (((data
[i
+j
] >> 24) & 0xff) << RrDefaultAlphaOffset
) +
2077 (((data
[i
+j
] >> 16) & 0xff) << RrDefaultRedOffset
) +
2078 (((data
[i
+j
] >> 8) & 0xff) << RrDefaultGreenOffset
) +
2079 (((data
[i
+j
] >> 0) & 0xff) << RrDefaultBlueOffset
);
2081 /* is it in the cache? */
2082 img
= RrImageCacheFind(ob_rr_icons
, &data
[i
], w
, h
);
2083 if (img
) RrImageRef(img
); /* own it */
2088 /* don't bother looping anymore if we already found it in the cache
2089 since we'll just use that! */
2093 /* if it's not in the cache yet, then add it to the cache now.
2094 we have already converted it to the correct bit order above */
2095 if (!img
&& num_seen
> 0) {
2096 img
= RrImageNew(ob_rr_icons
);
2098 for (j
= 0; j
< num_seen
; ++j
) {
2101 RrImageAddPicture(img
, &data
[i
], w
, h
);
2109 /* if we didn't find an image from the NET_WM_ICON stuff, then try the
2114 if ((hints
= XGetWMHints(obt_display
, self
->window
))) {
2115 if (hints
->flags
& IconPixmapHint
) {
2117 obt_display_ignore_errors(TRUE
);
2118 xicon
= RrPixmapToRGBA(ob_rr_inst
,
2120 (hints
->flags
& IconMaskHint
?
2121 hints
->icon_mask
: None
),
2122 (gint
*)&w
, (gint
*)&h
, &data
);
2123 obt_display_ignore_errors(FALSE
);
2126 if (w
> 0 && h
> 0) {
2127 /* is this icon in the cache yet? */
2128 img
= RrImageCacheFind(ob_rr_icons
, data
, w
, h
);
2129 if (img
) RrImageRef(img
); /* own it */
2131 /* if not, then add it */
2133 img
= RrImageNew(ob_rr_icons
);
2134 RrImageAddPicture(img
, data
, w
, h
);
2145 /* set the client's icons to be whatever we found */
2146 RrImageUnref(self
->icon_set
);
2147 self
->icon_set
= img
;
2149 /* if the client has no icon at all, then we set a default icon onto it.
2150 but, if it has parents, then one of them will have an icon already
2152 if (!self
->icon_set
&& !self
->parents
) {
2153 RrPixel32
*icon
= ob_rr_theme
->def_win_icon
;
2154 gulong
*ldata
; /* use a long here to satisfy OBT_PROP_SETA32 */
2156 w
= ob_rr_theme
->def_win_icon_w
;
2157 h
= ob_rr_theme
->def_win_icon_h
;
2158 ldata
= g_new(gulong
, w
*h
+2);
2161 for (i
= 0; i
< w
*h
; ++i
)
2162 ldata
[i
+2] = (((icon
[i
] >> RrDefaultAlphaOffset
) & 0xff) << 24) +
2163 (((icon
[i
] >> RrDefaultRedOffset
) & 0xff) << 16) +
2164 (((icon
[i
] >> RrDefaultGreenOffset
) & 0xff) << 8) +
2165 (((icon
[i
] >> RrDefaultBlueOffset
) & 0xff) << 0);
2166 OBT_PROP_SETA32(self
->window
, NET_WM_ICON
, CARDINAL
, ldata
, w
*h
+2);
2168 } else if (self
->frame
)
2169 /* don't draw the icon empty if we're just setting one now anyways,
2170 we'll get the property change any second */
2171 frame_adjust_icon(self
->frame
);
2176 void client_update_icon_geometry(ObClient
*self
)
2181 RECT_SET(self
->icon_geometry
, 0, 0, 0, 0);
2183 if (OBT_PROP_GETA32(self
->window
, NET_WM_ICON_GEOMETRY
, CARDINAL
,
2187 /* don't let them set it with an area < 0 */
2188 RECT_SET(self
->icon_geometry
, data
[0], data
[1],
2189 MAX(data
[2],0), MAX(data
[3],0));
2194 static void client_get_session_ids(ObClient
*self
)
2201 if (!OBT_PROP_GET32(self
->window
, WM_CLIENT_LEADER
, WINDOW
, &leader
))
2204 /* get the SM_CLIENT_ID */
2207 got
= OBT_PROP_GETS(leader
, SM_CLIENT_ID
, locale
, &self
->sm_client_id
);
2209 OBT_PROP_GETS(self
->window
, SM_CLIENT_ID
, locale
, &self
->sm_client_id
);
2211 /* get the WM_CLASS (name and class). make them "" if they are not
2215 got
= OBT_PROP_GETSS(leader
, WM_CLASS
, locale
, &ss
);
2217 got
= OBT_PROP_GETSS(self
->window
, WM_CLASS
, locale
, &ss
);
2221 self
->name
= g_strdup(ss
[0]);
2223 self
->class = g_strdup(ss
[1]);
2228 if (self
->name
== NULL
) self
->name
= g_strdup("");
2229 if (self
->class == NULL
) self
->class = g_strdup("");
2231 /* get the WM_WINDOW_ROLE. make it "" if it is not provided */
2234 got
= OBT_PROP_GETS(leader
, WM_WINDOW_ROLE
, locale
, &s
);
2236 got
= OBT_PROP_GETS(self
->window
, WM_WINDOW_ROLE
, locale
, &s
);
2241 self
->role
= g_strdup("");
2243 /* get the WM_COMMAND */
2247 got
= OBT_PROP_GETSS(leader
, WM_COMMAND
, locale
, &ss
);
2249 got
= OBT_PROP_GETSS(self
->window
, WM_COMMAND
, locale
, &ss
);
2252 /* merge/mash them all together */
2253 gchar
*merge
= NULL
;
2256 for (i
= 0; ss
[i
]; ++i
) {
2259 merge
= g_strconcat(merge
, ss
[i
], NULL
);
2261 merge
= g_strconcat(ss
[i
], NULL
);
2266 self
->wm_command
= merge
;
2269 /* get the WM_CLIENT_MACHINE */
2272 got
= OBT_PROP_GETS(leader
, WM_CLIENT_MACHINE
, locale
, &s
);
2274 got
= OBT_PROP_GETS(self
->window
, WM_CLIENT_MACHINE
, locale
, &s
);
2277 gchar localhost
[128];
2280 gethostname(localhost
, 127);
2281 localhost
[127] = '\0';
2282 if (strcmp(localhost
, s
) != 0)
2283 self
->client_machine
= s
;
2287 /* see if it has the PID set too (the PID requires that the
2288 WM_CLIENT_MACHINE be set) */
2289 if (OBT_PROP_GET32(self
->window
, NET_WM_PID
, CARDINAL
, &pid
))
2294 /*! Save the session IDs as seen by Openbox when the window mapped, so that
2295 users can still access them later if the app changes them */
2296 static void client_save_session_ids(ObClient
*self
)
2298 OBT_PROP_SETS(self
->window
, OB_ROLE
, utf8
, self
->role
);
2299 OBT_PROP_SETS(self
->window
, OB_NAME
, utf8
, self
->name
);
2300 OBT_PROP_SETS(self
->window
, OB_CLASS
, utf8
, self
->class);
2303 static void client_change_wm_state(ObClient
*self
)
2308 old
= self
->wmstate
;
2310 if (self
->shaded
|| self
->iconic
||
2311 (self
->desktop
!= DESKTOP_ALL
&& self
->desktop
!= screen_desktop
))
2313 self
->wmstate
= IconicState
;
2315 self
->wmstate
= NormalState
;
2317 if (old
!= self
->wmstate
) {
2318 OBT_PROP_MSG(ob_screen
, self
->window
, KDE_WM_CHANGE_STATE
,
2319 self
->wmstate
, 1, 0, 0, 0);
2321 state
[0] = self
->wmstate
;
2323 OBT_PROP_SETA32(self
->window
, WM_STATE
, WM_STATE
, state
, 2);
2327 static void client_change_state(ObClient
*self
)
2329 gulong netstate
[12];
2334 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MODAL
);
2336 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SHADED
);
2338 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
);
2339 if (self
->skip_taskbar
)
2340 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
);
2341 if (self
->skip_pager
)
2342 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
);
2343 if (self
->fullscreen
)
2344 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
);
2346 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
);
2348 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
);
2350 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_ABOVE
);
2352 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_BELOW
);
2353 if (self
->demands_attention
)
2354 netstate
[num
++] = OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
);
2355 if (self
->undecorated
)
2356 netstate
[num
++] = OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
);
2357 OBT_PROP_SETA32(self
->window
, NET_WM_STATE
, ATOM
, netstate
, num
);
2360 frame_adjust_state(self
->frame
);
2363 ObClient
*client_search_focus_tree(ObClient
*self
)
2368 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
2369 if (client_focused(it
->data
)) return it
->data
;
2370 if ((ret
= client_search_focus_tree(it
->data
))) return ret
;
2375 ObClient
*client_search_focus_tree_full(ObClient
*self
)
2377 if (self
->parents
) {
2380 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
2381 ObClient
*c
= it
->data
;
2382 if ((c
= client_search_focus_tree_full(c
))) return c
;
2388 /* this function checks the whole tree, the client_search_focus_tree
2389 does not, so we need to check this window */
2390 if (client_focused(self
))
2392 return client_search_focus_tree(self
);
2396 ObClient
*client_search_focus_group_full(ObClient
*self
)
2401 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
2402 ObClient
*c
= it
->data
;
2404 if (client_focused(c
)) return c
;
2405 if ((c
= client_search_focus_tree(it
->data
))) return c
;
2408 if (client_focused(self
)) return self
;
2412 gboolean
client_has_parent(ObClient
*self
)
2414 return self
->parents
!= NULL
;
2417 static ObStackingLayer
calc_layer(ObClient
*self
)
2422 monitor
= screen_physical_area_monitor(client_monitor(self
));
2424 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
2425 l
= OB_STACKING_LAYER_DESKTOP
;
2426 else if (self
->type
== OB_CLIENT_TYPE_DOCK
) {
2427 if (self
->below
) l
= OB_STACKING_LAYER_NORMAL
;
2428 else l
= OB_STACKING_LAYER_ABOVE
;
2430 else if ((self
->fullscreen
||
2431 /* No decorations and fills the monitor = oldskool fullscreen.
2432 But not for maximized windows.
2434 (self
->decorations
== 0 &&
2435 !(self
->max_horz
&& self
->max_vert
) &&
2436 RECT_EQUAL(self
->area
, *monitor
))) &&
2437 /* you are fullscreen while you or your children are focused.. */
2438 (client_focused(self
) || client_search_focus_tree(self
) ||
2439 /* you can be fullscreen if you're on another desktop */
2440 (self
->desktop
!= screen_desktop
&&
2441 self
->desktop
!= DESKTOP_ALL
) ||
2442 /* and you can also be fullscreen if the focused client is on
2443 another monitor, or nothing else is focused */
2445 client_monitor(focus_client
) != client_monitor(self
))))
2446 l
= OB_STACKING_LAYER_FULLSCREEN
;
2447 else if (self
->above
) l
= OB_STACKING_LAYER_ABOVE
;
2448 else if (self
->below
) l
= OB_STACKING_LAYER_BELOW
;
2449 else l
= OB_STACKING_LAYER_NORMAL
;
2456 static void client_calc_layer_recursive(ObClient
*self
, ObClient
*orig
,
2457 ObStackingLayer min
)
2459 ObStackingLayer old
, own
;
2463 own
= calc_layer(self
);
2464 self
->layer
= MAX(own
, min
);
2466 if (self
->layer
!= old
) {
2467 stacking_remove(CLIENT_AS_WINDOW(self
));
2468 stacking_add_nonintrusive(CLIENT_AS_WINDOW(self
));
2471 /* we've been restacked */
2472 self
->visited
= TRUE
;
2474 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
2475 client_calc_layer_recursive(it
->data
, orig
,
2479 static void client_calc_layer_internal(ObClient
*self
)
2483 /* transients take on the layer of their parents */
2484 sit
= client_search_all_top_parents(self
);
2486 for (; sit
; sit
= g_slist_next(sit
))
2487 client_calc_layer_recursive(sit
->data
, self
, 0);
2490 void client_calc_layer(ObClient
*self
)
2494 /* skip over stuff above fullscreen layer */
2495 for (it
= stacking_list
; it
; it
= g_list_next(it
))
2496 if (window_layer(it
->data
) <= OB_STACKING_LAYER_FULLSCREEN
) break;
2498 /* find the windows in the fullscreen layer, and mark them not-visited */
2499 for (; it
; it
= g_list_next(it
)) {
2500 if (window_layer(it
->data
) < OB_STACKING_LAYER_FULLSCREEN
) break;
2501 else if (WINDOW_IS_CLIENT(it
->data
))
2502 WINDOW_AS_CLIENT(it
->data
)->visited
= FALSE
;
2505 client_calc_layer_internal(self
);
2507 /* skip over stuff above fullscreen layer */
2508 for (it
= stacking_list
; it
; it
= g_list_next(it
))
2509 if (window_layer(it
->data
) <= OB_STACKING_LAYER_FULLSCREEN
) break;
2511 /* now recalc any windows in the fullscreen layer which have not
2512 had their layer recalced already */
2513 for (; it
; it
= g_list_next(it
)) {
2514 if (window_layer(it
->data
) < OB_STACKING_LAYER_FULLSCREEN
) break;
2515 else if (WINDOW_IS_CLIENT(it
->data
) &&
2516 !WINDOW_AS_CLIENT(it
->data
)->visited
)
2517 client_calc_layer_internal(it
->data
);
2521 gboolean
client_should_show(ObClient
*self
)
2525 if (client_normal(self
) && screen_showing_desktop
)
2527 if (self
->desktop
== screen_desktop
|| self
->desktop
== DESKTOP_ALL
)
2533 gboolean
client_show(ObClient
*self
)
2535 gboolean show
= FALSE
;
2537 if (client_should_show(self
)) {
2538 /* replay pending pointer event before showing the window, in case it
2539 should be going to something under the window */
2540 mouse_replay_pointer();
2542 frame_show(self
->frame
);
2545 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible,
2546 it needs to be in IconicState. This includes when it is on another
2549 client_change_wm_state(self
);
2554 gboolean
client_hide(ObClient
*self
)
2556 gboolean hide
= FALSE
;
2558 if (!client_should_show(self
)) {
2559 /* We don't need to ignore enter events here.
2560 The window can hide/iconify in 3 different ways:
2561 1 - through an x message. in this case we ignore all enter events
2562 caused by responding to the x message (unless underMouse)
2563 2 - by a keyboard action. in this case we ignore all enter events
2564 caused by the action
2565 3 - by a mouse action. in this case they are doing stuff with the
2566 mouse and focus _should_ move.
2568 Also in action_end, we simulate an enter event that can't be ignored
2569 so trying to ignore them is futile in case 3 anyways
2572 /* replay pending pointer event before hiding the window, in case it
2573 should be going to the window */
2574 mouse_replay_pointer();
2576 frame_hide(self
->frame
);
2579 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible,
2580 it needs to be in IconicState. This includes when it is on another
2583 client_change_wm_state(self
);
2588 void client_showhide(ObClient
*self
)
2590 if (!client_show(self
))
2594 gboolean
client_normal(ObClient
*self
) {
2595 return ! (self
->type
== OB_CLIENT_TYPE_DESKTOP
||
2596 self
->type
== OB_CLIENT_TYPE_DOCK
||
2597 self
->type
== OB_CLIENT_TYPE_SPLASH
);
2600 gboolean
client_helper(ObClient
*self
)
2602 return (self
->type
== OB_CLIENT_TYPE_UTILITY
||
2603 self
->type
== OB_CLIENT_TYPE_MENU
||
2604 self
->type
== OB_CLIENT_TYPE_TOOLBAR
);
2607 gboolean
client_mouse_focusable(ObClient
*self
)
2609 return !(self
->type
== OB_CLIENT_TYPE_MENU
||
2610 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
2611 self
->type
== OB_CLIENT_TYPE_SPLASH
||
2612 self
->type
== OB_CLIENT_TYPE_DOCK
);
2615 gboolean
client_enter_focusable(ObClient
*self
)
2617 /* you can focus desktops but it shouldn't on enter */
2618 return (client_mouse_focusable(self
) &&
2619 self
->type
!= OB_CLIENT_TYPE_DESKTOP
);
2622 static void client_apply_startup_state(ObClient
*self
,
2623 gint x
, gint y
, gint w
, gint h
)
2625 /* save the states that we are going to apply */
2626 gboolean iconic
= self
->iconic
;
2627 gboolean fullscreen
= self
->fullscreen
;
2628 gboolean undecorated
= self
->undecorated
;
2629 gboolean shaded
= self
->shaded
;
2630 gboolean demands_attention
= self
->demands_attention
;
2631 gboolean max_horz
= self
->max_horz
;
2632 gboolean max_vert
= self
->max_vert
;
2636 /* turn them all off in the client, so they won't affect the window
2638 self
->iconic
= self
->fullscreen
= self
->undecorated
= self
->shaded
=
2639 self
->demands_attention
= self
->max_horz
= self
->max_vert
= FALSE
;
2641 /* move the client to its placed position, or it it's already there,
2642 generate a ConfigureNotify telling the client where it is.
2644 do this after adjusting the frame. otherwise it gets all weird and
2645 clients don't work right
2647 do this before applying the states so they have the correct
2648 pre-max/pre-fullscreen values
2650 client_try_configure(self
, &x
, &y
, &w
, &h
, &l
, &l
, FALSE
);
2651 ob_debug("placed window 0x%x at %d, %d with size %d x %d",
2652 self
->window
, x
, y
, w
, h
);
2653 /* save the area, and make it where it should be for the premax stuff */
2654 oldarea
= self
->area
;
2655 RECT_SET(self
->area
, x
, y
, w
, h
);
2657 /* apply the states. these are in a carefully crafted order.. */
2660 client_iconify(self
, TRUE
, FALSE
, TRUE
);
2662 client_fullscreen(self
, TRUE
);
2664 client_set_undecorated(self
, TRUE
);
2666 client_shade(self
, TRUE
);
2667 if (demands_attention
)
2668 client_hilite(self
, TRUE
);
2670 if (max_vert
&& max_horz
)
2671 client_maximize(self
, TRUE
, 0);
2673 client_maximize(self
, TRUE
, 2);
2675 client_maximize(self
, TRUE
, 1);
2677 /* if the window hasn't been configured yet, then do so now, in fact the
2678 x,y,w,h may _not_ be the same as the area rect, which can end up
2679 meaning that the client isn't properly moved/resized by the fullscreen
2681 pho can cause this because it maps at size of the screen but not 0,0
2682 so openbox moves it on screen to 0,0 (thus x,y=0,0 and area.x,y don't).
2683 then fullscreen'ing makes it go to 0,0 which it thinks it already is at
2684 cuz thats where the pre-fullscreen will be. however the actual area is
2685 not, so this needs to be called even if we have fullscreened/maxed
2687 self
->area
= oldarea
;
2688 client_configure(self
, x
, y
, w
, h
, FALSE
, TRUE
, FALSE
);
2690 /* set the desktop hint, to make sure that it always exists */
2691 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, self
->desktop
);
2693 /* nothing to do for the other states:
2702 void client_gravity_resize_w(ObClient
*self
, gint
*x
, gint oldw
, gint neww
)
2704 /* these should be the current values. this is for when you're not moving,
2706 g_assert(*x
== self
->area
.x
);
2707 g_assert(oldw
== self
->area
.width
);
2710 switch (self
->gravity
) {
2712 case NorthWestGravity
:
2714 case SouthWestGravity
:
2721 *x
-= (neww
- oldw
) / 2;
2723 case NorthEastGravity
:
2725 case SouthEastGravity
:
2731 void client_gravity_resize_h(ObClient
*self
, gint
*y
, gint oldh
, gint newh
)
2733 /* these should be the current values. this is for when you're not moving,
2735 g_assert(*y
== self
->area
.y
);
2736 g_assert(oldh
== self
->area
.height
);
2739 switch (self
->gravity
) {
2741 case NorthWestGravity
:
2743 case NorthEastGravity
:
2750 *y
-= (newh
- oldh
) / 2;
2752 case SouthWestGravity
:
2754 case SouthEastGravity
:
2760 void client_try_configure(ObClient
*self
, gint
*x
, gint
*y
, gint
*w
, gint
*h
,
2761 gint
*logicalw
, gint
*logicalh
,
2764 Rect desired
= {*x
, *y
, *w
, *h
};
2765 frame_rect_to_frame(self
->frame
, &desired
);
2767 /* make the frame recalculate its dimensions n shit without changing
2768 anything visible for real, this way the constraints below can work with
2769 the updated frame dimensions. */
2770 frame_adjust_area(self
->frame
, FALSE
, TRUE
, TRUE
);
2772 /* gets the frame's position */
2773 frame_client_gravity(self
->frame
, x
, y
);
2775 /* these positions are frame positions, not client positions */
2777 /* set the size and position if fullscreen */
2778 if (self
->fullscreen
) {
2782 i
= screen_find_monitor(&desired
);
2783 a
= screen_physical_area_monitor(i
);
2790 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2794 } else if (self
->max_horz
|| self
->max_vert
) {
2798 /* use all possible struts when maximizing to the full screen */
2799 i
= screen_find_monitor(&desired
);
2800 a
= screen_area(self
->desktop
, i
,
2801 (self
->max_horz
&& self
->max_vert
? NULL
: &desired
));
2803 /* set the size and position if maximized */
2804 if (self
->max_horz
) {
2806 *w
= a
->width
- self
->frame
->size
.left
- self
->frame
->size
.right
;
2808 if (self
->max_vert
) {
2810 *h
= a
->height
- self
->frame
->size
.top
- self
->frame
->size
.bottom
;
2813 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2819 /* gets the client's position */
2820 frame_frame_gravity(self
->frame
, x
, y
);
2822 /* work within the preferred sizes given by the window, these may have
2823 changed rather than it's requested width and height, so always run
2824 through this code */
2826 gint basew
, baseh
, minw
, minh
;
2828 gfloat minratio
, maxratio
;
2830 incw
= self
->fullscreen
|| self
->max_horz
? 1 : self
->size_inc
.width
;
2831 inch
= self
->fullscreen
|| self
->max_vert
? 1 : self
->size_inc
.height
;
2832 minratio
= self
->fullscreen
|| (self
->max_horz
&& self
->max_vert
) ?
2833 0 : self
->min_ratio
;
2834 maxratio
= self
->fullscreen
|| (self
->max_horz
&& self
->max_vert
) ?
2835 0 : self
->max_ratio
;
2837 /* base size is substituted with min size if not specified */
2838 if (self
->base_size
.width
>= 0 || self
->base_size
.height
>= 0) {
2839 basew
= self
->base_size
.width
;
2840 baseh
= self
->base_size
.height
;
2842 basew
= self
->min_size
.width
;
2843 baseh
= self
->min_size
.height
;
2845 /* min size is substituted with base size if not specified */
2846 if (self
->min_size
.width
|| self
->min_size
.height
) {
2847 minw
= self
->min_size
.width
;
2848 minh
= self
->min_size
.height
;
2850 minw
= self
->base_size
.width
;
2851 minh
= self
->base_size
.height
;
2854 /* This comment is no longer true */
2855 /* if this is a user-requested resize, then check against min/max
2858 /* smaller than min size or bigger than max size? */
2859 if (*w
> self
->max_size
.width
) *w
= self
->max_size
.width
;
2860 if (*w
< minw
) *w
= minw
;
2861 if (*h
> self
->max_size
.height
) *h
= self
->max_size
.height
;
2862 if (*h
< minh
) *h
= minh
;
2867 /* keep to the increments */
2871 /* you cannot resize to nothing */
2872 if (basew
+ *w
< 1) *w
= 1 - basew
;
2873 if (baseh
+ *h
< 1) *h
= 1 - baseh
;
2875 /* save the logical size */
2876 *logicalw
= incw
> 1 ? *w
: *w
+ basew
;
2877 *logicalh
= inch
> 1 ? *h
: *h
+ baseh
;
2885 /* adjust the height to match the width for the aspect ratios.
2886 for this, min size is not substituted for base size ever. */
2887 *w
-= self
->base_size
.width
;
2888 *h
-= self
->base_size
.height
;
2891 if (*h
* minratio
> *w
) {
2892 *h
= (gint
)(*w
/ minratio
);
2894 /* you cannot resize to nothing */
2897 *w
= (gint
)(*h
* minratio
);
2901 if (*h
* maxratio
< *w
) {
2902 *h
= (gint
)(*w
/ maxratio
);
2904 /* you cannot resize to nothing */
2907 *w
= (gint
)(*h
* minratio
);
2911 *w
+= self
->base_size
.width
;
2912 *h
+= self
->base_size
.height
;
2915 /* these override the above states! if you cant move you can't move! */
2917 if (!(self
->functions
& OB_CLIENT_FUNC_MOVE
)) {
2921 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
)) {
2922 *w
= self
->area
.width
;
2923 *h
= self
->area
.height
;
2931 void client_configure(ObClient
*self
, gint x
, gint y
, gint w
, gint h
,
2932 gboolean user
, gboolean final
, gboolean force_reply
)
2936 gboolean send_resize_client
;
2937 gboolean moved
= FALSE
, resized
= FALSE
, rootmoved
= FALSE
;
2938 gboolean fmoved
, fresized
;
2939 guint fdecor
= self
->frame
->decorations
;
2940 gboolean fhorz
= self
->frame
->max_horz
;
2941 gboolean fvert
= self
->frame
->max_vert
;
2942 gint logicalw
, logicalh
;
2944 /* find the new x, y, width, and height (and logical size) */
2945 client_try_configure(self
, &x
, &y
, &w
, &h
, &logicalw
, &logicalh
, user
);
2947 /* set the logical size if things changed */
2948 if (!(w
== self
->area
.width
&& h
== self
->area
.height
))
2949 SIZE_SET(self
->logical_size
, logicalw
, logicalh
);
2951 /* figure out if we moved or resized or what */
2952 moved
= (x
!= self
->area
.x
|| y
!= self
->area
.y
);
2953 resized
= (w
!= self
->area
.width
|| h
!= self
->area
.height
);
2955 oldw
= self
->area
.width
;
2956 oldh
= self
->area
.height
;
2957 oldframe
= self
->frame
->area
;
2958 RECT_SET(self
->area
, x
, y
, w
, h
);
2960 /* for app-requested resizes, always resize if 'resized' is true.
2961 for user-requested ones, only resize if final is true, or when
2962 resizing in redraw mode */
2963 send_resize_client
= ((!user
&& resized
) ||
2965 (resized
&& config_resize_redraw
))));
2967 /* if the client is enlarging, then resize the client before the frame */
2968 if (send_resize_client
&& (w
> oldw
|| h
> oldh
)) {
2969 XMoveResizeWindow(obt_display
, self
->window
,
2970 self
->frame
->size
.left
, self
->frame
->size
.top
,
2971 MAX(w
, oldw
), MAX(h
, oldh
));
2972 frame_adjust_client_area(self
->frame
);
2975 /* find the frame's dimensions and move/resize it */
2979 /* if decorations changed, then readjust everything for the frame */
2980 if (self
->decorations
!= fdecor
||
2981 self
->max_horz
!= fhorz
|| self
->max_vert
!= fvert
)
2983 fmoved
= fresized
= TRUE
;
2986 /* adjust the frame */
2987 if (fmoved
|| fresized
) {
2988 gulong ignore_start
;
2990 ignore_start
= event_start_ignore_all_enters();
2992 /* replay pending pointer event before move the window, in case it
2993 would change what window gets the event */
2994 mouse_replay_pointer();
2996 frame_adjust_area(self
->frame
, fmoved
, fresized
, FALSE
);
2999 event_end_ignore_all_enters(ignore_start
);
3002 if (!user
|| final
) {
3003 gint oldrx
= self
->root_pos
.x
;
3004 gint oldry
= self
->root_pos
.y
;
3005 /* we have reset the client to 0 border width, so don't include
3006 it in these coords */
3007 POINT_SET(self
->root_pos
,
3008 self
->frame
->area
.x
+ self
->frame
->size
.left
-
3010 self
->frame
->area
.y
+ self
->frame
->size
.top
-
3011 self
->border_width
);
3012 if (self
->root_pos
.x
!= oldrx
|| self
->root_pos
.y
!= oldry
)
3016 /* This is kinda tricky and should not be changed.. let me explain!
3018 When user = FALSE, then the request is coming from the application
3019 itself, and we are more strict about when to send a synthetic
3020 ConfigureNotify. We strictly follow the rules of the ICCCM sec 4.1.5
3021 in this case (if force_reply is true)
3023 When user = TRUE, then the request is coming from "us", like when we
3024 maximize a window or something. In this case we are more lenient. We
3025 used to follow the same rules as above, but _Java_ Swing can't handle
3026 this. So just to appease Swing, when user = TRUE, we always send
3027 a synthetic ConfigureNotify to give the window its root coordinates.
3029 if ((!user
&& !resized
&& (rootmoved
|| force_reply
)) ||
3030 (user
&& final
&& rootmoved
))
3034 event
.type
= ConfigureNotify
;
3035 event
.xconfigure
.display
= obt_display
;
3036 event
.xconfigure
.event
= self
->window
;
3037 event
.xconfigure
.window
= self
->window
;
3039 ob_debug("Sending ConfigureNotify to %s for %d,%d %dx%d",
3040 self
->title
, self
->root_pos
.x
, self
->root_pos
.y
, w
, h
);
3042 /* root window real coords */
3043 event
.xconfigure
.x
= self
->root_pos
.x
;
3044 event
.xconfigure
.y
= self
->root_pos
.y
;
3045 event
.xconfigure
.width
= w
;
3046 event
.xconfigure
.height
= h
;
3047 event
.xconfigure
.border_width
= self
->border_width
;
3048 event
.xconfigure
.above
= None
;
3049 event
.xconfigure
.override_redirect
= FALSE
;
3050 XSendEvent(event
.xconfigure
.display
, event
.xconfigure
.window
,
3051 FALSE
, StructureNotifyMask
, &event
);
3054 /* if the client is shrinking, then resize the frame before the client.
3056 both of these resize sections may run, because the top one only resizes
3057 in the direction that is growing
3059 if (send_resize_client
&& (w
<= oldw
|| h
<= oldh
)) {
3060 frame_adjust_client_area(self
->frame
);
3061 XMoveResizeWindow(obt_display
, self
->window
,
3062 self
->frame
->size
.left
, self
->frame
->size
.top
, w
, h
);
3065 XFlush(obt_display
);
3067 /* if it moved between monitors, then this can affect the stacking
3068 layer of this window or others - for fullscreen windows */
3069 if (screen_find_monitor(&self
->frame
->area
) !=
3070 screen_find_monitor(&oldframe
))
3072 client_calc_layer(self
);
3076 void client_fullscreen(ObClient
*self
, gboolean fs
)
3080 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) || /* can't */
3081 self
->fullscreen
== fs
) return; /* already done */
3083 self
->fullscreen
= fs
;
3084 client_change_state(self
); /* change the state hints on the client */
3087 self
->pre_fullscreen_area
= self
->area
;
3088 /* if the window is maximized, its area isn't all that meaningful.
3089 save its premax area instead. */
3090 if (self
->max_horz
) {
3091 self
->pre_fullscreen_area
.x
= self
->pre_max_area
.x
;
3092 self
->pre_fullscreen_area
.width
= self
->pre_max_area
.width
;
3094 if (self
->max_vert
) {
3095 self
->pre_fullscreen_area
.y
= self
->pre_max_area
.y
;
3096 self
->pre_fullscreen_area
.height
= self
->pre_max_area
.height
;
3099 /* these will help configure_full figure out where to fullscreen
3103 w
= self
->area
.width
;
3104 h
= self
->area
.height
;
3106 g_assert(self
->pre_fullscreen_area
.width
> 0 &&
3107 self
->pre_fullscreen_area
.height
> 0);
3109 x
= self
->pre_fullscreen_area
.x
;
3110 y
= self
->pre_fullscreen_area
.y
;
3111 w
= self
->pre_fullscreen_area
.width
;
3112 h
= self
->pre_fullscreen_area
.height
;
3113 RECT_SET(self
->pre_fullscreen_area
, 0, 0, 0, 0);
3116 ob_debug("Window %s going fullscreen (%d)",
3117 self
->title
, self
->fullscreen
);
3119 client_setup_decor_and_functions(self
, FALSE
);
3120 client_move_resize(self
, x
, y
, w
, h
);
3122 /* and adjust our layer/stacking. do this after resizing the window,
3123 and applying decorations, because windows which fill the screen are
3124 considered "fullscreen" and it affects their layer */
3125 client_calc_layer(self
);
3128 /* try focus us when we go into fullscreen mode */
3133 static void client_iconify_recursive(ObClient
*self
,
3134 gboolean iconic
, gboolean curdesk
,
3135 gboolean hide_animation
)
3138 gboolean changed
= FALSE
;
3140 if (self
->iconic
!= iconic
) {
3141 ob_debug("%sconifying window: 0x%lx", (iconic
? "I" : "Uni"),
3145 /* don't let non-normal windows iconify along with their parents
3147 if (client_normal(self
)) {
3148 self
->iconic
= iconic
;
3150 /* update the focus lists.. iconic windows go to the bottom of
3152 focus_order_to_bottom(self
);
3157 self
->iconic
= iconic
;
3159 if (curdesk
&& self
->desktop
!= screen_desktop
&&
3160 self
->desktop
!= DESKTOP_ALL
)
3161 client_set_desktop(self
, screen_desktop
, FALSE
, FALSE
);
3163 /* this puts it after the current focused window */
3164 focus_order_remove(self
);
3165 focus_order_add_new(self
);
3172 client_change_state(self
);
3173 if (config_animate_iconify
&& !hide_animation
)
3174 frame_begin_iconify_animation(self
->frame
, iconic
);
3175 /* do this after starting the animation so it doesn't flash */
3176 client_showhide(self
);
3179 /* iconify all direct transients, and deiconify all transients
3181 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3182 if (it
->data
!= self
)
3183 if (client_is_direct_child(self
, it
->data
) || !iconic
)
3184 client_iconify_recursive(it
->data
, iconic
, curdesk
,
3188 void client_iconify(ObClient
*self
, gboolean iconic
, gboolean curdesk
,
3189 gboolean hide_animation
)
3191 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
|| !iconic
) {
3192 /* move up the transient chain as far as possible first */
3193 self
= client_search_top_direct_parent(self
);
3194 client_iconify_recursive(self
, iconic
, curdesk
, hide_animation
);
3198 void client_maximize(ObClient
*self
, gboolean max
, gint dir
)
3202 g_assert(dir
== 0 || dir
== 1 || dir
== 2);
3203 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && max
) return;/* can't */
3205 /* check if already done */
3207 if (dir
== 0 && self
->max_horz
&& self
->max_vert
) return;
3208 if (dir
== 1 && self
->max_horz
) return;
3209 if (dir
== 2 && self
->max_vert
) return;
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;
3216 /* these will help configure_full figure out which screen to fill with
3220 w
= self
->area
.width
;
3221 h
= self
->area
.height
;
3224 if ((dir
== 0 || dir
== 1) && !self
->max_horz
) { /* horz */
3225 RECT_SET(self
->pre_max_area
,
3226 self
->area
.x
, self
->pre_max_area
.y
,
3227 self
->area
.width
, self
->pre_max_area
.height
);
3229 if ((dir
== 0 || dir
== 2) && !self
->max_vert
) { /* vert */
3230 RECT_SET(self
->pre_max_area
,
3231 self
->pre_max_area
.x
, self
->area
.y
,
3232 self
->pre_max_area
.width
, self
->area
.height
);
3235 if ((dir
== 0 || dir
== 1) && self
->max_horz
) { /* horz */
3236 g_assert(self
->pre_max_area
.width
> 0);
3238 x
= self
->pre_max_area
.x
;
3239 w
= self
->pre_max_area
.width
;
3241 RECT_SET(self
->pre_max_area
, 0, self
->pre_max_area
.y
,
3242 0, self
->pre_max_area
.height
);
3244 if ((dir
== 0 || dir
== 2) && self
->max_vert
) { /* vert */
3245 g_assert(self
->pre_max_area
.height
> 0);
3247 y
= self
->pre_max_area
.y
;
3248 h
= self
->pre_max_area
.height
;
3250 RECT_SET(self
->pre_max_area
, self
->pre_max_area
.x
, 0,
3251 self
->pre_max_area
.width
, 0);
3255 if (dir
== 0 || dir
== 1) /* horz */
3256 self
->max_horz
= max
;
3257 if (dir
== 0 || dir
== 2) /* vert */
3258 self
->max_vert
= max
;
3260 client_change_state(self
); /* change the state hints on the client */
3262 client_setup_decor_and_functions(self
, FALSE
);
3263 client_move_resize(self
, x
, y
, w
, h
);
3266 void client_shade(ObClient
*self
, gboolean shade
)
3268 if ((!(self
->functions
& OB_CLIENT_FUNC_SHADE
) &&
3269 shade
) || /* can't shade */
3270 self
->shaded
== shade
) return; /* already done */
3272 self
->shaded
= shade
;
3273 client_change_state(self
);
3274 client_change_wm_state(self
); /* the window is being hidden/shown */
3275 /* resize the frame to just the titlebar */
3276 frame_adjust_area(self
->frame
, FALSE
, TRUE
, FALSE
);
3279 static void client_ping_event(ObClient
*self
, gboolean dead
)
3281 if (self
->not_responding
!= dead
) {
3282 self
->not_responding
= dead
;
3283 client_update_title(self
);
3286 /* the client isn't responding, so ask to kill it */
3287 client_prompt_kill(self
);
3289 /* it came back to life ! */
3291 if (self
->kill_prompt
) {
3292 prompt_unref(self
->kill_prompt
);
3293 self
->kill_prompt
= NULL
;
3296 self
->kill_level
= 0;
3301 void client_close(ObClient
*self
)
3303 if (!(self
->functions
& OB_CLIENT_FUNC_CLOSE
)) return;
3305 /* if closing an internal obprompt, that is just cancelling it */
3307 prompt_cancel(self
->prompt
);
3311 /* in the case that the client provides no means to requesting that it
3312 close, we just kill it */
3313 if (!self
->delete_window
)
3314 /* don't use client_kill(), we should only kill based on PID in
3315 response to a lack of PING replies */
3316 XKillClient(obt_display
, self
->window
);
3318 /* request the client to close with WM_DELETE_WINDOW */
3319 OBT_PROP_MSG_TO(self
->window
, self
->window
, WM_PROTOCOLS
,
3320 OBT_PROP_ATOM(WM_DELETE_WINDOW
), event_curtime
,
3321 0, 0, 0, NoEventMask
);
3323 /* we're trying to close the window, so see if it is responding. if it
3324 is not, then we will let them kill the window */
3326 ping_start(self
, client_ping_event
);
3328 /* if we already know the window isn't responding (maybe they clicked
3329 no in the kill dialog but it hasn't come back to life), then show
3331 if (self
->not_responding
)
3332 client_prompt_kill(self
);
3336 #define OB_KILL_RESULT_NO 0
3337 #define OB_KILL_RESULT_YES 1
3339 static gboolean
client_kill_requested(ObPrompt
*p
, gint result
, gpointer data
)
3341 ObClient
*self
= data
;
3343 if (result
== OB_KILL_RESULT_YES
)
3345 return TRUE
; /* call the cleanup func */
3348 static void client_kill_cleanup(ObPrompt
*p
, gpointer data
)
3350 ObClient
*self
= data
;
3352 g_assert(p
== self
->kill_prompt
);
3354 prompt_unref(self
->kill_prompt
);
3355 self
->kill_prompt
= NULL
;
3358 static void client_prompt_kill(ObClient
*self
)
3360 /* check if we're already prompting */
3361 if (!self
->kill_prompt
) {
3362 ObPromptAnswer answers
[] = {
3363 { 0, OB_KILL_RESULT_NO
},
3364 { 0, OB_KILL_RESULT_YES
}
3367 const gchar
*y
, *title
;
3369 title
= self
->original_title
;
3370 if (title
[0] == '\0') {
3371 /* empty string, so use its parent */
3372 ObClient
*p
= client_search_top_direct_parent(self
);
3373 if (p
) title
= p
->original_title
;
3376 if (client_on_localhost(self
)) {
3379 if (self
->kill_level
== 0)
3385 (_("The window \"%s\" does not seem to be responding. Do you want to force it to exit by sending the %s signal?"),
3387 y
= _("End Process");
3391 (_("The window \"%s\" does not seem to be responding. Do you want to disconnect it from the X server?"),
3393 y
= _("Disconnect");
3395 /* set the dialog buttons' text */
3396 answers
[0].text
= _("Cancel"); /* "no" */
3397 answers
[1].text
= y
; /* "yes" */
3399 self
->kill_prompt
= prompt_new(m
, NULL
, answers
,
3400 sizeof(answers
)/sizeof(answers
[0]),
3401 OB_KILL_RESULT_NO
, /* default = no */
3402 OB_KILL_RESULT_NO
, /* cancel = no */
3403 client_kill_requested
,
3404 client_kill_cleanup
,
3409 prompt_show(self
->kill_prompt
, self
, TRUE
);
3412 void client_kill(ObClient
*self
)
3414 /* don't kill our own windows */
3415 if (self
->prompt
) return;
3417 if (client_on_localhost(self
) && self
->pid
) {
3418 /* running on the local host */
3419 if (self
->kill_level
== 0) {
3420 ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
3421 self
->window
, self
->pid
);
3422 kill(self
->pid
, SIGTERM
);
3425 /* show that we're trying to kill it */
3426 client_update_title(self
);
3429 ob_debug("killing window 0x%x with pid %lu, with SIGKILL",
3430 self
->window
, self
->pid
);
3431 kill(self
->pid
, SIGKILL
); /* kill -9 */
3435 /* running on a remote host */
3436 XKillClient(obt_display
, self
->window
);
3440 void client_hilite(ObClient
*self
, gboolean hilite
)
3442 if (self
->demands_attention
== hilite
)
3443 return; /* no change */
3445 /* don't allow focused windows to hilite */
3446 self
->demands_attention
= hilite
&& !client_focused(self
);
3447 if (self
->frame
!= NULL
) { /* if we're mapping, just set the state */
3448 if (self
->demands_attention
) {
3449 frame_flash_start(self
->frame
);
3451 /* if the window is on another desktop then raise it and make it
3452 the most recently used window */
3453 if (self
->desktop
!= screen_desktop
&&
3454 self
->desktop
!= DESKTOP_ALL
)
3456 stacking_raise(CLIENT_AS_WINDOW(self
));
3457 focus_order_to_top(self
);
3461 frame_flash_stop(self
->frame
);
3462 client_change_state(self
);
3466 static void client_set_desktop_recursive(ObClient
*self
,
3474 if (target
!= self
->desktop
&& self
->type
!= OB_CLIENT_TYPE_DESKTOP
) {
3476 ob_debug("Setting desktop %u", target
+1);
3478 g_assert(target
< screen_num_desktops
|| target
== DESKTOP_ALL
);
3480 old
= self
->desktop
;
3481 self
->desktop
= target
;
3482 OBT_PROP_SET32(self
->window
, NET_WM_DESKTOP
, CARDINAL
, target
);
3483 /* the frame can display the current desktop state */
3484 frame_adjust_state(self
->frame
);
3485 /* 'move' the window to the new desktop */
3489 /* raise if it was not already on the desktop */
3490 if (old
!= DESKTOP_ALL
&& !dontraise
)
3491 stacking_raise(CLIENT_AS_WINDOW(self
));
3492 if (STRUT_EXISTS(self
->strut
))
3493 screen_update_areas();
3495 /* the new desktop's geometry may be different, so we may need to
3496 resize, for example if we are maximized */
3497 client_reconfigure(self
, FALSE
);
3500 /* move all transients */
3501 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3502 if (it
->data
!= self
)
3503 if (client_is_direct_child(self
, it
->data
))
3504 client_set_desktop_recursive(it
->data
, target
,
3505 donthide
, dontraise
);
3508 void client_set_desktop(ObClient
*self
, guint target
,
3509 gboolean donthide
, gboolean dontraise
)
3511 self
= client_search_top_direct_parent(self
);
3512 client_set_desktop_recursive(self
, target
, donthide
, dontraise
);
3515 gboolean
client_is_direct_child(ObClient
*parent
, ObClient
*child
)
3517 while (child
!= parent
&& (child
= client_direct_parent(child
)));
3518 return child
== parent
;
3521 ObClient
*client_search_modal_child(ObClient
*self
)
3526 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
3527 ObClient
*c
= it
->data
;
3528 if ((ret
= client_search_modal_child(c
))) return ret
;
3529 if (c
->modal
) return c
;
3534 static gboolean
client_validate_unmap(ObClient
*self
, int n
)
3537 gboolean ret
= TRUE
;
3539 if (XCheckTypedWindowEvent(obt_display
, self
->window
, UnmapNotify
, &e
)) {
3540 if (n
< self
->ignore_unmaps
) // ignore this one, but look for more
3541 ret
= client_validate_unmap(self
, n
+1);
3543 ret
= FALSE
; // the window is going to become unmanaged
3545 /* put them back on the event stack so they end up in the same order */
3546 XPutBackEvent(obt_display
, &e
);
3552 gboolean
client_validate(ObClient
*self
)
3556 XSync(obt_display
, FALSE
); /* get all events on the server */
3558 if (XCheckTypedWindowEvent(obt_display
, self
->window
, DestroyNotify
, &e
)) {
3559 XPutBackEvent(obt_display
, &e
);
3563 if (!client_validate_unmap(self
, 0))
3569 void client_set_wm_state(ObClient
*self
, glong state
)
3571 if (state
== self
->wmstate
) return; /* no change */
3575 client_iconify(self
, TRUE
, TRUE
, FALSE
);
3578 client_iconify(self
, FALSE
, TRUE
, FALSE
);
3583 void client_set_state(ObClient
*self
, Atom action
, glong data1
, glong data2
)
3585 gboolean shaded
= self
->shaded
;
3586 gboolean fullscreen
= self
->fullscreen
;
3587 gboolean undecorated
= self
->undecorated
;
3588 gboolean max_horz
= self
->max_horz
;
3589 gboolean max_vert
= self
->max_vert
;
3590 gboolean modal
= self
->modal
;
3591 gboolean iconic
= self
->iconic
;
3592 gboolean demands_attention
= self
->demands_attention
;
3593 gboolean above
= self
->above
;
3594 gboolean below
= self
->below
;
3598 if (!(action
== OBT_PROP_ATOM(NET_WM_STATE_ADD
) ||
3599 action
== OBT_PROP_ATOM(NET_WM_STATE_REMOVE
) ||
3600 action
== OBT_PROP_ATOM(NET_WM_STATE_TOGGLE
)))
3601 /* an invalid action was passed to the client message, ignore it */
3604 for (i
= 0; i
< 2; ++i
) {
3605 Atom state
= i
== 0 ? data1
: data2
;
3607 if (!state
) continue;
3609 /* if toggling, then pick whether we're adding or removing */
3610 if (action
== OBT_PROP_ATOM(NET_WM_STATE_TOGGLE
)) {
3611 if (state
== OBT_PROP_ATOM(NET_WM_STATE_MODAL
))
3613 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
))
3614 value
= self
->max_vert
;
3615 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
))
3616 value
= self
->max_horz
;
3617 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SHADED
))
3619 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
))
3620 value
= self
->skip_taskbar
;
3621 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
))
3622 value
= self
->skip_pager
;
3623 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
))
3624 value
= self
->iconic
;
3625 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
))
3627 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_ABOVE
))
3628 value
= self
->above
;
3629 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_BELOW
))
3630 value
= self
->below
;
3631 else if (state
== OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
))
3632 value
= self
->demands_attention
;
3633 else if (state
== OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
))
3634 value
= undecorated
;
3636 g_assert_not_reached();
3637 action
= value
? OBT_PROP_ATOM(NET_WM_STATE_REMOVE
) :
3638 OBT_PROP_ATOM(NET_WM_STATE_ADD
);
3641 value
= action
== OBT_PROP_ATOM(NET_WM_STATE_ADD
);
3642 if (state
== OBT_PROP_ATOM(NET_WM_STATE_MODAL
)) {
3644 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_VERT
)) {
3646 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_MAXIMIZED_HORZ
)) {
3648 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SHADED
)) {
3650 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_TASKBAR
)) {
3651 self
->skip_taskbar
= value
;
3652 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_SKIP_PAGER
)) {
3653 self
->skip_pager
= value
;
3654 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_HIDDEN
)) {
3656 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_FULLSCREEN
)) {
3658 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_ABOVE
)) {
3660 /* only unset below when setting above, otherwise you can't get to
3664 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_BELOW
)) {
3665 /* and vice versa */
3669 } else if (state
== OBT_PROP_ATOM(NET_WM_STATE_DEMANDS_ATTENTION
)){
3670 demands_attention
= value
;
3671 } else if (state
== OBT_PROP_ATOM(OB_WM_STATE_UNDECORATED
)) {
3672 undecorated
= value
;
3676 if (max_horz
!= self
->max_horz
|| max_vert
!= self
->max_vert
) {
3677 if (max_horz
!= self
->max_horz
&& max_vert
!= self
->max_vert
) {
3679 if (max_horz
== max_vert
) { /* both going the same way */
3680 client_maximize(self
, max_horz
, 0);
3682 client_maximize(self
, max_horz
, 1);
3683 client_maximize(self
, max_vert
, 2);
3687 if (max_horz
!= self
->max_horz
)
3688 client_maximize(self
, max_horz
, 1);
3690 client_maximize(self
, max_vert
, 2);
3693 /* change fullscreen state before shading, as it will affect if the window
3695 if (fullscreen
!= self
->fullscreen
)
3696 client_fullscreen(self
, fullscreen
);
3697 if (shaded
!= self
->shaded
)
3698 client_shade(self
, shaded
);
3699 if (undecorated
!= self
->undecorated
)
3700 client_set_undecorated(self
, undecorated
);
3701 if (above
!= self
->above
|| below
!= self
->below
) {
3702 self
->above
= above
;
3703 self
->below
= below
;
3704 client_calc_layer(self
);
3707 if (modal
!= self
->modal
) {
3708 self
->modal
= modal
;
3709 /* when a window changes modality, then its stacking order with its
3710 transients needs to change */
3711 stacking_raise(CLIENT_AS_WINDOW(self
));
3713 /* it also may get focused. if something is focused that shouldn't
3714 be focused anymore, then move the focus */
3715 if (focus_client
&& client_focus_target(focus_client
) != focus_client
)
3716 client_focus(focus_client
);
3719 if (iconic
!= self
->iconic
)
3720 client_iconify(self
, iconic
, FALSE
, FALSE
);
3722 if (demands_attention
!= self
->demands_attention
)
3723 client_hilite(self
, demands_attention
);
3725 client_change_state(self
); /* change the hint to reflect these changes */
3728 ObClient
*client_focus_target(ObClient
*self
)
3730 ObClient
*child
= NULL
;
3732 child
= client_search_modal_child(self
);
3733 if (child
) return child
;
3737 gboolean
client_can_focus(ObClient
*self
)
3739 /* choose the correct target */
3740 self
= client_focus_target(self
);
3742 if (!self
->frame
->visible
)
3745 if (!(self
->can_focus
|| self
->focus_notify
))
3751 gboolean
client_focus(ObClient
*self
)
3753 /* we might not focus this window, so if we have modal children which would
3754 be focused instead, bring them to this desktop */
3755 client_bring_modal_windows(self
);
3757 /* choose the correct target */
3758 self
= client_focus_target(self
);
3760 if (!client_can_focus(self
)) {
3761 ob_debug_type(OB_DEBUG_FOCUS
,
3762 "Client %s can't be focused", self
->title
);
3766 ob_debug_type(OB_DEBUG_FOCUS
,
3767 "Focusing client \"%s\" (0x%x) at time %u",
3768 self
->title
, self
->window
, event_curtime
);
3770 /* if using focus_delay, stop the timer now so that focus doesn't
3772 event_halt_focus_delay();
3774 obt_display_ignore_errors(TRUE
);
3776 if (self
->can_focus
) {
3777 /* This can cause a BadMatch error with CurrentTime, or if an app
3778 passed in a bad time for _NET_WM_ACTIVE_WINDOW. */
3779 XSetInputFocus(obt_display
, self
->window
, RevertToPointerRoot
,
3783 if (self
->focus_notify
) {
3785 ce
.xclient
.type
= ClientMessage
;
3786 ce
.xclient
.message_type
= OBT_PROP_ATOM(WM_PROTOCOLS
);
3787 ce
.xclient
.display
= obt_display
;
3788 ce
.xclient
.window
= self
->window
;
3789 ce
.xclient
.format
= 32;
3790 ce
.xclient
.data
.l
[0] = OBT_PROP_ATOM(WM_TAKE_FOCUS
);
3791 ce
.xclient
.data
.l
[1] = event_curtime
;
3792 ce
.xclient
.data
.l
[2] = 0l;
3793 ce
.xclient
.data
.l
[3] = 0l;
3794 ce
.xclient
.data
.l
[4] = 0l;
3795 XSendEvent(obt_display
, self
->window
, FALSE
, NoEventMask
, &ce
);
3798 obt_display_ignore_errors(FALSE
);
3800 ob_debug_type(OB_DEBUG_FOCUS
, "Error focusing? %d",
3801 obt_display_error_occured
);
3802 return !obt_display_error_occured
;
3805 static void client_present(ObClient
*self
, gboolean here
, gboolean raise
,
3808 if (client_normal(self
) && screen_showing_desktop
)
3809 screen_show_desktop(FALSE
, self
);
3811 client_iconify(self
, FALSE
, here
, FALSE
);
3812 if (self
->desktop
!= DESKTOP_ALL
&&
3813 self
->desktop
!= screen_desktop
)
3816 client_set_desktop(self
, screen_desktop
, FALSE
, TRUE
);
3818 screen_set_desktop(self
->desktop
, FALSE
);
3819 } else if (!self
->frame
->visible
)
3820 /* if its not visible for other reasons, then don't mess
3823 if (self
->shaded
&& unshade
)
3824 client_shade(self
, FALSE
);
3826 stacking_raise(CLIENT_AS_WINDOW(self
));
3831 /* this function exists to map to the net_active_window message in the ewmh */
3832 void client_activate(ObClient
*self
, gboolean desktop
,
3833 gboolean here
, gboolean raise
,
3834 gboolean unshade
, gboolean user
)
3836 if ((user
&& (desktop
||
3837 self
->desktop
== DESKTOP_ALL
||
3838 self
->desktop
== screen_desktop
)) ||
3839 client_can_steal_focus(self
, event_curtime
, CurrentTime
))
3841 client_present(self
, here
, raise
, unshade
);
3844 client_hilite(self
, TRUE
);
3847 static void client_bring_windows_recursive(ObClient
*self
,
3855 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
3856 client_bring_windows_recursive(it
->data
, desktop
,
3857 helpers
, modals
, iconic
);
3859 if (((helpers
&& client_helper(self
)) ||
3860 (modals
&& self
->modal
)) &&
3861 ((self
->desktop
!= desktop
&& self
->desktop
!= DESKTOP_ALL
) ||
3862 (iconic
&& self
->iconic
)))
3864 if (iconic
&& self
->iconic
)
3865 client_iconify(self
, FALSE
, TRUE
, FALSE
);
3867 client_set_desktop(self
, desktop
, FALSE
, FALSE
);
3871 void client_bring_helper_windows(ObClient
*self
)
3873 client_bring_windows_recursive(self
, self
->desktop
, TRUE
, FALSE
, FALSE
);
3876 void client_bring_modal_windows(ObClient
*self
)
3878 client_bring_windows_recursive(self
, self
->desktop
, FALSE
, TRUE
, TRUE
);
3881 gboolean
client_focused(ObClient
*self
)
3883 return self
== focus_client
;
3886 RrImage
* client_icon(ObClient
*self
)
3888 RrImage
*ret
= NULL
;
3891 ret
= self
->icon_set
;
3892 else if (self
->parents
) {
3894 for (it
= self
->parents
; it
&& !ret
; it
= g_slist_next(it
))
3895 ret
= client_icon(it
->data
);
3898 ret
= client_default_icon
;
3902 void client_set_layer(ObClient
*self
, gint layer
)
3906 self
->above
= FALSE
;
3907 } else if (layer
== 0) {
3908 self
->below
= self
->above
= FALSE
;
3910 self
->below
= FALSE
;
3913 client_calc_layer(self
);
3914 client_change_state(self
); /* reflect this in the state hints */
3917 void client_set_undecorated(ObClient
*self
, gboolean undecorated
)
3919 if (self
->undecorated
!= undecorated
&&
3920 /* don't let it undecorate if the function is missing, but let
3922 (self
->functions
& OB_CLIENT_FUNC_UNDECORATE
|| !undecorated
))
3924 self
->undecorated
= undecorated
;
3925 client_setup_decor_and_functions(self
, TRUE
);
3926 client_change_state(self
); /* reflect this in the state hints */
3930 guint
client_monitor(ObClient
*self
)
3932 return screen_find_monitor(&self
->frame
->area
);
3935 ObClient
*client_direct_parent(ObClient
*self
)
3937 if (!self
->parents
) return NULL
;
3938 if (self
->transient_for_group
) return NULL
;
3939 return self
->parents
->data
;
3942 ObClient
*client_search_top_direct_parent(ObClient
*self
)
3945 while ((p
= client_direct_parent(self
))) self
= p
;
3949 static GSList
*client_search_all_top_parents_internal(ObClient
*self
,
3951 ObStackingLayer layer
)
3956 /* move up the direct transient chain as far as possible */
3957 while ((p
= client_direct_parent(self
)) &&
3958 (!bylayer
|| p
->layer
== layer
))
3962 ret
= g_slist_prepend(NULL
, self
);
3964 ret
= g_slist_copy(self
->parents
);
3969 GSList
*client_search_all_top_parents(ObClient
*self
)
3971 return client_search_all_top_parents_internal(self
, FALSE
, 0);
3974 GSList
*client_search_all_top_parents_layer(ObClient
*self
)
3976 return client_search_all_top_parents_internal(self
, TRUE
, self
->layer
);
3979 ObClient
*client_search_focus_parent(ObClient
*self
)
3983 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
3984 if (client_focused(it
->data
)) return it
->data
;
3989 ObClient
*client_search_focus_parent_full(ObClient
*self
)
3992 ObClient
*ret
= NULL
;
3994 for (it
= self
->parents
; it
; it
= g_slist_next(it
)) {
3995 if (client_focused(it
->data
))
3998 ret
= client_search_focus_parent_full(it
->data
);
4004 ObClient
*client_search_parent(ObClient
*self
, ObClient
*search
)
4008 for (it
= self
->parents
; it
; it
= g_slist_next(it
))
4009 if (it
->data
== search
) return search
;
4014 ObClient
*client_search_transient(ObClient
*self
, ObClient
*search
)
4018 for (sit
= self
->transients
; sit
; sit
= g_slist_next(sit
)) {
4019 if (sit
->data
== search
)
4021 if (client_search_transient(sit
->data
, search
))
4027 static void detect_edge(Rect area
, ObDirection dir
,
4028 gint my_head
, gint my_size
,
4029 gint my_edge_start
, gint my_edge_size
,
4030 gint
*dest
, gboolean
*near_edge
)
4032 gint edge_start
, edge_size
, head
, tail
;
4033 gboolean skip_head
= FALSE
, skip_tail
= FALSE
;
4036 case OB_DIRECTION_NORTH
:
4037 case OB_DIRECTION_SOUTH
:
4038 edge_start
= area
.x
;
4039 edge_size
= area
.width
;
4041 case OB_DIRECTION_EAST
:
4042 case OB_DIRECTION_WEST
:
4043 edge_start
= area
.y
;
4044 edge_size
= area
.height
;
4047 g_assert_not_reached();
4050 /* do we collide with this window? */
4051 if (!RANGES_INTERSECT(my_edge_start
, my_edge_size
,
4052 edge_start
, edge_size
))
4056 case OB_DIRECTION_NORTH
:
4057 head
= RECT_BOTTOM(area
);
4058 tail
= RECT_TOP(area
);
4060 case OB_DIRECTION_SOUTH
:
4061 head
= RECT_TOP(area
);
4062 tail
= RECT_BOTTOM(area
);
4064 case OB_DIRECTION_WEST
:
4065 head
= RECT_RIGHT(area
);
4066 tail
= RECT_LEFT(area
);
4068 case OB_DIRECTION_EAST
:
4069 head
= RECT_LEFT(area
);
4070 tail
= RECT_RIGHT(area
);
4073 g_assert_not_reached();
4076 case OB_DIRECTION_NORTH
:
4077 case OB_DIRECTION_WEST
:
4078 /* check if our window is past the head of this window */
4079 if (my_head
<= head
+ 1)
4081 /* check if our window's tail is past the tail of this window */
4082 if (my_head
+ my_size
- 1 <= tail
)
4084 /* check if the head of this window is closer than the previously
4085 chosen edge (take into account that the previously chosen
4086 edge might have been a tail, not a head) */
4087 if (head
+ (*near_edge
? 0 : my_size
) <= *dest
)
4089 /* check if the tail of this window is closer than the previously
4090 chosen edge (take into account that the previously chosen
4091 edge might have been a head, not a tail) */
4092 if (tail
- (!*near_edge
? 0 : my_size
) <= *dest
)
4095 case OB_DIRECTION_SOUTH
:
4096 case OB_DIRECTION_EAST
:
4097 /* check if our window is past the head of this window */
4098 if (my_head
>= head
- 1)
4100 /* check if our window's tail is past the tail of this window */
4101 if (my_head
- my_size
+ 1 >= tail
)
4103 /* check if the head of this window is closer than the previously
4104 chosen edge (take into account that the previously chosen
4105 edge might have been a tail, not a head) */
4106 if (head
- (*near_edge
? 0 : my_size
) >= *dest
)
4108 /* check if the tail of this window is closer than the previously
4109 chosen edge (take into account that the previously chosen
4110 edge might have been a head, not a tail) */
4111 if (tail
+ (!*near_edge
? 0 : my_size
) >= *dest
)
4115 g_assert_not_reached();
4118 ob_debug("my head %d size %d", my_head
, my_size
);
4119 ob_debug("head %d tail %d dest %d", head
, tail
, *dest
);
4121 ob_debug("using near edge %d", head
);
4125 else if (!skip_tail
) {
4126 ob_debug("using far edge %d", tail
);
4132 void client_find_edge_directional(ObClient
*self
, ObDirection dir
,
4133 gint my_head
, gint my_size
,
4134 gint my_edge_start
, gint my_edge_size
,
4135 gint
*dest
, gboolean
*near_edge
)
4143 a
= screen_area(self
->desktop
, SCREEN_AREA_ALL_MONITORS
,
4144 &self
->frame
->area
);
4147 case OB_DIRECTION_NORTH
:
4148 edge
= RECT_TOP(*a
) - 1;
4150 case OB_DIRECTION_SOUTH
:
4151 edge
= RECT_BOTTOM(*a
) + 1;
4153 case OB_DIRECTION_EAST
:
4154 edge
= RECT_RIGHT(*a
) + 1;
4156 case OB_DIRECTION_WEST
:
4157 edge
= RECT_LEFT(*a
) - 1;
4160 g_assert_not_reached();
4162 /* default to the far edge, then narrow it down */
4166 /* search for edges of monitors */
4167 for (i
= 0; i
< screen_num_monitors
; ++i
) {
4168 Rect
*area
= screen_area(self
->desktop
, i
, NULL
);
4169 detect_edge(*area
, dir
, my_head
, my_size
, my_edge_start
,
4170 my_edge_size
, dest
, near_edge
);
4174 /* search for edges of clients */
4175 for (it
= client_list
; it
; it
= g_list_next(it
)) {
4176 ObClient
*cur
= it
->data
;
4178 /* skip windows to not bump into */
4183 if (self
->desktop
!= cur
->desktop
&& cur
->desktop
!= DESKTOP_ALL
&&
4184 cur
->desktop
!= screen_desktop
)
4187 ob_debug("trying window %s", cur
->title
);
4189 detect_edge(cur
->frame
->area
, dir
, my_head
, my_size
, my_edge_start
,
4190 my_edge_size
, dest
, near_edge
);
4192 dock_get_area(&dock_area
);
4193 detect_edge(dock_area
, dir
, my_head
, my_size
, my_edge_start
,
4194 my_edge_size
, dest
, near_edge
);
4198 void client_find_move_directional(ObClient
*self
, ObDirection dir
,
4202 gint e
, e_start
, e_size
;
4206 case OB_DIRECTION_EAST
:
4207 head
= RECT_RIGHT(self
->frame
->area
);
4208 size
= self
->frame
->area
.width
;
4209 e_start
= RECT_TOP(self
->frame
->area
);
4210 e_size
= self
->frame
->area
.height
;
4212 case OB_DIRECTION_WEST
:
4213 head
= RECT_LEFT(self
->frame
->area
);
4214 size
= self
->frame
->area
.width
;
4215 e_start
= RECT_TOP(self
->frame
->area
);
4216 e_size
= self
->frame
->area
.height
;
4218 case OB_DIRECTION_NORTH
:
4219 head
= RECT_TOP(self
->frame
->area
);
4220 size
= self
->frame
->area
.height
;
4221 e_start
= RECT_LEFT(self
->frame
->area
);
4222 e_size
= self
->frame
->area
.width
;
4224 case OB_DIRECTION_SOUTH
:
4225 head
= RECT_BOTTOM(self
->frame
->area
);
4226 size
= self
->frame
->area
.height
;
4227 e_start
= RECT_LEFT(self
->frame
->area
);
4228 e_size
= self
->frame
->area
.width
;
4231 g_assert_not_reached();
4234 client_find_edge_directional(self
, dir
, head
, size
,
4235 e_start
, e_size
, &e
, &near
);
4236 *x
= self
->frame
->area
.x
;
4237 *y
= self
->frame
->area
.y
;
4239 case OB_DIRECTION_EAST
:
4240 if (near
) e
-= self
->frame
->area
.width
;
4244 case OB_DIRECTION_WEST
:
4246 else e
-= self
->frame
->area
.width
;
4249 case OB_DIRECTION_NORTH
:
4251 else e
-= self
->frame
->area
.height
;
4254 case OB_DIRECTION_SOUTH
:
4255 if (near
) e
-= self
->frame
->area
.height
;
4260 g_assert_not_reached();
4262 frame_frame_gravity(self
->frame
, x
, y
);
4265 void client_find_resize_directional(ObClient
*self
, ObDirection side
,
4267 gint
*x
, gint
*y
, gint
*w
, gint
*h
)
4270 gint e
, e_start
, e_size
, delta
;
4275 case OB_DIRECTION_EAST
:
4276 head
= RECT_RIGHT(self
->frame
->area
) +
4277 (self
->size_inc
.width
- 1) * (grow
? 1 : 0);
4278 e_start
= RECT_TOP(self
->frame
->area
);
4279 e_size
= self
->frame
->area
.height
;
4280 dir
= grow
? OB_DIRECTION_EAST
: OB_DIRECTION_WEST
;
4282 case OB_DIRECTION_WEST
:
4283 head
= RECT_LEFT(self
->frame
->area
) -
4284 (self
->size_inc
.width
- 1) * (grow
? 1 : 0);
4285 e_start
= RECT_TOP(self
->frame
->area
);
4286 e_size
= self
->frame
->area
.height
;
4287 dir
= grow
? OB_DIRECTION_WEST
: OB_DIRECTION_EAST
;
4289 case OB_DIRECTION_NORTH
:
4290 head
= RECT_TOP(self
->frame
->area
) -
4291 (self
->size_inc
.height
- 1) * (grow
? 1 : 0);
4292 e_start
= RECT_LEFT(self
->frame
->area
);
4293 e_size
= self
->frame
->area
.width
;
4294 dir
= grow
? OB_DIRECTION_NORTH
: OB_DIRECTION_SOUTH
;
4296 case OB_DIRECTION_SOUTH
:
4297 head
= RECT_BOTTOM(self
->frame
->area
) +
4298 (self
->size_inc
.height
- 1) * (grow
? 1 : 0);
4299 e_start
= RECT_LEFT(self
->frame
->area
);
4300 e_size
= self
->frame
->area
.width
;
4301 dir
= grow
? OB_DIRECTION_SOUTH
: OB_DIRECTION_NORTH
;
4304 g_assert_not_reached();
4307 ob_debug("head %d dir %d", head
, dir
);
4308 client_find_edge_directional(self
, dir
, head
, 1,
4309 e_start
, e_size
, &e
, &near
);
4310 ob_debug("edge %d", e
);
4311 *x
= self
->frame
->area
.x
;
4312 *y
= self
->frame
->area
.y
;
4313 *w
= self
->frame
->area
.width
;
4314 *h
= self
->frame
->area
.height
;
4316 case OB_DIRECTION_EAST
:
4317 if (grow
== near
) --e
;
4318 delta
= e
- RECT_RIGHT(self
->frame
->area
);
4321 case OB_DIRECTION_WEST
:
4322 if (grow
== near
) ++e
;
4323 delta
= RECT_LEFT(self
->frame
->area
) - e
;
4327 case OB_DIRECTION_NORTH
:
4328 if (grow
== near
) ++e
;
4329 delta
= RECT_TOP(self
->frame
->area
) - e
;
4333 case OB_DIRECTION_SOUTH
:
4334 if (grow
== near
) --e
;
4335 delta
= e
- RECT_BOTTOM(self
->frame
->area
);
4339 g_assert_not_reached();
4341 frame_frame_gravity(self
->frame
, x
, y
);
4342 *w
-= self
->frame
->size
.left
+ self
->frame
->size
.right
;
4343 *h
-= self
->frame
->size
.top
+ self
->frame
->size
.bottom
;
4346 ObClient
* client_under_pointer(void)
4350 ObClient
*ret
= NULL
;
4352 if (screen_pointer_pos(&x
, &y
)) {
4353 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
4354 if (WINDOW_IS_CLIENT(it
->data
)) {
4355 ObClient
*c
= WINDOW_AS_CLIENT(it
->data
);
4356 if (c
->frame
->visible
&&
4357 /* check the desktop, this is done during desktop
4358 switching and windows are shown/hidden status is not
4360 (c
->desktop
== screen_desktop
||
4361 c
->desktop
== DESKTOP_ALL
) &&
4362 /* ignore all animating windows */
4363 !frame_iconify_animating(c
->frame
) &&
4364 RECT_CONTAINS(c
->frame
->area
, x
, y
))
4375 gboolean
client_has_group_siblings(ObClient
*self
)
4377 return self
->group
&& self
->group
->members
->next
;
4380 /*! Returns TRUE if the client is running on the same machine as Openbox */
4381 gboolean
client_on_localhost(ObClient
*self
)
4383 return self
->client_machine
== NULL
;