]> Dogcows Code - chaz/openbox/blobdiff - openbox/action.c
when using openbox-gnome/kde-session, use a separate config file (rc-gnome/kde.xml)
[chaz/openbox] / openbox / action.c
index 8e7b56a341dffe0c14a3636893396d6385201149..8c8064f89a21ab86acc5f145efbcdb6f981e9558 100644 (file)
@@ -48,8 +48,21 @@ inline void client_action_start(union ActionData *data)
 inline void client_action_end(union ActionData *data)
 {
     if (config_focus_follow)
-        if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
-            grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
+        if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
+            if (!data->any.button) {
+                grab_pointer(FALSE, FALSE, OB_CURSOR_NONE);
+            } else {
+                ObClient *c;
+
+                /* usually this is sorta redundant, but with a press action
+                   that moves windows our from under the cursor, the enter
+                   event will come as a GrabNotify which is ignored, so this
+                   makes a fake enter event
+                */
+                if ((c = client_under_pointer()))
+                    event_enter_client(c);
+            }
+        }
 }
 
 typedef struct
@@ -1101,12 +1114,20 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
             }
         }
 
-    if (!inter) {
-        /* sometimes when we execute another app as an action,
-           it won't work right unless we XUngrabKeyboard first,
-           even though we grabbed the key/button Asychronously.
-           e.g. "gnome-panel-control --main-menu" */
-        grab_keyboard(FALSE);
+    if (!inter && button == 0) {
+        /* Ungrab the keyboard before running the action, if it was
+           not from a mouse event.
+
+           We have to do this because a key press causes a passive
+           grab on the keyboard, and so if the action we are running
+           wants to grab the keyboard, it will fail if the button is still
+           held down (which is likely).
+
+           Use the X function not out own, because we're not considering
+           a grab to be in place at all so our function won't try ungrab
+           anything.
+        */
+        XUngrabKeyboard(ob_display, time);
     }
 
     for (it = acts; it; it = g_slist_next(it)) {
@@ -1138,8 +1159,9 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
             {
                 /* interactive actions are not queued */
                 a->func(&a->data);
-            } else if ((context == OB_FRAME_CONTEXT_CLIENT ||
-                        (c && c->type == OB_CLIENT_TYPE_DESKTOP &&
+            } else if (c &&
+                       (context == OB_FRAME_CONTEXT_CLIENT ||
+                        (c->type == OB_CLIENT_TYPE_DESKTOP &&
                          context == OB_FRAME_CONTEXT_DESKTOP)) &&
                        (a->func == action_focus ||
                         a->func == action_activate ||
@@ -1246,7 +1268,8 @@ void action_activate(union ActionData *data)
 {
     if (data->client.any.c) {
         if (!data->any.button || client_mouse_focusable(data->client.any.c) ||
-            data->any.context != OB_FRAME_CONTEXT_CLIENT)
+            (data->any.context != OB_FRAME_CONTEXT_CLIENT &&
+             data->any.context != OB_FRAME_CONTEXT_FRAME))
         {
             /* if using focus_delay, stop the timer now so that focus doesn't
                go moving on us */
@@ -1266,7 +1289,8 @@ void action_focus(union ActionData *data)
 {
     if (data->client.any.c) {
         if (!data->any.button || client_mouse_focusable(data->client.any.c) ||
-            data->any.context != OB_FRAME_CONTEXT_CLIENT)
+            (data->any.context != OB_FRAME_CONTEXT_CLIENT &&
+             data->any.context != OB_FRAME_CONTEXT_FRAME))
         {
             /* if using focus_delay, stop the timer now so that focus doesn't
                go moving on us */
@@ -1285,7 +1309,7 @@ void action_focus(union ActionData *data)
 void action_unfocus (union ActionData *data)
 {
     if (data->client.any.c == focus_client)
-        focus_fallback(FALSE);
+        focus_fallback(TRUE);
 }
 
 void action_iconify(union ActionData *data)
This page took 0.022536 seconds and 4 git commands to generate.