]> Dogcows Code - chaz/openbox/commitdiff
Allow windows created by execute actions to steal focus if the user isn't interacting...
authorDana Jansens <danakj@orodu.net>
Mon, 1 Oct 2012 02:41:34 +0000 (22:41 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 7 Oct 2012 01:56:56 +0000 (21:56 -0400)
When the execute action was run, we would say that the user had used the focused
at that time. Then when a new window popped up, we'd think the user was busy in
the current window and prevent the new one from steal focus.

Now the execute action does not update the "user interacted with the focused
window" timestamp anymore. So, if they aren't currently typing in some window
when they trigger an execute action, and the window appears, it will steal
focus.

openbox/actions.c
openbox/actions.h
openbox/actions/execute.c
openbox/event.h

index afbd9cb6445f07f395b6f6ac55e05404b03416fe..ac849a9741b794070537ef1094e35787985628cd 100644 (file)
@@ -51,6 +51,7 @@ struct _ObActionsDefinition {
     ObActionsDataFreeFunc free;
     ObActionsRunFunc run;
     ObActionsShutdownFunc shutdown;
+    gboolean modifies_focused_window;
 };
 
 struct _ObActionsAct {
@@ -103,12 +104,13 @@ ObActionsDefinition* do_register(const gchar *name,
             return NULL;
     }
 
-    def = g_slice_new(ObActionsDefinition);
+    def = g_slice_new0(ObActionsDefinition);
     def->ref = 1;
     def->name = g_strdup(name);
     def->free = free;
     def->run = run;
     def->shutdown = NULL;
+    def->modifies_focused_window = TRUE;
 
     registered = g_slist_prepend(registered, def);
     return def;
@@ -156,6 +158,22 @@ gboolean actions_set_shutdown(const gchar *name,
     return FALSE;
 }
 
+gboolean actions_set_modifies_focused_window(const gchar *name,
+                                             gboolean modifies)
+{
+    GSList *it;
+    ObActionsDefinition *def;
+
+    for (it = registered; it; it = g_slist_next(it)) {
+        def = it->data;
+        if (!g_ascii_strcasecmp(name, def->name)) {
+            def->modifies_focused_window = modifies;
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
 static void actions_definition_ref(ObActionsDefinition *def)
 {
     ++def->ref;
@@ -340,8 +358,11 @@ void actions_run_acts(GSList *acts,
             if (!act->def->run(&data, act->options)) {
                 if (actions_act_is_interactive(act))
                     actions_interactive_end_act();
-                if (client && client == focus_client)
+                if (client && client == focus_client &&
+                    act->def->modifies_focused_window)
+                {
                     update_user_time = TRUE;
+                }
             } else {
                 /* make sure its interactive if it returned TRUE */
                 g_assert(act->i_input);
index e03bc577742fd0eb92d03019c53061b1a3ea9393..f413ad8284386389015d07d43197a42ae8ad8e68 100644 (file)
@@ -82,6 +82,8 @@ gboolean actions_register(const gchar *name,
 
 gboolean actions_set_shutdown(const gchar *name,
                               ObActionsShutdownFunc shutdown);
+gboolean actions_set_modifies_focused_window(const gchar *name,
+                                             gboolean modifies);
 
 ObActionsAct* actions_parse(xmlNodePtr node);
 ObActionsAct* actions_parse_string(const gchar *name);
index 380ffa008996936d4484d3d6bb15914cf861417c..df600fa08a7a66aa328f557c9660eaa500e5aa4f 100644 (file)
@@ -33,6 +33,7 @@ void action_execute_startup(void)
 {
     actions_register("Execute", setup_func, free_func, run_func);
     actions_set_shutdown("Execute", shutdown_func);
+    actions_set_modifies_focused_window("Execute", FALSE);
 
     client_add_destroy_notify(client_dest, NULL);
 }
index 4d9984e16c04ded47a499d047e9e6ba729092f3a..cc441405a4638e582f0119149ec76b5ff991981a 100644 (file)
@@ -26,7 +26,7 @@ struct _ObClient;
 
 /*! The amount of time before a window appears that is checked for user input
     to determine if the user is working in another window */
-#define OB_EVENT_USER_TIME_DELAY (1000) /* 1.0 seconds */
+#define OB_EVENT_USER_TIME_DELAY (1000) /* milliseconds */
 
 /*! The last user-interaction time, as given by the clients */
 extern Time event_last_user_time;
This page took 0.024214 seconds and 4 git commands to generate.