]> git.sur5r.net Git - i3/i3/commitdiff
Added a "jump" command to directly focus a container.
authorUrs Ganse <urs@nerd2nerd.org>
Sun, 29 Mar 2009 12:53:48 +0000 (14:53 +0200)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Tue, 5 May 2009 14:47:05 +0000 (16:47 +0200)
Syntax is "jump <ws> <row> <col>".
This is quite handy for clients that you always keep
in the same spot, and like to jump to quite often. The
irc client would be an example.

src/commands.c

index 09c21b3488e23861df77c391700118451d6340ae..60e5a08f09fd7f18c63591820f9ab533c0532c61 100644 (file)
@@ -585,6 +585,39 @@ void show_workspace(xcb_connection_t *conn, int workspace) {
         render_layout(conn);
 }
 
+/*
+ * Jump directly to the specified workspace, row and col.
+ * Great for reaching windows that you always keep in the
+ * same spot (hello irssi, I'm looking at you)
+ */
+static void jump_to_container(xcb_connection_t *conn, const char* arg_str) {
+        int ws,row,col;
+        int result;
+
+        result = sscanf(arg_str, "%i %i %i", &ws, &row, &col);
+        LOG("Jump called with parameters '%s', which parses as %i numbers\n", arg_str, result);
+
+        /* No match? (This is technically a syntax error, but who cares.) */
+        if(result < 1)
+          return;
+
+        /* Move to the target workspace */
+        show_workspace(conn, ws);
+
+        if(result < 3)
+          return;
+
+        /* Move to row/col */
+        if(row >= c_ws->rows)
+          row = c_ws->rows - 1;
+        if(col >= c_ws->cols)
+          col = c_ws->cols - 1;
+
+        LOG("Jumping to row %i, col %i\n", row, col);
+        if (c_ws->table[col][row]->currently_focused != NULL)
+                set_focus(conn, c_ws->table[col][row]->currently_focused);
+}
+
 /*
  * Parses a command, see file CMDMODE for more information
  *
@@ -626,6 +659,12 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                 return;
         }
 
+        /* Is it a jump to a specified workspae,row,col? */
+        if (STARTS_WITH(command, "jump ")) {
+                jump_to_container(conn, command+strlen("jump "));
+                return;
+        }
+
         /* Is it 'f' for fullscreen? */
         if (command[0] == 'f') {
                 if (CUR_CELL->currently_focused == NULL)