]> git.sur5r.net Git - i3/i3/commitdiff
Implement moving of floating clients
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 19 Jun 2009 10:57:21 +0000 (12:57 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 19 Jun 2009 10:57:21 +0000 (12:57 +0200)
include/floating.h
src/commands.c
src/floating.c

index 93110bc25beb5380a289bde4c6266c5eddfa2786..020e91ff2a3a26d92513f43bfe9b84e2609580e2 100644 (file)
@@ -46,4 +46,10 @@ void floating_drag_window(xcb_connection_t *conn, Client *client, xcb_button_pre
  */
 void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused, direction_t direction);
 
+/**
+ * Moves the client 10px to the specified direction.
+ *
+ */
+void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction);
+
 #endif
index 10ac35f878681d2b893d1617b350f4f3295c2bbe..3300d1f890e43ec3bfa7315a0ce2a35cb9bf4581 100644 (file)
@@ -928,7 +928,8 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                 return;
         }
 
-        if (last_focused->floating >= FLOATING_AUTO_ON && action != ACTION_FOCUS) {
+        if (last_focused->floating >= FLOATING_AUTO_ON &&
+           (action != ACTION_FOCUS && action != ACTION_MOVE)) {
                 LOG("Not performing (floating)\n");
                 return;
         }
@@ -947,20 +948,32 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                         LOG("unknown direction: %c\n", *rest);
                         return;
                 }
+                rest++;
 
                 if (action == ACTION_FOCUS) {
-                        if (last_focused->floating >= FLOATING_AUTO_ON)
+                        if (last_focused->floating >= FLOATING_AUTO_ON) {
                                 floating_focus_direction(conn, last_focused, direction);
-                        else focus_thing(conn, direction, (with == WITH_WINDOW ? THING_WINDOW : THING_CONTAINER));
-                } else if (action == ACTION_MOVE) {
+                                continue;
+                        }
+                        focus_thing(conn, direction, (with == WITH_WINDOW ? THING_WINDOW : THING_CONTAINER));
+                        continue;
+                }
+
+                if (action == ACTION_MOVE) {
+                        if (last_focused->floating >= FLOATING_AUTO_ON) {
+                                floating_move(conn, last_focused, direction);
+                                continue;
+                        }
                         if (with == WITH_WINDOW)
                                 move_current_window(conn, direction);
                         else move_current_container(conn, direction);
+                        continue;
                 }
-                else if (action == ACTION_SNAP)
-                        snap_current_container(conn, direction);
 
-                rest++;
+                if (action == ACTION_SNAP) {
+                        snap_current_container(conn, direction);
+                        continue;
+                }
         }
 
         LOG("--- done ---\n");
index 7cf4b6dc553bf49063f4170a1dd6ae880256f273..fb5c95118ff8ea28dc81a06cb1c6df0c717f0ea3 100644 (file)
@@ -318,3 +318,40 @@ void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused,
                 }
         }
 }
+
+/*
+ * Moves the client 10px to the specified direction.
+ *
+ */
+void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction) {
+        LOG("floating move\n");
+
+        switch (direction) {
+                case D_LEFT:
+                        if (currently_focused->rect.x < 10)
+                                return;
+                        currently_focused->rect.x -= 10;
+                        break;
+                case D_RIGHT:
+                        currently_focused->rect.x += 10;
+                        break;
+                case D_UP:
+                        if (currently_focused->rect.y < 10)
+                                return;
+                        currently_focused->rect.y -= 10;
+                        break;
+                case D_DOWN:
+                        currently_focused->rect.y += 10;
+                        break;
+                /* to make static analyzers happy */
+                default:
+                        break;
+        }
+
+        reposition_client(conn, currently_focused);
+
+        /* Because reposition_client does not send a faked configure event (only resize does),
+         * we need to initiate that on our own */
+        fake_absolute_configure_notify(conn, currently_focused);
+        /* fake_absolute_configure_notify flushes */
+}