]> git.sur5r.net Git - i3/i3/commitdiff
added a move mode and command
authorbatman <batman@batz-laptop.localdomain>
Thu, 15 Apr 2010 17:40:18 +0000 (10:40 -0700)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 17 Apr 2010 21:08:56 +0000 (23:08 +0200)
src/commands.c

index b2649beeec1f7b22d11afa771f3ea600c2d06370..0f970e9d85bb961188f6d2944d1469dac55719eb 100644 (file)
@@ -866,6 +866,35 @@ static void next_previous_workspace(xcb_connection_t *conn, int direction) {
         }
 }
 
+static void parse_move_command(xcb_connection_t *conn, Client *last_focused, const char *command) {
+        int first, second;
+        resize_orientation_t orientation = O_VERTICAL;
+        Container *con = last_focused->container;
+        Workspace *ws = last_focused->workspace;
+        if (client_is_floating(last_focused)) {
+                DLOG("Moving a floating client\n");
+                if (STARTS_WITH(command, "left")) {
+                        command += strlen("left");
+                        last_focused->rect.x -= atoi(command);
+                } else if (STARTS_WITH(command, "right")) {
+                        command += strlen("right");
+                        last_focused->rect.x += atoi(command);
+                } else if (STARTS_WITH(command, "top")) {
+                        command += strlen("top");
+                        last_focused->rect.y -= atoi(command);
+                } else if (STARTS_WITH(command, "bottom")) {
+                        command += strlen("bottom");
+                        last_focused->rect.y += atoi(command);
+                } else {
+                        ELOG("Syntax: move <left|right|top|bottom> <pixels>\n");
+                        return;
+                }
+                /* resize_client flushes */
+                resize_client(conn, last_focused);
+                return;
+        }
+}
+
 static void parse_resize_command(xcb_connection_t *conn, Client *last_focused, const char *command) {
         int first, second;
         resize_orientation_t orientation = O_VERTICAL;
@@ -1030,6 +1059,14 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                 return;
         }
 
+        if (STARTS_WITH(command, "move ")) {
+                if (last_focused == NULL)
+                        return;
+                const char *rest = command + strlen("move ");
+                parse_move_command(conn, last_focused, rest);
+                return;
+        }
+
         if (STARTS_WITH(command, "mode ")) {
                 const char *rest = command + strlen("mode ");
                 switch_mode(conn, rest);