From 60053651335e4ffd2bb1cb0aec04e4ceb9357c3f Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 13:30:44 -0500 Subject: [PATCH 1/3] don't steal focus from windows you are typing in, even if the new window is a relative --- openbox/client.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/openbox/client.c b/openbox/client.c index 816fa922..98d1035b 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -494,6 +494,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, @@ -524,10 +530,8 @@ void client_manage(Window window, ObPrompt *prompt) "Not focusing the window because its on another " "desktop\n"); } - /* 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 && @@ -541,8 +545,9 @@ void client_manage(Window window, ObPrompt *prompt) "Not focusing the window because the user is " "working in another window\n"); } - /* 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 " @@ -568,8 +573,11 @@ void client_manage(Window window, ObPrompt *prompt) "Not focusing the window because another window " "would get the focus anyway\n"); } + /* 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; From ffaac4a65043b6d4ea1e358d17f68f8c703db73d Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 15:01:46 -0500 Subject: [PATCH 2/3] make the SessionLogout action always available but it shows an error if you use it and Openbox wasn't built with SM support --- openbox/actions/session.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/openbox/actions/session.c b/openbox/actions/session.c index 0117e07c..2c373654 100644 --- a/openbox/actions/session.c +++ b/openbox/actions/session.c @@ -3,10 +3,6 @@ #include "openbox/session.h" #include "gettext.h" -#ifndef USE_SM -void action_logout_startup(void) {} -#else - typedef struct { gboolean prompt; gboolean silent; @@ -38,8 +34,13 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) static void prompt_cb(ObPrompt *p, gint result, gpointer data) { Options *o = data; - if (result) + if (result) { +#ifndef USE_SM session_request_logout(o->silent); +#else + g_message(_("The SessionLogout actions is not available since Openbox was built without session management support")); +#endif + } g_free(o); prompt_unref(p); } @@ -67,5 +68,3 @@ static gboolean logout_func(ObActionsData *data, gpointer options) return FALSE; } - -#endif From b8960827b76ad499170e8b5b9ae8bf202188f0b0 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 2 Mar 2008 15:02:34 -0500 Subject: [PATCH 3/3] make code to show a prompt when you just want to display and message and not do anything when the user presses the button --- openbox/prompt.c | 25 +++++++++++++++++++++++++ openbox/prompt.h | 2 ++ po/POTFILES.in | 1 + 3 files changed, 28 insertions(+) diff --git a/openbox/prompt.c b/openbox/prompt.c index 0278757e..6084d798 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -28,6 +28,7 @@ #include "gettext.h" static GList *prompt_list = NULL; +static GList *prompt_msg_list = NULL; /* we construct these */ static RrAppearance *prompt_a_bg; @@ -121,6 +122,9 @@ void prompt_startup(gboolean reconfig) void prompt_shutdown(gboolean reconfig) { + while (prompt_msg_list) + prompt_cancel(prompt_msg_list->data); + RrAppearanceFree(prompt_a_button); RrAppearanceFree(prompt_a_focus); RrAppearanceFree(prompt_a_press); @@ -218,6 +222,9 @@ void prompt_unref(ObPrompt *self) if (self && --self->ref == 0) { gint i; + if (self->mapped) + prompt_hide(self); + prompt_list = g_list_remove(prompt_list, self); for (i = 0; i < self->n_buttons; ++i) { @@ -600,3 +607,21 @@ void prompt_cancel(ObPrompt *self) if (self->func) self->func(self, self->cancel_result, self->data); prompt_hide(self); } + +static void prompt_show_message_cb(ObPrompt *p, int res, gpointer data) +{ + prompt_msg_list = g_list_remove(prompt_msg_list, p); + prompt_unref(p); +} + +void prompt_show_message(const gchar *msg, const gchar *answer) +{ + ObPrompt *p; + ObPromptAnswer ans[] = { + { answer, 0 } + }; + + p = prompt_new(msg, ans, 1, 0, 0, prompt_show_message_cb, NULL); + prompt_msg_list = g_list_prepend(prompt_msg_list, p); + prompt_show(p, NULL, FALSE); +} diff --git a/openbox/prompt.h b/openbox/prompt.h index 89d3d598..c4558ad2 100644 --- a/openbox/prompt.h +++ b/openbox/prompt.h @@ -107,4 +107,6 @@ gboolean prompt_key_event(ObPrompt *self, XEvent *e); gboolean prompt_mouse_event(ObPrompt *self, XEvent *e); void prompt_cancel(ObPrompt *self); +void prompt_show_message(const gchar *msg, const gchar *answer); + #endif diff --git a/po/POTFILES.in b/po/POTFILES.in index 85938dee..bb6beff8 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,6 +2,7 @@ openbox/actions.c openbox/actions/execute.c openbox/actions/exit.c +openbox/actions/session.c openbox/client.c openbox/client_list_combined_menu.c openbox/client_list_menu.c