From d48a2b4706030b6b323851d5baa5bec3fed541e8 Mon Sep 17 00:00:00 2001 From: Brian Mattern Date: Thu, 13 Sep 2012 23:14:55 -0700 Subject: [PATCH] Allow focus stealing just after launching an app This works around the fact that many apps (e.g. firefox, chrome, etc) signal an existing process to open a new window instead of launching a new process. Without this, openbox treats these new windows like unrequested dialogs, and does not give them focus. --- openbox/actions/execute.c | 2 ++ openbox/client.c | 8 ++++++++ openbox/client.h | 1 + 3 files changed, 11 insertions(+) diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index 380ffa0..faac6b7 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -248,6 +248,8 @@ static gboolean run_func(ObActionsData *data, gpointer options) screen_desktop); } + client_set_last_action_execute_time(); + e = NULL; ok = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | diff --git a/openbox/client.c b/openbox/client.c index f3b4bda..bf84af5 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -115,6 +115,8 @@ static gboolean client_can_steal_focus(ObClient *self, static void client_setup_default_decor_and_functions(ObClient *self); static void client_setup_decor_undecorated(ObClient *self); +static Time last_action_execute_time = CurrentTime; + void client_startup(gboolean reconfig) { client_default_icon = RrImageNewFromData( @@ -831,6 +833,7 @@ static gboolean client_can_steal_focus(ObClient *self, /* last user time must be strictly > launch_time to block focus */ (event_time_after(event_last_user_time, launch_time) && event_last_user_time != launch_time) && + event_time_after(steal_time - OB_EVENT_USER_TIME_DELAY, last_action_execute_time) && event_time_after(event_last_user_time, steal_time - OB_EVENT_USER_TIME_DELAY)) { @@ -4601,3 +4604,8 @@ gboolean client_on_localhost(ObClient *self) { return self->client_machine == NULL; } + +void client_set_last_action_execute_time(void) +{ + last_action_execute_time = event_time(); +} diff --git a/openbox/client.h b/openbox/client.h index d5b344f..48fa3a3 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -755,4 +755,5 @@ gboolean client_has_relative(ObClient *self); /*! Returns TRUE if the client is running on the same machine as Openbox */ gboolean client_on_localhost(ObClient *self); +void client_set_last_action_execute_time(void); #endif -- 1.7.9.5