]> Dogcows Code - chaz/openbox/blobdiff - openbox/action.c
xinerama support like crazy for struts and everything else too. this probably crashes...
[chaz/openbox] / openbox / action.c
index d720f97dcce41791a88df2b9b4f1a3b7ba08dce4..6ba52c8959f13d140fbea9a3f5f0e1a7ae3adb08 100644 (file)
 
 #include <glib.h>
 
+static gulong ignore_start = 0;
+
 static void client_action_start(union ActionData *data)
 {
+    ignore_start = event_start_ignore_all_enters();
 }
 
-static void client_action_end(union ActionData *data)
+static void client_action_end(union ActionData *data, gboolean allow_enters)
 {
     if (config_focus_follow)
         if (data->any.context != OB_FRAME_CONTEXT_CLIENT) {
-            if (!data->any.button && data->any.c) {
-                event_ignore_all_queued_enters();
+            if (!data->any.button && data->any.c && !allow_enters) {
+                event_end_ignore_all_enters(ignore_start);
             } else {
                 ObClient *c;
 
@@ -57,9 +60,12 @@ static void client_action_end(union ActionData *data)
                    event will come as a GrabNotify which is ignored, so this
                    makes a fake enter event
                 */
-                if ((c = client_under_pointer())
-                    && c != data->any.c)
+                if ((c = client_under_pointer()) && c != data->any.c) {
+                    ob_debug_type(OB_DEBUG_FOCUS,
+                                  "Generating fake enter because we did a "
+                                  "mouse-event action");
                     event_enter_client(c);
+                }
             }
         }
 }
@@ -1152,13 +1158,9 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
             {
                 /* interactive actions are not queued */
                 a->func(&a->data);
-            } 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 ||
-                        a->func == action_showmenu))
+            } else if (a->func == action_focus ||
+                       a->func == action_activate ||
+                       a->func == action_showmenu)
             {
                 /* XXX MORE UGLY HACK
                    actions from clicks on client windows are NOT queued.
@@ -1178,11 +1180,15 @@ void action_run_list(GSList *acts, ObClient *c, ObFrameContext context,
                    pointer. ugh.
 
                    also with the menus, there is a race going on. if the
-                   desktop wants to pop up a menu, and we do to, we send them
+                   desktop wants to pop up a menu, and we do too, we send them
                    the button before we pop up the menu, so they pop up their
                    menu first. but not always. if we pop up our menu before
                    sending them the button press, then the result is
                    deterministic. yay.
+
+                   XXX further more. focus actions are not queued at all,
+                   because if you bind focus->showmenu, the menu will get
+                   hidden to do the focusing
                 */
                 a->func(&a->data);
             } else
@@ -1312,14 +1318,14 @@ void action_focus(union ActionData *data)
 void action_unfocus (union ActionData *data)
 {
     if (data->client.any.c == focus_client)
-        focus_fallback(FALSE);
+        focus_fallback(FALSE, FALSE, TRUE);
 }
 
 void action_iconify(union ActionData *data)
 {
     client_action_start(data);
     client_iconify(data->client.any.c, TRUE, TRUE, FALSE);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_focus_order_to_bottom(union ActionData *data)
@@ -1330,38 +1336,17 @@ void action_focus_order_to_bottom(union ActionData *data)
 void action_raiselower(union ActionData *data)
 {
     ObClient *c = data->client.any.c;
-    GList *it;
-    gboolean raise = FALSE;
-
-    for (it = stacking_list; it; it = g_list_next(it)) {
-        if (WINDOW_IS_CLIENT(it->data)) {
-            ObClient *cit = it->data;
-
-            if (cit == c) break;
-            if (client_normal(cit) == client_normal(c) &&
-                cit->layer == c->layer &&
-                cit->frame->visible &&
-                !client_search_transient(c, cit))
-            {
-                if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) {
-                    raise = TRUE;
-                    break;
-                }
-            }
-        }
-    }
 
-    if (raise)
-        action_raise(data);
-    else
-        action_lower(data);
+    client_action_start(data);
+    stacking_restack_request(c, NULL, Opposite, FALSE);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_raise(union ActionData *data)
 {
     client_action_start(data);
     stacking_raise(CLIENT_AS_WINDOW(data->client.any.c));
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_unshaderaise(union ActionData *data)
@@ -1384,7 +1369,7 @@ void action_lower(union ActionData *data)
 {
     client_action_start(data);
     stacking_lower(CLIENT_AS_WINDOW(data->client.any.c));
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_close(union ActionData *data)
@@ -1401,21 +1386,21 @@ void action_shade(union ActionData *data)
 {
     client_action_start(data);
     client_shade(data->client.any.c, TRUE);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_unshade(union ActionData *data)
 {
     client_action_start(data);
     client_shade(data->client.any.c, FALSE);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_shade(union ActionData *data)
 {
     client_action_start(data);
     client_shade(data->client.any.c, !data->client.any.c->shaded);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_omnipresent(union ActionData *data)
@@ -1430,7 +1415,7 @@ void action_move_relative_horz(union ActionData *data)
     ObClient *c = data->relative.any.c;
     client_action_start(data);
     client_move(c, c->area.x + data->relative.deltax, c->area.y);
-    client_action_end(data);
+    client_action_end(data, FALSE);
 }
 
 void action_move_relative_vert(union ActionData *data)
@@ -1438,18 +1423,19 @@ void action_move_relative_vert(union ActionData *data)
     ObClient *c = data->relative.any.c;
     client_action_start(data);
     client_move(c, c->area.x, c->area.y + data->relative.deltax);
-    client_action_end(data);
+    client_action_end(data, FALSE);
 }
 
 void action_move_to_center(union ActionData *data)
 {
     ObClient *c = data->client.any.c;
     Rect *area;
-    area = screen_area_monitor(c->desktop, 0);
+    area = screen_area(c->desktop, client_monitor(c), NULL);
     client_action_start(data);
     client_move(c, area->width / 2 - c->area.width / 2,
                 area->height / 2 - c->area.height / 2);
-    client_action_end(data);
+    client_action_end(data, FALSE);
+    g_free(area);
 }
 
 void action_resize_relative_horz(union ActionData *data)
@@ -1459,7 +1445,7 @@ void action_resize_relative_horz(union ActionData *data)
     client_resize(c,
                   c->area.width + data->relative.deltax * c->size_inc.width,
                   c->area.height);
-    client_action_end(data);
+    client_action_end(data, FALSE);
 }
 
 void action_resize_relative_vert(union ActionData *data)
@@ -1469,7 +1455,7 @@ void action_resize_relative_vert(union ActionData *data)
         client_action_start(data);
         client_resize(c, c->area.width, c->area.height +
                       data->relative.deltax * c->size_inc.height);
-        client_action_end(data);
+        client_action_end(data, FALSE);
     }
 }
 
@@ -1479,42 +1465,51 @@ void action_move_relative(union ActionData *data)
     client_action_start(data);
     client_move(c, c->area.x + data->relative.deltax, c->area.y +
                 data->relative.deltay);
-    client_action_end(data);
+    client_action_end(data, FALSE);
 }
 
 void action_resize_relative(union ActionData *data)
 {
     ObClient *c = data->relative.any.c;
-    gint x, y, ow, w, oh, h, lw, lh;
+    gint x, y, ow, xoff, nw, oh, yoff, nh, lw, lh;
 
     client_action_start(data);
 
     x = c->area.x;
     y = c->area.y;
     ow = c->area.width;
-    w = ow + data->relative.deltax * c->size_inc.width
+    xoff = -data->relative.deltaxl * c->size_inc.width;
+    nw = ow + data->relative.deltax * c->size_inc.width
         + data->relative.deltaxl * c->size_inc.width;
     oh = c->area.height;
-    h = oh + data->relative.deltay * c->size_inc.height
+    yoff = -data->relative.deltayu * c->size_inc.height;
+    nh = oh + data->relative.deltay * c->size_inc.height
         + data->relative.deltayu * c->size_inc.height;
+
+    g_print("deltax %d %d x %d ow %d xoff %d nw %d\n",
+            data->relative.deltax, 
+            data->relative.deltaxl, 
+            x, ow, xoff, nw);
     
-    client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE);
-    client_move_resize(c, x + (ow - w), y + (oh - h), w, h);
-    client_action_end(data);
+    client_try_configure(c, &x, &y, &nw, &nh, &lw, &lh, TRUE);
+    xoff = xoff == 0 ? 0 : (xoff < 0 ? MAX(xoff, ow-nw) : MIN(xoff, ow-nw));
+    yoff = yoff == 0 ? 0 : (yoff < 0 ? MAX(yoff, oh-nh) : MIN(yoff, oh-nh));
+    client_move_resize(c, x + xoff, y + yoff, nw, nh);
+    client_action_end(data, FALSE);
 }
 
 void action_maximize_full(union ActionData *data)
 {
     client_action_start(data);
     client_maximize(data->client.any.c, TRUE, 0);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_unmaximize_full(union ActionData *data)
 {
     client_action_start(data);
     client_maximize(data->client.any.c, FALSE, 0);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_maximize_full(union ActionData *data)
@@ -1524,21 +1519,21 @@ void action_toggle_maximize_full(union ActionData *data)
                     !(data->client.any.c->max_horz ||
                       data->client.any.c->max_vert),
                     0);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_maximize_horz(union ActionData *data)
 {
     client_action_start(data);
     client_maximize(data->client.any.c, TRUE, 1);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_unmaximize_horz(union ActionData *data)
 {
     client_action_start(data);
     client_maximize(data->client.any.c, FALSE, 1);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_maximize_horz(union ActionData *data)
@@ -1546,21 +1541,21 @@ void action_toggle_maximize_horz(union ActionData *data)
     client_action_start(data);
     client_maximize(data->client.any.c,
                     !data->client.any.c->max_horz, 1);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_maximize_vert(union ActionData *data)
 {
     client_action_start(data);
     client_maximize(data->client.any.c, TRUE, 2);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_unmaximize_vert(union ActionData *data)
 {
     client_action_start(data);
     client_maximize(data->client.any.c, FALSE, 2);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_maximize_vert(union ActionData *data)
@@ -1568,14 +1563,14 @@ void action_toggle_maximize_vert(union ActionData *data)
     client_action_start(data);
     client_maximize(data->client.any.c,
                     !data->client.any.c->max_vert, 2);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_fullscreen(union ActionData *data)
 {
     client_action_start(data);
     client_fullscreen(data->client.any.c, !(data->client.any.c->fullscreen));
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_send_to_desktop(union ActionData *data)
@@ -1661,7 +1656,7 @@ void action_toggle_decorations(union ActionData *data)
 
     client_action_start(data);
     client_set_undecorated(c, !c->undecorated);
-    client_action_end(data);
+    client_action_end(data, FALSE);
 }
 
 static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
@@ -1894,7 +1889,7 @@ void action_movetoedge(union ActionData *data)
     frame_frame_gravity(c->frame, &x, &y, c->area.width, c->area.height);
     client_action_start(data);
     client_move(c, x, y);
-    client_action_end(data);
+    client_action_end(data, FALSE);
 }
 
 void action_growtoedge(union ActionData *data)
@@ -1903,7 +1898,7 @@ void action_growtoedge(union ActionData *data)
     ObClient *c = data->diraction.any.c;
     Rect *a;
 
-    a = screen_area(c->desktop);
+    a = screen_area(c->desktop, SCREEN_AREA_ALL_MONITORS, &c->frame->area);
     x = c->frame->area.x;
     y = c->frame->area.y;
     /* get the unshaded frame's dimensions..if it is shaded */
@@ -1961,7 +1956,8 @@ void action_growtoedge(union ActionData *data)
     frame_frame_gravity(c->frame, &x, &y, width, height);
     client_action_start(data);
     client_move_resize(c, x, y, width, height);
-    client_action_end(data);
+    client_action_end(data, FALSE);
+    g_free(a);
 }
 
 void action_send_to_layer(union ActionData *data)
@@ -1978,7 +1974,7 @@ void action_toggle_layer(union ActionData *data)
         client_set_layer(c, c->below ? 0 : -1);
     else if (data->layer.layer > 0)
         client_set_layer(c, c->above ? 0 : 1);
-    client_action_end(data);
+    client_action_end(data, config_focus_under_mouse);
 }
 
 void action_toggle_dockautohide(union ActionData *data)
This page took 0.030282 seconds and 4 git commands to generate.