]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #2040 from Airblader/bug-2034
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 27 Oct 2015 09:07:25 +0000 (10:07 +0100)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 27 Oct 2015 09:07:25 +0000 (10:07 +0100)
Fix crash when trying to split and float a dock container.

1  2 
src/commands.c

diff --combined src/commands.c
index d6c0b78834ca3dc97f29cd35b2cfd84382f48dbc,7f196bdc9da966eabb6233cd52133345192f17e3..2b6e7dfe29f3ae49a6f17ef2059513c2213a66be
@@@ -403,17 -403,16 +403,17 @@@ void cmd_move_con_to_workspace_back_and
  }
  
  /*
 - * Implementation of 'move [window|container] [to] workspace <name>'.
 + * Implementation of 'move [--no-auto-back-and-forth] [window|container] [to] workspace <name>'.
   *
   */
 -void cmd_move_con_to_workspace_name(I3_CMD, const char *name) {
 +void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *_no_auto_back_and_forth) {
      if (strncasecmp(name, "__", strlen("__")) == 0) {
          LOG("You cannot move containers to i3-internal workspaces (\"%s\").\n", name);
          ysuccess(false);
          return;
      }
  
 +    const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
      owindow *current;
  
      /* We have nothing to move:
      /* get the workspace */
      Con *ws = workspace_get(name, NULL);
  
 -    ws = maybe_auto_back_and_forth_workspace(ws);
 +    if (!no_auto_back_and_forth)
 +        ws = maybe_auto_back_and_forth_workspace(ws);
  
      HANDLE_EMPTY_MATCH;
  
  }
  
  /*
 - * Implementation of 'move [window|container] [to] workspace number <name>'.
 + * Implementation of 'move [--no-auto-back-and-forth] [window|container] [to] workspace number <name>'.
   *
   */
 -void cmd_move_con_to_workspace_number(I3_CMD, const char *which) {
 +void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *_no_auto_back_and_forth) {
 +    const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
      owindow *current;
  
      /* We have nothing to move:
          workspace = workspace_get(which, NULL);
      }
  
 -    workspace = maybe_auto_back_and_forth_workspace(workspace);
 +    if (!no_auto_back_and_forth)
 +        workspace = maybe_auto_back_and_forth_workspace(workspace);
  
      HANDLE_EMPTY_MATCH;
  
@@@ -1192,16 -1188,18 +1192,18 @@@ void cmd_move_workspace_to_output(I3_CM
   *
   */
  void cmd_split(I3_CMD, const char *direction) {
+     HANDLE_EMPTY_MATCH;
      owindow *current;
-     /* TODO: use matches */
      LOG("splitting in direction %c\n", direction[0]);
-     if (match_is_empty(current_match))
-         tree_split(focused, (direction[0] == 'v' ? VERT : HORIZ));
-     else {
-         TAILQ_FOREACH(current, &owindows, owindows) {
-             DLOG("matching: %p / %s\n", current->con, current->con->name);
-             tree_split(current->con, (direction[0] == 'v' ? VERT : HORIZ));
+     TAILQ_FOREACH(current, &owindows, owindows) {
+         if (con_is_docked(current->con)) {
+             ELOG("Cannot split a docked container, skipping.\n");
+             continue;
          }
+         DLOG("matching: %p / %s\n", current->con, current->con->name);
+         tree_split(current->con, (direction[0] == 'v' ? VERT : HORIZ));
      }
  
      cmd_output->needs_tree_render = true;
@@@ -1528,9 -1526,10 +1530,10 @@@ 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";
-     owindow *current;
      layout_t layout;
      /* default is a special case which will be handled in con_set_layout(). */
      if (strcmp(layout_str, "default") == 0)
  
      DLOG("changing layout to %s (%d)\n", layout_str, layout);
  
-     /* check if the match is empty, not if the result is empty */
-     if (match_is_empty(current_match))
-         con_set_layout(focused, layout);
-     else {
-         TAILQ_FOREACH(current, &owindows, owindows) {
-             DLOG("matching: %p / %s\n", current->con, current->con->name);
-             con_set_layout(current->con, layout);
+     owindow *current;
+     TAILQ_FOREACH(current, &owindows, owindows) {
+         if (con_is_docked(current->con)) {
+             ELOG("cannot change layout of a docked container, skipping it.\n");
+             continue;
          }
+         DLOG("matching: %p / %s\n", current->con, current->con->name);
+         con_set_layout(current->con, layout);
      }
  
      cmd_output->needs_tree_render = true;