]> Dogcows Code - chaz/openbox/commitdiff
when ending actions which can move windows, and we were using the mouse, instead...
authorDana Jansens <danakj@orodu.net>
Sun, 21 Sep 2003 21:26:07 +0000 (21:26 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 21 Sep 2003 21:26:07 +0000 (21:26 +0000)
openbox/action.c
openbox/event.c
openbox/event.h

index 0e4d570f97f662fca3ea4b3835b43250297b5e2e..332e100d45c4a15bdd4ed0363d1e6310ece2642a 100644 (file)
 
 #include <glib.h>
 
-#define ACT_START(d) \
-    ((d->any.context != OB_FRAME_CONTEXT_CLIENT && config_focus_follow) ? \
-     grab_pointer(TRUE, OB_CURSOR_NONE), 0 : 0)
+inline void client_action_start(union ActionData *data)
+{
+    if (config_focus_follow)
+        if (data->any.context != OB_FRAME_CONTEXT_CLIENT && !data->any.button)
+            grab_pointer(TRUE, OB_CURSOR_NONE);
+}
+
+inline void client_action_end(union ActionData *data)
+{
+    if (config_focus_follow)
+        if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
+            if (!data->any.button) {
+                grab_pointer(FALSE, OB_CURSOR_NONE);
+            } else {
+                ObClient *c;
 
-#define ACT_END(d) \
-    ((d->any.context != OB_FRAME_CONTEXT_CLIENT && config_focus_follow) ? \
-     grab_pointer(FALSE, OB_CURSOR_NONE), \
-     (d->any.button ? focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS), 1 : 0) : \
-     0)
+                if ((c = client_under_pointer()))
+                    event_enter_client(c);
+            }
+        }
+}
 
 typedef struct ActionString {
     const gchar *name;
@@ -916,22 +928,22 @@ void action_raiselower(union ActionData *data)
     }
 
     if (raise) {
-        ACT_START(data);
+        client_action_start(data);
         stacking_raise(CLIENT_AS_WINDOW(c));
-        ACT_END(data);
+        client_action_end(data);
     } else {
-        ACT_START(data);
+        client_action_start(data);
         stacking_lower(CLIENT_AS_WINDOW(c));
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_raise(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -939,13 +951,13 @@ void action_unshaderaise(union ActionData *data)
 {
     if (data->client.any.c) {
         if (data->client.any.c->shaded) {
-            ACT_START(data);
+            client_action_start(data);
             client_shade(data->client.any.c, FALSE);
-            ACT_END(data);
+            client_action_end(data);
         } else {
-            ACT_START(data);
+            client_action_start(data);
             stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
-            ACT_END(data);
+            client_action_end(data);
         }
     }
 }
@@ -956,9 +968,9 @@ void action_shadelower(union ActionData *data)
         if (data->client.any.c->shaded)
             stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
         else {
-            ACT_START(data);
+            client_action_start(data);
             client_shade(data->client.any.c, TRUE);
-            ACT_END(data);
+            client_action_end(data);
         }
     }
 }
@@ -966,9 +978,9 @@ void action_shadelower(union ActionData *data)
 void action_lower(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -987,27 +999,27 @@ void action_kill(union ActionData *data)
 void action_shade(union ActionData *data)
 {
     if (data->client.any.c) { 
-        ACT_START(data);
+        client_action_start(data);
         client_shade(data->client.any.c, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_unshade(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_shade(data->client.any.c, FALSE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_toggle_shade(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_shade(data->client.any.c, !data->client.any.c->shaded);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -1023,9 +1035,9 @@ void action_move_relative_horz(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c) {
-        ACT_START(data);
+        client_action_start(data);
         client_move(c, c->area.x + data->relative.delta, c->area.y);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -1033,9 +1045,9 @@ void action_move_relative_vert(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c) {
-        ACT_START(data);
+        client_action_start(data);
         client_move(c, c->area.x, c->area.y + data->relative.delta);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -1043,11 +1055,11 @@ void action_resize_relative_horz(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c) {
-        ACT_START(data);
+        client_action_start(data);
         client_resize(c,
                       c->area.width + data->relative.delta * c->size_inc.width,
                       c->area.height);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -1055,96 +1067,96 @@ void action_resize_relative_vert(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
     if (c && !c->shaded) {
-        ACT_START(data);
+        client_action_start(data);
         client_resize(c, c->area.width, c->area.height +
                       data->relative.delta * c->size_inc.height);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_maximize_full(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c, TRUE, 0, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_unmaximize_full(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c, FALSE, 0, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_toggle_maximize_full(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c,
                         !(data->client.any.c->max_horz ||
                           data->client.any.c->max_vert),
                         0, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_maximize_horz(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c, TRUE, 1, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_unmaximize_horz(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c, FALSE, 1, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_toggle_maximize_horz(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c,
                         !data->client.any.c->max_horz, 1, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_maximize_vert(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c, TRUE, 2, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_unmaximize_vert(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c, FALSE, 2, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
 void action_toggle_maximize_vert(union ActionData *data)
 {
     if (data->client.any.c) {
-        ACT_START(data);
+        client_action_start(data);
         client_maximize(data->client.any.c,
                         !data->client.any.c->max_vert, 2, TRUE);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -1209,10 +1221,10 @@ void action_toggle_decorations(union ActionData *data)
     ObClient *c = data->client.any.c;
 
     if (c) {
-        ACT_START(data);
+        client_action_start(data);
         c->decorate = !c->decorate;
         client_setup_decor_and_functions(c);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
@@ -1327,9 +1339,9 @@ void action_movetoedge(union ActionData *data)
         g_assert_not_reached();
     }
     frame_frame_gravity(c->frame, &x, &y);
-    ACT_START(data);
+    client_action_start(data);
     client_move(c, x, y);
-    ACT_END(data);
+    client_action_end(data);
 
 }
 
@@ -1393,9 +1405,9 @@ void action_growtoedge(union ActionData *data)
     frame_frame_gravity(c->frame, &x, &y);
     width -= c->frame->size.left + c->frame->size.right;
     height -= c->frame->size.top + c->frame->size.bottom;
-    ACT_START(data);
+    client_action_start(data);
     client_move_resize(c, x, y, width, height);
-    ACT_END(data);
+    client_action_end(data);
 }
 
 void action_send_to_layer(union ActionData *data)
@@ -1409,12 +1421,12 @@ void action_toggle_layer(union ActionData *data)
     ObClient *c = data->layer.any.c;
 
     if (c) {
-        ACT_START(data);
+        client_action_start(data);
         if (data->layer.layer < 0)
             client_set_layer(c, c->below ? 0 : -1);
         else if (data->layer.layer > 0)
             client_set_layer(c, c->above ? 0 : 1);
-        ACT_END(data);
+        client_action_end(data);
     }
 }
 
index 4f2a1513d746cdc1ee3fd90e32cc4b2ed2dceaad..9d141c5ab4ca27ccf5a9542fc29c031d95768d9f 100644 (file)
@@ -97,7 +97,6 @@ static const int mask_table[] = {
 static int mask_table_size;
 
 static guint ignore_enter_focus = 0;
-static ObClient *focus_delay_client;
 
 static gboolean menu_can_hide;
 
@@ -602,6 +601,25 @@ static void event_handle_group(ObGroup *group, XEvent *e)
         event_handle_client(it->data, e);
 }
 
+void event_enter_client(ObClient *client)
+{
+    g_assert(config_focus_follow);
+
+    if (client_normal(client) && client_can_focus(client)) {
+        if (config_focus_delay) {
+            ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func);
+            ob_main_loop_timeout_add(ob_main_loop,
+                                     config_focus_delay,
+                                     focus_delay_func,
+                                     client, NULL);
+        } else {
+            client_focus(client);
+            if (config_focus_raise)
+                stacking_raise(CLIENT_AS_WINDOW(client));
+        }
+    }
+}
+
 static void event_handle_client(ObClient *client, XEvent *e)
 {
     XEvent ce;
@@ -694,12 +712,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             frame_adjust_state(client->frame);
             break;
         case OB_FRAME_CONTEXT_FRAME:
-            if (client == focus_delay_client) {
-                ob_main_loop_timeout_remove_data(ob_main_loop,
-                                                 focus_delay_func,
-                                                 focus_delay_client);
-                focus_delay_client = NULL;
-            }
+            break;
         default:
             break;
         }
@@ -736,39 +749,26 @@ static void event_handle_client(ObClient *client, XEvent *e)
             frame_adjust_state(client->frame);
             break;
         case OB_FRAME_CONTEXT_FRAME:
-            if (!nofocus && config_focus_follow &&
-                client_normal(client) && client_can_focus(client)) {
-                if (e->xcrossing.mode == NotifyGrab ||
-                    e->xcrossing.detail == NotifyInferior ||
-                    e->xcrossing.mode == NotifyUngrab)
-                {
+            if (e->xcrossing.mode == NotifyGrab ||
+                e->xcrossing.detail == NotifyInferior ||
+                e->xcrossing.mode == NotifyUngrab)
+            {
 #ifdef DEBUG_FOCUS
-                    ob_debug("%sNotify mode %d detail %d on %lx IGNORED\n",
-                             (e->type == EnterNotify ? "Enter" : "Leave"),
-                             e->xcrossing.mode,
-                             e->xcrossing.detail, client?client->window:0);
+                ob_debug("%sNotify mode %d detail %d on %lx IGNORED\n",
+                         (e->type == EnterNotify ? "Enter" : "Leave"),
+                         e->xcrossing.mode,
+                         e->xcrossing.detail, client?client->window:0);
 #endif
-                } else {
+            } else {
 #ifdef DEBUG_FOCUS
-                    ob_debug("%sNotify mode %d detail %d on %lx, "
-                             "focusing window\n",
-                             (e->type == EnterNotify ? "Enter" : "Leave"),
-                             e->xcrossing.mode,
-                             e->xcrossing.detail, client?client->window:0);
+                ob_debug("%sNotify mode %d detail %d on %lx, "
+                         "focusing window\n",
+                         (e->type == EnterNotify ? "Enter" : "Leave"),
+                         e->xcrossing.mode,
+                         e->xcrossing.detail, client?client->window:0);
 #endif
-                    if (config_focus_delay) {
-                        ob_main_loop_timeout_add(ob_main_loop,
-                                                 config_focus_delay,
-                                                 focus_delay_func,
-                                                 client, NULL);
-                        focus_delay_client = client;
-                    } else {
-                        client_focus(client);
-                        if (config_focus_raise)
-                            stacking_raise
-                                (CLIENT_AS_WINDOW(focus_delay_client));
-                    }
-                }
+                if (!nofocus && config_focus_follow)
+                    event_enter_client(client);
             }
             break;
         default:
@@ -1252,22 +1252,19 @@ static gboolean menu_hide_delay_func(gpointer data)
 
 static gboolean focus_delay_func(gpointer data)
 {
-    if (data == focus_delay_client) {
-        client_focus(focus_delay_client);
-        if (config_focus_raise)
-            stacking_raise(CLIENT_AS_WINDOW(focus_delay_client));
-    }
+    ObClient *c = data;
+
+    client_focus(c);
+    if (config_focus_raise)
+        stacking_raise(CLIENT_AS_WINDOW(c));
     return FALSE; /* no repeat */
 }
 
 static void focus_delay_client_dest(gpointer data)
 {
     ObClient *c = data;
-    if (c == focus_delay_client) {
-        ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func,
-                                         focus_delay_client);
-        focus_delay_client = NULL;
-    }
+
+    ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func, c);
 }
 
 void event_ignore_enter_focus(guint num)
index e2b57ffec1b002d2074e34b29f28c09db797bfe4..341bc8d39c4f42890f02ec9f576f8779ba7b6606 100644 (file)
@@ -22,6 +22,8 @@
 #include <X11/Xlib.h>
 #include <glib.h>
 
+struct _ObClient;
+
 /*! Time at which the last event with a timestamp occured. */
 extern Time event_lasttime;
 
@@ -37,4 +39,8 @@ void event_shutdown(gboolean reconfig);
   focus */
 void event_ignore_enter_focus(guint num);
 
+/*! Make as if the mouse just entered the client, use only when using focus
+  follows mouse */
+void event_enter_client(struct _ObClient *client);
+
 #endif
This page took 0.043673 seconds and 4 git commands to generate.