]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #3389 from orestisf1993/resize-ensure-1px
authorIngo Bürk <admin@airblader.de>
Thu, 6 Sep 2018 06:41:00 +0000 (08:41 +0200)
committerGitHub <noreply@github.com>
Thu, 6 Sep 2018 06:41:00 +0000 (08:41 +0200)
Ensure containers have a size of at least 1px after resize

src/commands.c
testcases/t/522-rename-assigned-workspace.t
testcases/t/541-resize-set-tiling.t

index ab41ec97f4ac70d27023b618fda1c76f2b3b4830..e07509c49c5d7a85ffb9dc79695af1b72958497f 100644 (file)
@@ -695,13 +695,15 @@ void cmd_resize_set(I3_CMD, long cwidth, const char *mode_width, long cheight, c
                 continue;
             }
 
-            if (cwidth > 0 && mode_width) {
+            if (cwidth > 0) {
+                bool is_ppt = mode_width && strcmp(mode_width, "ppt") == 0;
                 success &= resize_set_tiling(current_match, cmd_output, current->con,
-                                             HORIZ, strcmp(mode_width, "ppt") == 0, cwidth);
+                                             HORIZ, is_ppt, cwidth);
             }
-            if (cheight > 0 && mode_height) {
+            if (cheight > 0) {
+                bool is_ppt = mode_height && strcmp(mode_height, "ppt") == 0;
                 success &= resize_set_tiling(current_match, cmd_output, current->con,
-                                             VERT, strcmp(mode_height, "ppt") == 0, cheight);
+                                             VERT, is_ppt, cheight);
             }
         }
     }
@@ -2003,6 +2005,7 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
     Con *parent = workspace->parent;
     con_detach(workspace);
     con_attach(workspace, parent, false);
+    ipc_send_workspace_event("rename", workspace, NULL);
 
     /* Move the workspace to the correct output if it has an assignment */
     struct Workspace_Assignment *assignment = NULL;
@@ -2047,7 +2050,6 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
     cmd_output->needs_tree_render = true;
     ysuccess(true);
 
-    ipc_send_workspace_event("rename", workspace, NULL);
     ewmh_update_desktop_names();
     ewmh_update_desktop_viewport();
     ewmh_update_current_desktop();
index 824f4a062ddba6be888842425c9fe69ed6e1f280..9897e4ee263860be01b52f8f185496282e3228ed 100644 (file)
@@ -82,16 +82,31 @@ is(get_output_for_workspace('5'), 'fake-0',
     'Renaming the workspace to a workspace assigned to a directional output should not move the workspace');
 
 ##########################################################################
-# Renaming a workspace, so that it becomes assigned to the focused
-# output's workspace (and the focused output is empty) should
-# result in the original workspace replacing the originally
-# focused workspace.
+# Renaming an unfocused workspace, triggering an assignment to the output
+# which holds the currently focused empty workspace should result in the
+# original workspace replacing the empty one.
+# See issue #3228.
 ##########################################################################
 
 cmd 'workspace baz';
 cmd 'rename workspace 5 to 2';
 is(get_output_for_workspace('2'), 'fake-1',
-    'Renaming a workspace so that it moves to the focused output which contains only an empty workspace should replace the empty workspace');
+    'Renaming an unfocused workspace, triggering an assignment to the output which holds the currently focused empty workspace should result in the original workspace replacing the empty one');
+
+##########################################################################
+# Renaming an unfocused empty workspace, triggering an assignment to the
+# output which holds the currently focused non-empty workspace should
+# close the empty workspace and not crash i3.
+# See issue #3248.
+##########################################################################
+
+cmd 'workspace 1';
+cmd 'workspace 2';
+open_window;
+cmd 'rename workspace 1 to baz';
+is(get_output_for_workspace('baz'), '',
+    'Renaming an unfocused empty workspace, triggering an assignment to the output which holds the currently focused non-empty workspace should close the empty workspace and not crash i3');
+kill_all_windows;
 
 ##########################################################################
 # Renaming a workspace with multiple assignments, where the first output
index d695edee41af60d357d777bc965515fed0bd5ec5..0298fecd31692b783f23f431145c57479d451455 100644 (file)
@@ -124,6 +124,14 @@ cmd 'resize set 155 px 135 px';
 cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{width}, 155, 'bottom-right window got 155 px width');
 cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{height}, 135, 'bottom-right window got 135 px height');
 
+# Without specifying mode
+cmd 'resize set 201 131';
+
+($nodes, $focus) = get_ws_content($tmp);
+
+cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{width}, 201, 'bottom-right window got 201 px width');
+cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{height}, 131, 'bottom-right window got 131 px height');
+
 # Mix ppt and px
 cmd 'resize set 75 ppt 200 px';