From 9e9a7e124d1a80579281c5ab2ffc3574f38f9eba Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 11 Jan 2008 09:46:07 -0500 Subject: allow dialog windows to be fullscreened, kpdf does this --- openbox/client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index d0fed545..1e2040fd 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1634,11 +1634,16 @@ void client_setup_decor_and_functions(ObClient *self, gboolean reconfig) switch (self->type) { case OB_CLIENT_TYPE_NORMAL: /* normal windows retain all of the possible decorations and - functionality, and are the only windows that you can fullscreen */ + functionality, and can be fullscreen */ self->functions |= OB_CLIENT_FUNC_FULLSCREEN; break; case OB_CLIENT_TYPE_DIALOG: + /* sometimes apps make dialog windows fullscreen for some reason (for + e.g. kpdf does this..) */ + self->functions |= OB_CLIENT_FUNC_FULLSCREEN; + break; + case OB_CLIENT_TYPE_UTILITY: /* these windows don't have anything added or removed by default */ break; -- cgit v1.2.3 From 6dfc3c726a2164ba70cfac3df436ee035822bdb1 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 13 Jan 2008 03:40:14 -0500 Subject: don't skip windows that are skip_taskbar unless they are normal typed.. i.e. if a dialog sets this don't skip it (gnome shutdown/logout dialogs don't get focused otherwise in arch linux) --- openbox/client.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 1e2040fd..22eb8403 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -450,6 +450,8 @@ void client_manage(Window window) g_free(monitor); monitor = NULL; + ob_debug_type(OB_DEBUG_FOCUS, "Going to try activate new window? %s\n", + activate ? "yes" : "no"); if (activate) { gboolean raise = FALSE; -- cgit v1.2.3 From ed51baa95808ad0235e30d3c5215deca4b9faa6b Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 19:36:36 -0500 Subject: remove the visible window title hints when unmanaging a window. not all WMs set those and it messes them up, and we'll set them again appropriately, they don't need to be saved. --- openbox/client.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 22eb8403..5e4e52e7 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -762,6 +762,11 @@ void client_unmanage(ObClient *self) XMapWindow(ob_display, self->window); } + /* these should not be left on the window ever. other window managers + don't necessarily use them and it will mess them up (like compiz) */ + PROP_ERASE(self->window, net_wm_visible_name); + PROP_ERASE(self->window, net_wm_visible_icon_name); + /* update the list hints */ client_set_list(); -- cgit v1.2.3 From d790dc162d24cfdcc236114b50c51af62612646a Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 20:48:28 -0500 Subject: check if a client will respond to pings --- openbox/client.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 5e4e52e7..7019f690 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1507,6 +1507,10 @@ void client_update_protocols(ObClient *self) /* if this protocol is requested, then the window will be notified whenever we want it to receive focus */ self->focus_notify = TRUE; + else if (proto[i] == prop_atoms.net_wm_ping) + /* if this protocol is requested, then the window will allow + pings to determine if it is still alive */ + self->ping = TRUE; #ifdef SYNC else if (proto[i] == prop_atoms.net_wm_sync_request) /* if this protocol is requested, then resizing the -- cgit v1.2.3 From fb7a71da202632c7301ada67c8b4420bfb8d8fbe Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 21:40:15 -0500 Subject: can tell when a window that was "closed" has stopped responding now --- openbox/client.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 7019f690..0f592ebe 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3166,10 +3166,16 @@ void client_shade(ObClient *self, gboolean shade) frame_adjust_area(self->frame, FALSE, TRUE, FALSE); } -void client_close(ObClient *self) +static void client_ping_event(ObClient *self, gboolean dead) { - XEvent ce; + if (dead) + ob_debug("client 0x%x window 0x%x is not responding !!\n"); + else + ob_debug("client 0x%x window 0x%x started responding again..\n"); +} +void client_close(ObClient *self) +{ if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return; /* in the case that the client provides no means to requesting that it @@ -3185,17 +3191,11 @@ void client_close(ObClient *self) explicitly killed. */ - ce.xclient.type = ClientMessage; - ce.xclient.message_type = prop_atoms.wm_protocols; - ce.xclient.display = ob_display; - ce.xclient.window = self->window; - ce.xclient.format = 32; - ce.xclient.data.l[0] = prop_atoms.wm_delete_window; - ce.xclient.data.l[1] = event_curtime; - ce.xclient.data.l[2] = 0l; - ce.xclient.data.l[3] = 0l; - ce.xclient.data.l[4] = 0l; - XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce); + PROP_MSG_TO(self->window, self->window, wm_protocols, + prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, + NoEventMask); + + ping_start(self, client_ping_event); } void client_kill(ObClient *self) -- cgit v1.2.3 From d3e9fc8941831477b50678b9bd676e29f4bed1a7 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 21:57:47 -0500 Subject: show [Not Responding] in the titlebar when closing an app and it stops responding to pings --- openbox/client.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 0f592ebe..a4d045dc 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -40,6 +40,7 @@ #include "keyboard.h" #include "mouse.h" #include "render/render.h" +#include "gettext.h" #ifdef HAVE_UNISTD_H # include @@ -93,6 +94,7 @@ static GSList *client_search_all_top_parents_internal(ObClient *self, gboolean bylayer, ObStackingLayer layer); static void client_call_notifies(ObClient *self, GSList *list); +static void client_ping_event(ObClient *self, gboolean dead); void client_startup(gboolean reconfig) @@ -1947,6 +1949,12 @@ void client_update_title(ObClient *self) } else visible = data; + if (self->not_responding) { + data = visible; + visible = g_strdup_printf("%s - [%s]", data, _("Not Responding")); + g_free(data); + } + PROP_SETS(self->window, net_wm_visible_name, visible); self->title = visible; @@ -1970,6 +1978,12 @@ void client_update_title(ObClient *self) } else visible = data; + if (self->not_responding) { + data = visible; + visible = g_strdup_printf("%s - [%s]", data, _("Not Responding")); + g_free(data); + } + PROP_SETS(self->window, net_wm_visible_icon_name, visible); self->icon_title = visible; } @@ -3168,10 +3182,8 @@ void client_shade(ObClient *self, gboolean shade) static void client_ping_event(ObClient *self, gboolean dead) { - if (dead) - ob_debug("client 0x%x window 0x%x is not responding !!\n"); - else - ob_debug("client 0x%x window 0x%x started responding again..\n"); + self->not_responding = dead; + client_update_title(self); } void client_close(ObClient *self) @@ -3195,7 +3207,8 @@ void client_close(ObClient *self) prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, NoEventMask); - ping_start(self, client_ping_event); + if (self->ping) + ping_start(self, client_ping_event); } void client_kill(ObClient *self) -- cgit v1.2.3 From 07994cb2dcafe33db99da5f7234caefdc0baa809 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:00:21 -0500 Subject: when you close a window that you already tried to close and its not responding to pings, then do a kill the next time --- openbox/client.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index a4d045dc..517482c7 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3195,20 +3195,16 @@ void client_close(ObClient *self) if (!self->delete_window) client_kill(self); - /* - XXX: itd be cool to do timeouts and shit here for killing the client's - process off - like... if the window is around after 5 seconds, then the close button - turns a nice red, and if this function is called again, the client is - explicitly killed. - */ - - PROP_MSG_TO(self->window, self->window, wm_protocols, - prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, - NoEventMask); + if (self->not_responding) + client_kill(self); + else { + PROP_MSG_TO(self->window, self->window, wm_protocols, + prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, + NoEventMask); - if (self->ping) - ping_start(self, client_ping_event); + if (self->ping) + ping_start(self, client_ping_event); + } } void client_kill(ObClient *self) -- cgit v1.2.3 From e6d33facc8f02a068f62b4f60c2872589b620dab Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:13:16 -0500 Subject: when you close an app and it stops responding.. if you hit close again, it will try kill -TERM. if that fails and you close again, it will kill -9 ! (assuming the app is running on the local host and provided its PID) --- openbox/client.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 517482c7..d768ecc1 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -46,6 +46,10 @@ # include #endif +#ifdef HAVE_SIGNAL_H +# include /* for kill() */ +#endif + #include #include @@ -2244,6 +2248,7 @@ static void client_get_session_ids(ObClient *self) if (got) { gchar localhost[128]; + guint32 pid; gethostname(localhost, 127); localhost[127] = '\0'; @@ -2251,6 +2256,11 @@ static void client_get_session_ids(ObClient *self) self->client_machine = s; else g_free(s); + + /* see if it has the PID set too (the PID requires that the + WM_CLIENT_MACHINE be set) */ + if (PROP_GET32(self->window, net_wm_pid, cardinal, &pid)) + self->pid = pid; } } @@ -3193,9 +3203,10 @@ void client_close(ObClient *self) /* in the case that the client provides no means to requesting that it close, we just kill it */ if (!self->delete_window) - client_kill(self); - - if (self->not_responding) + /* don't use client_kill(), we should only kill based on PID in + response to a lack of PING replies */ + XKillClient(ob_display, self->window); + else if (self->not_responding) client_kill(self); else { PROP_MSG_TO(self->window, self->window, wm_protocols, @@ -3209,7 +3220,17 @@ void client_close(ObClient *self) void client_kill(ObClient *self) { - XKillClient(ob_display, self->window); + if (!self->client_machine && self->pid) { + /* running on the local host */ + if (!self->kill_tried_term) { + kill(self->pid, SIGTERM); + self->kill_tried_term = TRUE; + } + else + kill(self->pid, SIGKILL); /* kill -9 */ + } + else + XKillClient(ob_display, self->window); } void client_hilite(ObClient *self, gboolean hilite) -- cgit v1.2.3 From dbce9ee24320baa01e62d88485fb536c8d9a5e55 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:15:45 -0500 Subject: its possible we did kill -TERM and it stayed alive and started responding again, so handle that case --- openbox/client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index d768ecc1..5443b158 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3213,8 +3213,13 @@ void client_close(ObClient *self) prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, NoEventMask); - if (self->ping) + if (self->ping) { + /* may have tried to kill it earlier but the window is still + around and started responding again */ + self->kill_tried_term = FALSE; + ping_start(self, client_ping_event); + } } } -- cgit v1.2.3 From 810afd8597da355039e289218abed6c062585870 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:34:04 -0500 Subject: ping all the windows every 3 seconds, and show "not responding" if they stop replying for 3 times (9-12 seconds). show [Killing...] in the titlebar when trying to kill an app off --- openbox/client.c | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 5443b158..85f5e691 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -602,6 +602,9 @@ void client_manage(Window window) /* update the list hints */ client_set_list(); + /* watch for when the application stops responding */ + if (self->ping) ping_start(self, client_ping_event); + /* free the ObAppSettings shallow copy */ g_free(settings); @@ -683,6 +686,9 @@ void client_unmanage(ObClient *self) /* remove the window from our save set */ XChangeSaveSet(ob_display, self->window, SetModeDelete); + /* stop pinging the window */ + if (self->ping) ping_stop(self); + /* update the focus lists */ focus_order_remove(self); if (client_focused(self)) { @@ -1955,7 +1961,10 @@ void client_update_title(ObClient *self) if (self->not_responding) { data = visible; - visible = g_strdup_printf("%s - [%s]", data, _("Not Responding")); + if (self->close_tried_term) + visible = g_strdup_printf("%s - [%s]", data, _("Killing...")); + else + visible = g_strdup_printf("%s - [%s]", data, _("Not Responding")); g_free(data); } @@ -1984,7 +1993,10 @@ void client_update_title(ObClient *self) if (self->not_responding) { data = visible; - visible = g_strdup_printf("%s - [%s]", data, _("Not Responding")); + if (self->close_tried_term) + visible = g_strdup_printf("%s - [%s]", data, _("Killing...")); + else + visible = g_strdup_printf("%s - [%s]", data, _("Not Responding")); g_free(data); } @@ -3194,6 +3206,14 @@ static void client_ping_event(ObClient *self, gboolean dead) { self->not_responding = dead; client_update_title(self); + + if (!dead) { + /* the window has started responding again, so don't kill it the first + time they click on close, even if it stops responding again in the + future */ + self->close_tried_destroy = FALSE; + self->close_tried_term = FALSE; + } } void client_close(ObClient *self) @@ -3206,20 +3226,14 @@ void client_close(ObClient *self) /* don't use client_kill(), we should only kill based on PID in response to a lack of PING replies */ XKillClient(ob_display, self->window); - else if (self->not_responding) + else if (self->not_responding && self->close_tried_destroy) client_kill(self); else { PROP_MSG_TO(self->window, self->window, wm_protocols, prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, NoEventMask); - - if (self->ping) { - /* may have tried to kill it earlier but the window is still - around and started responding again */ - self->kill_tried_term = FALSE; - - ping_start(self, client_ping_event); - } + self->close_tried_destroy = TRUE; + self->close_tried_term = FALSE; } } @@ -3227,12 +3241,20 @@ void client_kill(ObClient *self) { if (!self->client_machine && self->pid) { /* running on the local host */ - if (!self->kill_tried_term) { + if (!self->close_tried_term) { + ob_debug("killing window 0x%x with pid %lu, with SIGTERM\n", + self->window, self->pid); kill(self->pid, SIGTERM); - self->kill_tried_term = TRUE; + self->close_tried_term = TRUE; + + /* show that we're trying to kill it */ + client_update_title(self); } - else + else { + ob_debug("killing window 0x%x with pid %lu, with SIGKILL\n", + self->window, self->pid); kill(self->pid, SIGKILL); /* kill -9 */ + } } else XKillClient(ob_display, self->window); -- cgit v1.2.3 From d5c824cfd4ec84155772a5c482b0ffdc99dc1ab9 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:36:45 -0500 Subject: only ping windows that we need to --- openbox/client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 85f5e691..1f7ce97b 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -602,8 +602,11 @@ void client_manage(Window window) /* update the list hints */ client_set_list(); - /* watch for when the application stops responding */ - if (self->ping) ping_start(self, client_ping_event); + /* watch for when the application stops responding. only do this for + normal windows, i.e. windows which have titlebars and close buttons + and things like that */ + if (self->ping && client_normal(self)) + ping_start(self, client_ping_event); /* free the ObAppSettings shallow copy */ g_free(settings); @@ -687,7 +690,8 @@ void client_unmanage(ObClient *self) XChangeSaveSet(ob_display, self->window, SetModeDelete); /* stop pinging the window */ - if (self->ping) ping_stop(self); + if (self->ping && client_normal(self)) + ping_stop(self); /* update the focus lists */ focus_order_remove(self); -- cgit v1.2.3 From f9f32d9fbaae9ca415603bb61b36393994afbd16 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:51:04 -0500 Subject: cant consistently tell if we should use WM_DESTROY after the first time they try close a window.. so just kill when "not responding" is showing --- openbox/client.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 1f7ce97b..2f8f58a9 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3212,10 +3212,8 @@ static void client_ping_event(ObClient *self, gboolean dead) client_update_title(self); if (!dead) { - /* the window has started responding again, so don't kill it the first - time they click on close, even if it stops responding again in the - future */ - self->close_tried_destroy = FALSE; + /* try kill it nicely the first time again, if it started responding + at some point */ self->close_tried_term = FALSE; } } @@ -3230,14 +3228,12 @@ void client_close(ObClient *self) /* don't use client_kill(), we should only kill based on PID in response to a lack of PING replies */ XKillClient(ob_display, self->window); - else if (self->not_responding && self->close_tried_destroy) + else if (self->not_responding) client_kill(self); else { PROP_MSG_TO(self->window, self->window, wm_protocols, prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, NoEventMask); - self->close_tried_destroy = TRUE; - self->close_tried_term = FALSE; } } -- cgit v1.2.3 From 053558dc5ffa7f561d06cfd43926e19b4d4da422 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 15 Jan 2008 22:53:05 -0500 Subject: add a comment --- openbox/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 2f8f58a9..c90c39bf 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3230,11 +3230,11 @@ void client_close(ObClient *self) XKillClient(ob_display, self->window); else if (self->not_responding) client_kill(self); - else { + else + /* request the client to close with WM_DELETE_WINDOW */ PROP_MSG_TO(self->window, self->window, wm_protocols, prop_atoms.wm_delete_window, event_curtime, 0, 0, 0, NoEventMask); - } } void client_kill(ObClient *self) -- cgit v1.2.3 From 0be98fee4743c795b06aa23881b82eff5bab3ef6 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 16 Jan 2008 15:25:08 +0100 Subject: Various fixes for sparse warnings. Define void functions with (void), not (). Add missing includes. Some functions were declared static but defined non-static. Some variables that should be file static were file global but not used in any other file. prop.h defined a new prop_atoms in each file that included it instead of declaring it extern. --- openbox/client.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index c90c39bf..6a6ec2bd 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -24,6 +24,7 @@ #include "xerror.h" #include "screen.h" #include "moveresize.h" +#include "ping.h" #include "place.h" #include "prop.h" #include "extensions.h" @@ -79,6 +80,10 @@ static void client_get_state(ObClient *self); static void client_get_shaped(ObClient *self); static void client_get_mwm_hints(ObClient *self); static void client_get_colormap(ObClient *self); +static void client_set_desktop_recursive(ObClient *self, + guint target, + gboolean donthide, + gboolean dontraise); static void client_change_allowed_actions(ObClient *self); static void client_change_state(ObClient *self); static void client_change_wm_state(ObClient *self); @@ -1551,7 +1556,7 @@ void client_update_sync_request_counter(ObClient *self) } #endif -void client_get_colormap(ObClient *self) +static void client_get_colormap(ObClient *self) { XWindowAttributes wa; @@ -3276,10 +3281,10 @@ void client_hilite(ObClient *self, gboolean hilite) } } -void client_set_desktop_recursive(ObClient *self, - guint target, - gboolean donthide, - gboolean dontraise) +static void client_set_desktop_recursive(ObClient *self, + guint target, + gboolean donthide, + gboolean dontraise) { guint old; GSList *it; -- cgit v1.2.3 From cccc57fdb04b2e5602254f1eb623acc95f9a032e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 16 Jan 2008 19:21:42 -0500 Subject: make the ping hash tables work correctly. don't need to stop pinging, it will automatically. and not all windows get pings, even tho we get notified that they are being destroyed --- openbox/client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 6a6ec2bd..63245a3c 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -609,7 +609,10 @@ void client_manage(Window window) /* watch for when the application stops responding. only do this for normal windows, i.e. windows which have titlebars and close buttons - and things like that */ + and things like that. + we don't need to stop pinging on unmanage, because it will be handled + automatically by the destroy callback! + */ if (self->ping && client_normal(self)) ping_start(self, client_ping_event); @@ -694,10 +697,6 @@ void client_unmanage(ObClient *self) /* remove the window from our save set */ XChangeSaveSet(ob_display, self->window, SetModeDelete); - /* stop pinging the window */ - if (self->ping && client_normal(self)) - ping_stop(self); - /* update the focus lists */ focus_order_remove(self); if (client_focused(self)) { -- cgit v1.2.3