]> git.sur5r.net Git - i3/i3/commitdiff
Make 'move' handle floating windows properly
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 27 Oct 2011 20:46:15 +0000 (21:46 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 27 Oct 2011 20:46:15 +0000 (21:46 +0100)
This means you can now specify an amount of pixels for the move command. The
default is 10. Note that this of course only works for floating windows.

Example:
  move left 20 px

src/cmdparse.y

index 3eb33426b0f9a3248e8de83339ec0ce1fa6d2bad..0144524b369ad4809aada3819d2e206f100a00cf 100644 (file)
@@ -734,10 +734,27 @@ border_style:
     ;
 
 move:
-    TOK_MOVE direction
+    TOK_MOVE direction resize_px
     {
-        printf("moving in direction %d\n", $2);
-        tree_move($2);
+        int direction = $2;
+        int px = $3;
+
+        /* TODO: make 'move' work with criteria. */
+        printf("moving in direction %d\n", direction);
+        if (con_is_floating(focused)) {
+            printf("floating move with %d pixels\n", px);
+            if (direction == TOK_LEFT) {
+                focused->parent->rect.x -= px;
+            } else if (direction == TOK_RIGHT) {
+                focused->parent->rect.x += px;
+            } else if (direction == TOK_UP) {
+                focused->parent->rect.y -= px;
+            } else if (direction == TOK_DOWN) {
+                focused->parent->rect.y += px;
+            }
+        } else {
+            tree_move(direction);
+        }
 
         tree_render();
     }