X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=20ccfe3d22cb1b399f18616cd5318707447b858b;hb=32a92abf7578ea93d85741b7c89a0958082aa9ee;hp=5443b158a4843e0f34532266cd4a41c0aa2c30a1;hpb=dbce9ee24320baa01e62d88485fb536c8d9a5e55;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index 5443b158..20ccfe3d 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -21,12 +21,11 @@ #include "debug.h" #include "startupnotify.h" #include "dock.h" -#include "xerror.h" #include "screen.h" #include "moveresize.h" +#include "ping.h" #include "place.h" #include "prop.h" -#include "extensions.h" #include "frame.h" #include "session.h" #include "event.h" @@ -41,6 +40,7 @@ #include "mouse.h" #include "render/render.h" #include "gettext.h" +#include "obt/display.h" #ifdef HAVE_UNISTD_H # include @@ -79,6 +79,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); @@ -602,6 +606,15 @@ void client_manage(Window window) /* update the list hints */ client_set_list(); + /* 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. + 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); + /* free the ObAppSettings shallow copy */ g_free(settings); @@ -1248,7 +1261,7 @@ static void client_get_shaped(ObClient *self) { self->shaped = FALSE; #ifdef SHAPE - if (extensions_shape) { + if (obt_display_extension_shape) { gint foo; guint ufoo; gint s; @@ -1541,7 +1554,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; @@ -1955,7 +1968,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 +2000,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); } @@ -2104,7 +2123,7 @@ void client_update_icons(ObClient *self) if (hints->flags & IconPixmapHint) { self->nicons = 1; self->icons = g_new(ObClientIcon, self->nicons); - xerror_set_ignore(TRUE); + obt_display_ignore_errors(ob_display, TRUE); if (!RrPixmapToRGBA(ob_rr_inst, hints->icon_pixmap, (hints->flags & IconMaskHint ? @@ -2116,7 +2135,7 @@ void client_update_icons(ObClient *self) g_free(self->icons); self->nicons = 0; } - xerror_set_ignore(FALSE); + obt_display_ignore_errors(ob_display, FALSE); } XFree(hints); } @@ -3194,6 +3213,12 @@ static void client_ping_event(ObClient *self, gboolean dead) { self->not_responding = dead; client_update_title(self); + + if (!dead) { + /* try kill it nicely the first time again, if it started responding + at some point */ + self->close_tried_term = FALSE; + } } void client_close(ObClient *self) @@ -3208,31 +3233,31 @@ 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); - - 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); - } - } } 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); @@ -3254,10 +3279,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; @@ -3586,8 +3611,7 @@ gboolean client_focus(ObClient *self) */ event_cancel_all_key_grabs(); - xerror_set_ignore(TRUE); - xerror_occured = FALSE; + obt_display_ignore_errors(ob_display, TRUE); if (self->can_focus) { /* This can cause a BadMatch error with CurrentTime, or if an app @@ -3611,10 +3635,11 @@ gboolean client_focus(ObClient *self) XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce); } - xerror_set_ignore(FALSE); + obt_display_ignore_errors(ob_display, FALSE); - ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", xerror_occured); - return !xerror_occured; + ob_debug_type(OB_DEBUG_FOCUS, "Error focusing? %d\n", + obt_display_error_occured); + return !obt_display_error_occured; } static void client_present(ObClient *self, gboolean here, gboolean raise,