]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
draw a box inside the key-focused button in an ObPrompt. also fix rendering the...
[chaz/openbox] / openbox / client.c
index 98ad7de292b2b5ca9d83bd1bfc092955d49a6853..62489c1d86af20b5e07fd4e30e46d2d49905aeae 100644 (file)
@@ -619,15 +619,6 @@ void client_manage(Window window, ObPrompt *prompt)
     /* 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);
 
@@ -820,6 +811,7 @@ void client_unmanage(ObClient *self)
     g_free(self->wm_command);
     g_free(self->title);
     g_free(self->icon_title);
+    g_free(self->original_title);
     g_free(self->name);
     g_free(self->class);
     g_free(self->role);
@@ -1974,6 +1966,7 @@ void client_update_title(ObClient *self)
     gchar *visible = NULL;
 
     g_free(self->title);
+    g_free(self->original_title);
 
     /* try netwm */
     if (!PROP_GETS(self->window, net_wm_name, utf8, &data)) {
@@ -1990,6 +1983,7 @@ void client_update_title(ObClient *self)
                 data = g_strdup("Unnamed Window");
         }
     }
+    self->original_title = g_strdup(data);
 
     if (self->client_machine) {
         visible = g_strdup_printf("%s (%s)", data, self->client_machine);
@@ -3341,18 +3335,23 @@ void client_shade(ObClient *self, gboolean shade)
 
 static void client_ping_event(ObClient *self, gboolean dead)
 {
-    self->not_responding = dead;
-    client_update_title(self);
+    if (self->not_responding != dead) {
+        self->not_responding = dead;
+        client_update_title(self);
 
-    if (!dead) {
-        /* it came back to life ! */
+        if (dead)
+            /* the client isn't responding, so ask to kill it */
+            client_prompt_kill(self);
+        else {
+            /* it came back to life ! */
 
-        if (self->kill_prompt) {
-            prompt_unref(self->kill_prompt);
-            self->kill_prompt = NULL;
-        }
+            if (self->kill_prompt) {
+                prompt_unref(self->kill_prompt);
+                self->kill_prompt = NULL;
+            }
 
-        self->kill_level = 0;
+            self->kill_level = 0;
+        }
     }
 }
 
@@ -3360,6 +3359,7 @@ void client_close(ObClient *self)
 {
     if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
 
+    /* if closing an internal obprompt, that is just cancelling it */
     if (self->prompt) {
         prompt_cancel(self->prompt);
         return;
@@ -3377,6 +3377,14 @@ void client_close(ObClient *self)
                     prop_atoms.wm_delete_window, event_curtime, 0, 0, 0,
                     NoEventMask);
 
+        /* we're trying to close the window, so see if it is responding. if it
+           is not, then we will let them kill the window */
+        if (self->ping)
+            ping_start(self, client_ping_event);
+
+        /* if we already know the window isn't responding (maybe they clicked
+           no in the kill dialog but it hasn't come back to life), then show
+           the kill dialog */
         if (self->not_responding)
             client_prompt_kill(self);
     }
@@ -3398,31 +3406,47 @@ static void client_kill_requested(ObPrompt *p, gint result, gpointer data)
 
 static void client_prompt_kill(ObClient *self)
 {
-    ObPromptAnswer answers[] = {
-        { _("No"), OB_KILL_RESULT_NO },
-        { _("Yes"), OB_KILL_RESULT_YES }
-    };
-    gchar *m;
-
     /* check if we're already prompting */
-    if (self->kill_prompt) return;
+    if (!self->kill_prompt) {
+        ObPromptAnswer answers[] = {
+            { _("No"), OB_KILL_RESULT_NO },
+            { _("Yes"), OB_KILL_RESULT_YES }
+        };
+        gchar *m;
+
+        if (client_on_localhost(self)) {
+            const gchar *sig;
+
+            if (self->kill_level == 0)
+                sig = "terminate";
+            else
+                sig = "kill";
 
-    m = g_strdup_printf
-        (_("The window \"%s\" does not seem to be responding.  Do you want to force it to exit?"), self->title);
+            m = g_strdup_printf
+                (_("The window \"%s\" does not seem to be responding.  Do you want to force it to exit by sending the %s signal?"), self->original_title, sig);
+        }
+        else
+            m = g_strdup_printf
+                (_("The window \"%s\" does not seem to be responding.  Do you want to disconnect it from the X server?"), self->original_title);
 
-    self->kill_prompt = prompt_new(m, answers,
-                                   sizeof(answers)/sizeof(answers[0]),
-                                   OB_KILL_RESULT_NO, /* default = no */
-                                   OB_KILL_RESULT_NO, /* cancel = no */
-                                   client_kill_requested, self);
-    prompt_show(self->kill_prompt, self);
 
-    g_free(m);
+        self->kill_prompt = prompt_new(m, answers,
+                                       sizeof(answers)/sizeof(answers[0]),
+                                       OB_KILL_RESULT_NO, /* default = no */
+                                       OB_KILL_RESULT_NO, /* cancel = no */
+                                       client_kill_requested, self);
+        g_free(m);
+    }
+
+    prompt_show(self->kill_prompt, self);
 }
 
 void client_kill(ObClient *self)
 {
-    if (!self->client_machine && self->pid) {
+    /* don't kill our own windows */
+    if (self->prompt) return;
+
+    if (client_on_localhost(self) && self->pid) {
         /* running on the local host */
         if (self->kill_level == 0) {
             ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
@@ -4412,3 +4436,9 @@ gboolean client_has_group_siblings(ObClient *self)
 {
     return self->group && self->group->members->next;
 }
+
+/*! Returns TRUE if the client is running on the same machine as Openbox */
+gboolean client_on_localhost(ObClient *self)
+{
+    return self->client_machine == NULL;
+}
This page took 0.024483 seconds and 4 git commands to generate.