X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fclient.c;h=e9443d4914e256ac5647e7ef2dafd261c7ca13b8;hb=40377ab10a5970b20ab005a3d4994dfdf244cd4c;hp=c0864bc45db4f70ced2b3ba63850b03ba001fc41;hpb=9676757a08b3e2e508c47f7795326bda8e54dc53;p=chaz%2Fopenbox diff --git a/openbox/client.c b/openbox/client.c index c0864bc4..e9443d49 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -414,6 +414,12 @@ void client_manage(Window window, ObPrompt *prompt) activate ? "yes" : "no"); if (activate) { gboolean raise = FALSE; + gboolean relative_focused = FALSE; + + relative_focused = (focus_client != NULL && + client_search_focus_tree_full(self) != NULL && + client_search_focus_group_full(self) != NULL); + /* This is focus stealing prevention */ ob_debug_type(OB_DEBUG_FOCUS, @@ -444,10 +450,8 @@ void client_manage(Window window, ObPrompt *prompt) "Not focusing the window because its on another " "desktop"); } - /* If something is focused, and it's not our relative... */ - else if (focus_client && client_search_focus_tree_full(self) == NULL && - client_search_focus_group_full(self) == NULL) - { + /* If something is focused... */ + else if (focus_client) { /* If the user is working in another window right now, then don't steal focus */ if (event_last_user_time && launch_time && @@ -461,8 +465,9 @@ void client_manage(Window window, ObPrompt *prompt) "Not focusing the window because the user is " "working in another window"); } - /* If it's a transient (and its parents aren't focused) */ - else if (client_has_parent(self)) { + /* If the new window is a transient (and its relatives aren't + focused) */ + else if (client_has_parent(self) && !relative_focused) { activate = FALSE; ob_debug_type(OB_DEBUG_FOCUS, "Not focusing the window because it is a " @@ -488,8 +493,11 @@ void client_manage(Window window, ObPrompt *prompt) "Not focusing the window because another window " "would get the focus anyway"); } + /* Don't move focus if the window is not visible on the current + desktop and none of its relatives are focused */ else if (!(self->desktop == screen_desktop || - self->desktop == DESKTOP_ALL)) + self->desktop == DESKTOP_ALL) && + !relative_focused) { activate = FALSE; raise = TRUE; @@ -3331,12 +3339,20 @@ void client_close(ObClient *self) #define OB_KILL_RESULT_NO 0 #define OB_KILL_RESULT_YES 1 -static void client_kill_requested(ObPrompt *p, gint result, gpointer data) +static gboolean client_kill_requested(ObPrompt *p, gint result, gpointer data) { ObClient *self = data; if (result == OB_KILL_RESULT_YES) client_kill(self); + return TRUE; /* call the cleanup func */ +} + +static void client_kill_cleanup(ObPrompt *p, gpointer data) +{ + ObClient *self = data; + + g_assert(p == self->kill_prompt); prompt_unref(self->kill_prompt); self->kill_prompt = NULL; @@ -3383,11 +3399,13 @@ static void client_prompt_kill(ObClient *self) answers[0].text = _("Cancel"); /* "no" */ answers[1].text = y; /* "yes" */ - self->kill_prompt = prompt_new(m, answers, + self->kill_prompt = prompt_new(m, NULL, answers, sizeof(answers)/sizeof(answers[0]), OB_KILL_RESULT_NO, /* default = no */ OB_KILL_RESULT_NO, /* cancel = no */ - client_kill_requested, self); + client_kill_requested, + client_kill_cleanup, + self); g_free(m); }