]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #2649 from s3rb31/next
authorIngo Bürk <admin@airblader.de>
Thu, 23 Feb 2017 23:58:19 +0000 (00:58 +0100)
committerGitHub <noreply@github.com>
Thu, 23 Feb 2017 23:58:19 +0000 (00:58 +0100)
layout toggle: take any combination of layouts as arguments (continuation of #2476)

1  2 
docs/userguide
src/commands.c
src/util.c

diff --combined docs/userguide
index 69eeda3534e5843b2f33496b398cd41f53a72330,21d0862521edb5e698172a9f13773b57a0a4b84a..40e9e3b9ea24f63328643fe317bc23641a291b61
@@@ -479,7 -479,7 +479,7 @@@ mode <name
  
  *Example*:
  ------------------------------------------------------------------------
 -# Press $mod+o followed by either f, t, Esc or Return to launch firefox,
 +# Press $mod+o followed by either f, t, Escape or Return to launch firefox,
  # thunderbird or return to the default mode, respectively.
  set $mode_launcher Launch: [f]irefox [t]hunderbird
  bindsym $mod+o mode "$mode_launcher"
@@@ -488,7 -488,7 +488,7 @@@ mode "$mode_launcher" 
      bindsym f exec firefox
      bindsym t exec thunderbird
  
 -    bindsym Esc mode "default"
 +    bindsym Escape mode "default"
      bindsym Return mode "default"
  }
  ------------------------------------------------------------------------
@@@ -946,12 -946,12 +946,12 @@@ the next section
  
  === Focus follows mouse
  
 -By default, window focus follows your mouse movements. However, if you have a
 -setup where your mouse usually is in your way (like a touchpad on your laptop
 -which you do not want to disable completely), you might want to disable 'focus
 -follows mouse' and control focus only by using your keyboard.  The mouse will
 -still be useful inside the currently active window (for example to click on
 -links in your browser window).
 +By default, window focus follows your mouse movements as the mouse crosses
 +window borders. However, if you have a setup where your mouse usually is in your
 +way (like a touchpad on your laptop which you do not want to disable
 +completely), you might want to disable 'focus follows mouse' and control focus
 +only by using your keyboard.  The mouse will still be useful inside the
 +currently active window (for example to click on links in your browser window).
  
  *Syntax*:
  --------------------------
@@@ -1802,7 -1802,8 +1802,8 @@@ The +toggle+ option will toggle the ori
  contains a single window. Otherwise it makes the current window a split
  container with opposite orientation compared to the parent container.
  Use +layout toggle split+ to change the layout of any split container from
- splitv to splith or vice-versa.
+ splitv to splith or vice-versa. You can also define a custom sequence of layouts
+ to cycle through with +layout toggle+, see <<manipulating_layout>>.
  
  *Syntax*:
  --------------------------------
@@@ -1822,6 -1823,11 +1823,11 @@@ Use +layout toggle split+, +layout stac
  or +layout splith+ to change the current container layout to splith/splitv,
  stacking, tabbed layout, splitv or splith, respectively.
  
+ Specify up to four layouts after +layout toggle+ to cycle through them. Every
+ time the command is executed, the layout specified after the currently active
+ one will be applied. If the currently active layout is not in the list, the
+ first layout in the list will be activated.
  To make the current window (!) fullscreen, use +fullscreen enable+ (or
  +fullscreen enable global+ for the global mode), to leave either fullscreen
  mode use +fullscreen disable+, and to toggle between these two states use
@@@ -1834,6 -1840,7 +1840,7 @@@ enable+ respectively +floating disable
  --------------------------------------------
  layout default|tabbed|stacking|splitv|splith
  layout toggle [split|all]
+ layout toggle [split|tabbed|stacking|splitv|splith] [split|tabbed|stacking|splitv|splith]…
  --------------------------------------------
  
  *Examples*:
@@@ -1848,6 -1855,15 +1855,15 @@@ bindsym $mod+x layout toggl
  # Toggle between stacking/tabbed/splith/splitv:
  bindsym $mod+x layout toggle all
  
+ # Toggle between stacking/tabbed/splith:
+ bindsym $mod+x layout toggle stacking tabbed splith
+ # Toggle between splitv/tabbed
+ bindsym $mod+x layout toggle splitv tabbed
+ # Toggle between last split layout/tabbed/stacking
+ bindsym $mod+x layout toggle split tabbed stacking
  # Toggle fullscreen
  bindsym $mod+f fullscreen toggle
  
@@@ -2090,23 -2106,6 +2106,23 @@@ i3-msg 'rename workspace to "2: mail"
  bindsym $mod+r exec i3-input -F 'rename workspace to "%s"' -P 'New name: '
  --------------------------------------------------------------------------
  
 +If you want to rename workspaces on demand while keeping the navigation stable,
 +you can use a setup like this:
 +
 +*Example*:
 +-------------------------
 +bindsym $mod+1 workspace number "1: www"
 +bindsym $mod+2 workspace number "2: mail"
 +...
 +-------------------------
 +
 +If a workspace does not exist, the command +workspace number "1: mail"+ will
 +create workspace "1: mail".
 +
 +If a workspace with number 1 does already exist, the command will switch to this
 +workspace and ignore the text part. So even when the workspace has been renamed
 +to "1: web", the above command will still switch to it.
 +
  === Moving workspaces to a different screen
  
  See <<move_to_outputs>> for how to move a container/workspace to a different
diff --combined src/commands.c
index 56c07b6ab6fc9a4aa7dccf4017354b71a87b5273,44a5d8a441732b76cb7318abceaf6cd47630e457..33737f71187647609228d77d9cb24924d8816de0
@@@ -1489,21 -1489,8 +1489,8 @@@ void cmd_move_direction(I3_CMD, const c
  void cmd_layout(I3_CMD, const char *layout_str) {
      HANDLE_EMPTY_MATCH;
  
-     if (strcmp(layout_str, "stacking") == 0)
-         layout_str = "stacked";
      layout_t layout;
-     /* default is a special case which will be handled in con_set_layout(). */
-     if (strcmp(layout_str, "default") == 0)
-         layout = L_DEFAULT;
-     else if (strcmp(layout_str, "stacked") == 0)
-         layout = L_STACKED;
-     else if (strcmp(layout_str, "tabbed") == 0)
-         layout = L_TABBED;
-     else if (strcmp(layout_str, "splitv") == 0)
-         layout = L_SPLITV;
-     else if (strcmp(layout_str, "splith") == 0)
-         layout = L_SPLITH;
-     else {
+     if (!layout_from_name(layout_str, &layout)) {
          ELOG("Unknown layout \"%s\", this is a mismatch between code and parser spec.\n", layout_str);
          return;
      }
@@@ -1562,7 -1549,7 +1549,7 @@@ void cmd_exit(I3_CMD) 
  #ifdef I3_ASAN_ENABLED
      __lsan_do_leak_check();
  #endif
 -    ipc_shutdown();
 +    ipc_shutdown(SHUTDOWN_REASON_EXIT);
      unlink(config.ipc_socket_path);
      xcb_disconnect(conn);
      exit(0);
@@@ -1595,7 -1582,7 +1582,7 @@@ void cmd_reload(I3_CMD) 
   */
  void cmd_restart(I3_CMD) {
      LOG("restarting i3\n");
 -    ipc_shutdown();
 +    ipc_shutdown(SHUTDOWN_REASON_RESTART);
      unlink(config.ipc_socket_path);
      /* We need to call this manually since atexit handlers don’t get called
       * when exec()ing */
diff --combined src/util.c
index 5c8fc774bd389a8b710ea4755bb0e432f7379604,0289ded91f6a5a8a4a8dc1b6dbd9ae14f3de1465..06fbea2a7ef0856aa6a2ac0d71c07bce5ea85dd5
@@@ -66,6 -66,34 +66,34 @@@ __attribute__((pure)) bool name_is_digi
      return true;
  }
  
+ /*
+  * Set 'out' to the layout_t value for the given layout. The function
+  * returns true on success or false if the passed string is not a valid
+  * layout name.
+  *
+  */
+ bool layout_from_name(const char *layout_str, layout_t *out) {
+     if (strcmp(layout_str, "default") == 0) {
+         *out = L_DEFAULT;
+         return true;
+     } else if (strcasecmp(layout_str, "stacked") == 0 ||
+                strcasecmp(layout_str, "stacking") == 0) {
+         *out = L_STACKED;
+         return true;
+     } else if (strcasecmp(layout_str, "tabbed") == 0) {
+         *out = L_TABBED;
+         return true;
+     } else if (strcasecmp(layout_str, "splitv") == 0) {
+         *out = L_SPLITV;
+         return true;
+     } else if (strcasecmp(layout_str, "splith") == 0) {
+         *out = L_SPLITH;
+         return true;
+     }
+     return false;
+ }
  /*
   * Parses the workspace name as a number. Returns -1 if the workspace should be
   * interpreted as a "named workspace".
@@@ -259,7 -287,7 +287,7 @@@ void i3_restart(bool forget_layout) 
  
      restore_geometry();
  
 -    ipc_shutdown();
 +    ipc_shutdown(SHUTDOWN_REASON_RESTART);
  
      LOG("restarting \"%s\"...\n", start_argv[0]);
      /* make sure -a is in the argument list or add it */