don't ping everything all the time. yay. ping when you close, and if it doesn't reply then show the kill prompt. also show a more correct prompt for windows connecting from non-local machines - ask to disconnect them from the X server.
This commit is contained in:
parent
4eecbeb611
commit
c778cf15cb
4 changed files with 54 additions and 35 deletions
|
@ -619,15 +619,6 @@ void client_manage(Window window, ObPrompt *prompt)
|
||||||
/* update the list hints */
|
/* update the list hints */
|
||||||
client_set_list();
|
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 */
|
/* free the ObAppSettings shallow copy */
|
||||||
g_free(settings);
|
g_free(settings);
|
||||||
|
|
||||||
|
@ -3344,18 +3335,23 @@ void client_shade(ObClient *self, gboolean shade)
|
||||||
|
|
||||||
static void client_ping_event(ObClient *self, gboolean dead)
|
static void client_ping_event(ObClient *self, gboolean dead)
|
||||||
{
|
{
|
||||||
self->not_responding = dead;
|
if (self->not_responding != dead) {
|
||||||
client_update_title(self);
|
self->not_responding = dead;
|
||||||
|
client_update_title(self);
|
||||||
|
|
||||||
if (!dead) {
|
if (dead)
|
||||||
/* it came back to life ! */
|
/* the client isn't responding, so ask to kill it */
|
||||||
|
client_prompt_kill(self);
|
||||||
|
else {
|
||||||
|
/* it came back to life ! */
|
||||||
|
|
||||||
if (self->kill_prompt) {
|
if (self->kill_prompt) {
|
||||||
prompt_unref(self->kill_prompt);
|
prompt_unref(self->kill_prompt);
|
||||||
self->kill_prompt = NULL;
|
self->kill_prompt = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->kill_level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->kill_level = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3363,6 +3359,7 @@ void client_close(ObClient *self)
|
||||||
{
|
{
|
||||||
if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
|
if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
|
||||||
|
|
||||||
|
/* if closing an internal obprompt, that is just cancelling it */
|
||||||
if (self->prompt) {
|
if (self->prompt) {
|
||||||
prompt_cancel(self->prompt);
|
prompt_cancel(self->prompt);
|
||||||
return;
|
return;
|
||||||
|
@ -3380,6 +3377,14 @@ void client_close(ObClient *self)
|
||||||
prop_atoms.wm_delete_window, event_curtime, 0, 0, 0,
|
prop_atoms.wm_delete_window, event_curtime, 0, 0, 0,
|
||||||
NoEventMask);
|
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)
|
if (self->not_responding)
|
||||||
client_prompt_kill(self);
|
client_prompt_kill(self);
|
||||||
}
|
}
|
||||||
|
@ -3408,15 +3413,22 @@ static void client_prompt_kill(ObClient *self)
|
||||||
{ _("Yes"), OB_KILL_RESULT_YES }
|
{ _("Yes"), OB_KILL_RESULT_YES }
|
||||||
};
|
};
|
||||||
gchar *m;
|
gchar *m;
|
||||||
const gchar *sig;
|
|
||||||
|
|
||||||
if (self->kill_level == 0)
|
if (client_on_localhost(self)) {
|
||||||
sig = "terminate";
|
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 by sending the %s signal?"), self->original_title, sig);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sig = "kill";
|
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);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
self->kill_prompt = prompt_new(m, answers,
|
self->kill_prompt = prompt_new(m, answers,
|
||||||
sizeof(answers)/sizeof(answers[0]),
|
sizeof(answers)/sizeof(answers[0]),
|
||||||
|
@ -3434,7 +3446,7 @@ void client_kill(ObClient *self)
|
||||||
/* don't kill our own windows */
|
/* don't kill our own windows */
|
||||||
if (self->prompt) return;
|
if (self->prompt) return;
|
||||||
|
|
||||||
if (!self->client_machine && self->pid) {
|
if (client_on_localhost(self) && self->pid) {
|
||||||
/* running on the local host */
|
/* running on the local host */
|
||||||
if (self->kill_level == 0) {
|
if (self->kill_level == 0) {
|
||||||
ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
|
ob_debug("killing window 0x%x with pid %lu, with SIGTERM",
|
||||||
|
@ -4424,3 +4436,9 @@ gboolean client_has_group_siblings(ObClient *self)
|
||||||
{
|
{
|
||||||
return self->group && self->group->members->next;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -729,4 +729,7 @@ ObClient* client_under_pointer();
|
||||||
|
|
||||||
gboolean client_has_group_siblings(ObClient *self);
|
gboolean client_has_group_siblings(ObClient *self);
|
||||||
|
|
||||||
|
/*! Returns TRUE if the client is running on the same machine as Openbox */
|
||||||
|
gboolean client_on_localhost(ObClient *self);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,7 @@ static guint32 ping_next_id = 1;
|
||||||
|
|
||||||
#define PING_TIMEOUT (G_USEC_PER_SEC * 3)
|
#define PING_TIMEOUT (G_USEC_PER_SEC * 3)
|
||||||
/*! Warn the user after this many PING_TIMEOUT intervals */
|
/*! Warn the user after this many PING_TIMEOUT intervals */
|
||||||
#define PING_TIMEOUT_WARN 3
|
#define PING_TIMEOUT_WARN 1
|
||||||
|
|
||||||
static void ping_send(ObPingTarget *t);
|
static void ping_send(ObPingTarget *t);
|
||||||
static void ping_end(ObClient *client, gpointer data);
|
static void ping_end(ObClient *client, gpointer data);
|
||||||
|
@ -69,11 +69,12 @@ void ping_start(struct _ObClient *client, ObPingEventHandler h)
|
||||||
{
|
{
|
||||||
ObPingTarget *t;
|
ObPingTarget *t;
|
||||||
|
|
||||||
/* make sure we're not already pinging the client */
|
/* make sure the client supports ping! */
|
||||||
g_assert(g_hash_table_find(ping_ids, find_client, client) == NULL);
|
|
||||||
|
|
||||||
g_assert(client->ping == TRUE);
|
g_assert(client->ping == TRUE);
|
||||||
|
|
||||||
|
/* make sure we're not already pinging the client */
|
||||||
|
if (g_hash_table_find(ping_ids, find_client, client) != NULL) return;
|
||||||
|
|
||||||
t = g_new0(ObPingTarget, 1);
|
t = g_new0(ObPingTarget, 1);
|
||||||
t->client = client;
|
t->client = client;
|
||||||
t->h = h;
|
t->h = h;
|
||||||
|
@ -89,11 +90,6 @@ void ping_start(struct _ObClient *client, ObPingEventHandler h)
|
||||||
g_assert(g_hash_table_find(ping_ids, find_client, client) != NULL);
|
g_assert(g_hash_table_find(ping_ids, find_client, client) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ping_stop(struct _ObClient *c)
|
|
||||||
{
|
|
||||||
ping_end(c, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ping_got_pong(guint32 id)
|
void ping_got_pong(guint32 id)
|
||||||
{
|
{
|
||||||
ObPingTarget *t;
|
ObPingTarget *t;
|
||||||
|
@ -106,6 +102,9 @@ void ping_got_pong(guint32 id)
|
||||||
t->h(t->client, FALSE);
|
t->h(t->client, FALSE);
|
||||||
}
|
}
|
||||||
t->waiting = 0; /* not waiting for a reply anymore */
|
t->waiting = 0; /* not waiting for a reply anymore */
|
||||||
|
|
||||||
|
/* we got a pong so we're happy now */
|
||||||
|
ping_end(t->client, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ob_debug("Got PONG with id %u but not waiting for one\n", id);
|
ob_debug("Got PONG with id %u but not waiting for one\n", id);
|
||||||
|
|
|
@ -37,7 +37,6 @@ void ping_startup(gboolean reconfigure);
|
||||||
void ping_shutdown(gboolean reconfigure);
|
void ping_shutdown(gboolean reconfigure);
|
||||||
|
|
||||||
void ping_start(struct _ObClient *c, ObPingEventHandler h);
|
void ping_start(struct _ObClient *c, ObPingEventHandler h);
|
||||||
void ping_stop(struct _ObClient *c);
|
|
||||||
|
|
||||||
void ping_got_pong(guint32 id);
|
void ping_got_pong(guint32 id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue