]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Correctly check boundaries and reassign floating windows when moving (Thanks...
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 18 Dec 2011 17:24:27 +0000 (17:24 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 18 Dec 2011 17:24:27 +0000 (17:24 +0000)
Fixes: #592
include/floating.h
src/cmdparse.y
src/floating.c
src/handlers.c

index e97029f5bb4e0e1a4198ac3db18e93b5122679cc..b6c7c6e37176b4657f7ad66fb619f29071257be0 100644 (file)
@@ -137,4 +137,13 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event,
                   xcb_window_t confine_to, border_t border, callback_t callback,
                   const void *extra);
 
+/**
+ * Repositions the CT_FLOATING_CON to have the coordinates specified by
+ * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
+ * the floating con to a different workspace if this move was across different
+ * outputs.
+ *
+ */
+void floating_reposition(Con *con, Rect newrect);
+
 #endif
index 652f6adce3dd5010889d0ab3237e392b84cc0a62..7f86c8db1d7dd8965a0573cf5bb612f274994b84 100644 (file)
@@ -780,20 +780,21 @@ move:
         printf("moving in direction %d\n", direction);
         if (con_is_floating(focused)) {
             printf("floating move with %d pixels\n", px);
+            Rect newrect = focused->parent->rect;
             if (direction == TOK_LEFT) {
-                focused->parent->rect.x -= px;
+                newrect.x -= px;
             } else if (direction == TOK_RIGHT) {
-                focused->parent->rect.x += px;
+                newrect.x += px;
             } else if (direction == TOK_UP) {
-                focused->parent->rect.y -= px;
+                newrect.y -= px;
             } else if (direction == TOK_DOWN) {
-                focused->parent->rect.y += px;
+                newrect.y += px;
             }
+            floating_reposition(focused->parent, newrect);
         } else {
             tree_move(direction);
+            tree_render();
         }
-
-        tree_render();
     }
     | TOK_MOVE TOK_WORKSPACE STR
     {
index 90e5024e8dc11773cd5711ef902b001368c3e497..d86ee2c0f6c8a176ced7cf86894e8c2e20f28b7a 100644 (file)
@@ -514,6 +514,31 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t
     xcb_flush(conn);
 }
 
+/*
+ * Repositions the CT_FLOATING_CON to have the coordinates specified by
+ * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
+ * the floating con to a different workspace if this move was across different
+ * outputs.
+ *
+ */
+void floating_reposition(Con *con, Rect newrect) {
+    /* Sanity check: Are the new coordinates on any output? If not, we
+     * ignore that request. */
+    Output *output = get_output_containing(
+        newrect.x + (newrect.width / 2),
+        newrect.y + (newrect.height / 2));
+
+    if (!output) {
+        ELOG("No output found at destination coordinates. Not repositioning.\n");
+        return;
+    }
+
+    con->rect = newrect;
+
+    floating_maybe_reassign_ws(con);
+    tree_render();
+}
+
 #if 0
 /*
  * Moves the client 10px to the specified direction.
index 61a2e1752b2426c67be314bf832f218c4f7e1c9c..69c1831d1326ce5617308f72215068ea5e7f9eb9 100644 (file)
@@ -400,23 +400,9 @@ static int handle_configure_request(xcb_configure_request_event_t *event) {
                  event->height, newrect.height, con->border_width);
         }
 
-        /* Sanity check: Are the new coordinates on any output? If not, we
-         * ignore that request. */
-        Output *output = get_output_containing(
-            newrect.x + (newrect.width / 2),
-            newrect.y + (newrect.height / 2));
-
-        if (!output) {
-            ELOG("No output found at destination coordinates. Ignoring this ConfigureRequest.\n");
-            fake_absolute_configure_notify(con);
-            return 0;
-        }
-
         DLOG("Container is a floating leaf node, will do that.\n");
-        floatingcon->rect = newrect;
-
-        floating_maybe_reassign_ws(floatingcon);
-        tree_render();
+        floating_reposition(floatingcon, newrect);
+        return 1;
     }
 
     /* Dock windows can be reconfigured in their height */