- Floating
-
-
- + +
- | toggle floating
-
- |
- +
- | drag floating
- |
+ + + e
+ | exit i3
+
+
@@ -176,7 +188,7 @@
All rights reserved
- Designed by Zeus Panchenko
+ Designed by Zeus Panchenko, updated by Moritz Bandemer
Permission is granted to copy, distribute and/or modify this document provided
From 4611f875ffe50b05af7b347bb4600c58f8d7acaf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20L=C3=B6bl?=
Date: Wed, 9 May 2012 23:39:44 +0200
Subject: [PATCH 009/200] Fix a mistake in comment
---
src/commands.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/commands.c b/src/commands.c
index cf8187b7..c3f7e4c4 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -23,7 +23,7 @@
} while (0)
/** When the command did not include match criteria (!), we use the currently
- * focused command. Do not confuse this case with a command which included
+ * focused container. Do not confuse this case with a command which included
* criteria but which did not match any windows. This macro has to be called in
* every command.
*/
From 51173baf28a7dcec2a75f1410e95ac9569c48f40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20L=C3=B6bl?=
Date: Wed, 9 May 2012 23:43:21 +0200
Subject: [PATCH 010/200] Fix 'move to workspace' when used with criteria
When moving window from other (not current) workspace to another
workspace with criteria we should stay on current workspace.
And we should exit early when criteria was specified but didn't
match any window.
---
src/commands.c | 25 +++++++++++++++++++------
src/con.c | 18 ++++++++++++++++--
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/src/commands.c b/src/commands.c
index c3f7e4c4..17d700c4 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -359,6 +359,15 @@ void cmd_move_con_to_workspace(I3_CMD, char *which) {
DLOG("which=%s\n", which);
+ /* We have nothing to move:
+ * when criteria was specified but didn't match any window or
+ * when criteria wasn't specified and we don't have any window focused. */
+ if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
+ (match_is_empty(current_match) && focused->type == CT_WORKSPACE)) {
+ ysuccess(false);
+ return;
+ }
+
HANDLE_EMPTY_MATCH;
/* get the workspace */
@@ -400,9 +409,11 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
owindow *current;
- /* Error out early to not create a non-existing workspace (in
- * workspace_get()) if we are not actually able to move anything. */
- if (match_is_empty(current_match) && focused->type == CT_WORKSPACE) {
+ /* We have nothing to move:
+ * when criteria was specified but didn't match any window or
+ * when criteria wasn't specified and we don't have any window focused. */
+ if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
+ (match_is_empty(current_match) && focused->type == CT_WORKSPACE)) {
ysuccess(false);
return;
}
@@ -430,9 +441,11 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
owindow *current;
- /* Error out early to not create a non-existing workspace (in
- * workspace_get()) if we are not actually able to move anything. */
- if (match_is_empty(current_match) && focused->type == CT_WORKSPACE) {
+ /* We have nothing to move:
+ * when criteria was specified but didn't match any window or
+ * when criteria wasn't specified and we don't have any window focused. */
+ if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
+ (match_is_empty(current_match) && focused->type == CT_WORKSPACE)) {
ysuccess(false);
return;
}
diff --git a/src/con.c b/src/con.c
index a1491e03..f804a204 100644
--- a/src/con.c
+++ b/src/con.c
@@ -587,6 +587,16 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
con = con->parent;
}
+ Con *source_ws = con_get_workspace(con);
+ if (workspace == source_ws) {
+ DLOG("Not moving, already there\n");
+ return;
+ }
+
+ /* Save the current workspace. So we can call workspace_show() by the end
+ * of this function. */
+ Con *current_ws = con_get_workspace(focused);
+
Con *source_output = con_get_output(con),
*dest_output = con_get_output(workspace);
@@ -669,8 +679,12 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
/* Descend focus stack in case focus_next is a workspace which can
* occur if we move to the same workspace. Also show current workspace
* to ensure it is focused. */
- workspace_show(con_get_workspace(focus_next));
- con_focus(con_descend_focused(focus_next));
+ workspace_show(current_ws);
+
+ /* Set focus only if con was on current workspace before moving.
+ * Otherwise we would give focus to some window on different workspace. */
+ if (source_ws == current_ws)
+ con_focus(con_descend_focused(focus_next));
}
CALL(parent, on_remove_child);
From 2afecaf35532c19f5d51440942c66572b8ab5653 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20L=C3=B6bl?=
Date: Wed, 9 May 2012 23:45:12 +0200
Subject: [PATCH 011/200] Add a new command 'move to workspace current'
Added a new command 'move to workspace current' which can be used
with criteria to move a window to the current workspace.
---
docs/userguide | 20 ++++++++++++++++++--
parser-specs/commands.spec | 4 ++--
src/commands.c | 4 +++-
testcases/t/132-move-workspace.t | 20 ++++++++++++++++++++
4 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/docs/userguide b/docs/userguide
index 41452793..37ddf4f8 100644
--- a/docs/userguide
+++ b/docs/userguide
@@ -1293,8 +1293,9 @@ You can also switch to the next and previous workspace with the commands
workspace 1, 3, 4 and 9 and you want to cycle through them with a single key
combination. To restrict those to the current output, use +workspace
next_on_output+ and +workspace prev_on_output+. Similarly, you can use +move
-container to workspace next+ and +move container to workspace prev+ to move a
-container to the next/previous workspace.
+container to workspace next+, +move container to workspace prev+ to move a
+container to the next/previous workspace and +move container to workspace current+
+(the last one makes sense only when used with criteria).
[[back_and_forth]]
To switch back to the previously focused workspace, use +workspace
@@ -1310,6 +1311,18 @@ you can use the +move workspace to output+ command followed by the name of the
target output. You may also use +left+, +right+, +up+, +down+ instead of the
xrandr output name to move to the next output in the specified direction.
+*Syntax*:
+-----------------------------------
+workspace
+workspace back_and_forth
+workspace
+workspace number
+
+move [window|container] [to] workspace
+move [window|container] [to] workspace number
+move [window|container] [to] workspace
+-----------------------------------
+
*Examples*:
-------------------------
bindsym mod+1 workspace 1
@@ -1325,6 +1338,9 @@ bindsym mod+b workspace back_and_forth
# move the whole workspace to the next output
bindsym mod+x move workspace to output right
+
+# move firefox to current workspace
+bindsym mod+F1 [class="Firefox"] move workspace current
-------------------------
==== Named workspaces
diff --git a/parser-specs/commands.spec b/parser-specs/commands.spec
index 684fd23e..100e5f4e 100644
--- a/parser-specs/commands.spec
+++ b/parser-specs/commands.spec
@@ -190,7 +190,7 @@ state RENAME_WORKSPACE_TO:
-> call cmd_rename_workspace($old_name, $new_name)
# move [ [px]]
-# move [window|container] [to] workspace
+# move [window|container] [to] workspace [|next|prev|current]
# move [window|container] [to] output
# move [window|container] [to] scratchpad
# move workspace to [output]
@@ -231,7 +231,7 @@ state MOVE_DIRECTION_PX:
state MOVE_WORKSPACE:
'to'
-> MOVE_WORKSPACE_TO_OUTPUT
- workspace = 'next', 'prev', 'next_on_output', 'prev_on_output'
+ workspace = 'next', 'prev', 'next_on_output', 'prev_on_output', 'current'
-> call cmd_move_con_to_workspace($workspace)
'number'
-> MOVE_WORKSPACE_NUMBER
diff --git a/src/commands.c b/src/commands.c
index 17d700c4..6f0d0c5e 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -351,7 +351,7 @@ void cmd_criteria_add(I3_CMD, char *ctype, char *cvalue) {
/*
* Implementation of 'move [window|container] [to] workspace
- * next|prev|next_on_output|prev_on_output'.
+ * next|prev|next_on_output|prev_on_output|current'.
*
*/
void cmd_move_con_to_workspace(I3_CMD, char *which) {
@@ -380,6 +380,8 @@ void cmd_move_con_to_workspace(I3_CMD, char *which) {
ws = workspace_next_on_output();
else if (strcmp(which, "prev_on_output") == 0)
ws = workspace_prev_on_output();
+ else if (strcmp(which, "current") == 0)
+ ws = con_get_workspace(focused);
else {
ELOG("BUG: called with which=%s\n", which);
ysuccess(false);
diff --git a/testcases/t/132-move-workspace.t b/testcases/t/132-move-workspace.t
index 3f00428c..79753cd7 100644
--- a/testcases/t/132-move-workspace.t
+++ b/testcases/t/132-move-workspace.t
@@ -99,6 +99,26 @@ cmd 'move workspace prev';
ok(@{get_ws_content($tmp)} == 3, 'three containers on first ws');
ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
+###################################################################
+# check if 'move workspace current' works
+###################################################################
+
+$tmp = get_unused_workspace();
+$tmp2 = get_unused_workspace();
+
+cmd "workspace $tmp";
+$first = open_window(name => 'win-name');
+ok(@{get_ws_content($tmp)} == 1, 'one container on first ws');
+
+cmd "workspace $tmp2";
+ok(@{get_ws_content($tmp2)} == 0, 'no containers yet');
+
+cmd qq|[title="win-name"] move workspace $tmp2|;
+ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
+
+cmd qq|[title="win-name"] move workspace $tmp|;
+ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
+
###################################################################
# check if floating cons are moved to new workspaces properly
# (that is, if they are floating on the target ws, too)
From ecd238b65eba9754f0e017b9bc953af5a6069799 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
Date: Sun, 3 Jun 2012 19:44:42 +0200
Subject: [PATCH 012/200] ignore "current" when searching for named workspaces
---
src/workspace.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/workspace.c b/src/workspace.c
index 928f0bd6..3d08fa4c 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -114,14 +114,15 @@ Con *create_workspace_on_output(Output *output, Con *content) {
/* We check if this is the workspace
* next/prev/next_on_output/prev_on_output/back_and_forth/number command.
* Beware: The workspace names "next", "prev", "next_on_output",
- * "prev_on_output", "number" and "back_and_forth" are OK, so we check
- * before stripping the double quotes */
+ * "prev_on_output", "number", "back_and_forth" and "current" are OK,
+ * so we check before stripping the double quotes */
if (strncasecmp(target, "next", strlen("next")) == 0 ||
strncasecmp(target, "prev", strlen("prev")) == 0 ||
strncasecmp(target, "next_on_output", strlen("next_on_output")) == 0 ||
strncasecmp(target, "prev_on_output", strlen("prev_on_output")) == 0 ||
strncasecmp(target, "number", strlen("number")) == 0 ||
- strncasecmp(target, "back_and_forth", strlen("back_and_forth")) == 0)
+ strncasecmp(target, "back_and_forth", strlen("back_and_forth")) == 0 ||
+ strncasecmp(target, "current", strlen("current")) == 0)
continue;
if (*target == '"')
target++;
From 19946ee14d2e4262165f05c717c59143e581db19 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
Date: Fri, 29 Jun 2012 21:21:07 +0200
Subject: [PATCH 013/200] tests: make t/159-socketpath more robust
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
…by getting the socket path from i3 and then checking that it conforms
to what we expect. Previously we monitored /tmp, which can go wrong in
various ways, especially since i3’s directory within /tmp is not
predictable (by design).
---
testcases/t/159-socketpaths.t | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/testcases/t/159-socketpaths.t b/testcases/t/159-socketpaths.t
index c63bbbc4..7c3946b4 100644
--- a/testcases/t/159-socketpaths.t
+++ b/testcases/t/159-socketpaths.t
@@ -5,6 +5,7 @@
#
use i3test i3_autostart => 0;
use File::Temp qw(tempfile tempdir);
+use File::Basename;
use POSIX qw(getuid);
use v5.10;
@@ -20,21 +21,14 @@ EOT
# ensure XDG_RUNTIME_DIR is not set
delete $ENV{XDG_RUNTIME_DIR};
-# See which files exist in /tmp before to not mistakenly check an already
-# existing tmpdir of another i3 instance.
-my @files_before = ;
my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
-my @files_after = ;
-@files_after = grep { !($_ ~~ @files_before) } @files_after;
-
-is(@files_after, 1, 'one new temp directory');
-
+my $socketpath = get_socket_path(0);
my $folder = "/tmp/i3-" . getpwuid(getuid());
-like($files_after[0], qr/^$folder/, 'temp directory matches expected pattern');
-$folder = $files_after[0];
+like(dirname($socketpath), qr/^$folder/, 'temp directory matches expected pattern');
+$folder = dirname($socketpath);
ok(-d $folder, "folder $folder exists");
-my $socketpath = "$folder/ipc-socket." . $pid;
+$socketpath = "$folder/ipc-socket." . $pid;
ok(-S $socketpath, "file $socketpath exists and is a socket");
exit_gracefully($pid);
From daee3218c9aec3499bf128ba1649099d4f93bcd9 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
Date: Fri, 29 Jun 2012 21:28:10 +0200
Subject: [PATCH 014/200] tests: make t/166-assign.t more robust
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
…by using the new syntax which will not trigger i3-nagbar. Checking for
i3-nagbar is inherently prone to race conditions since i3-nagbar does
not communicate in any way that it’s there.
---
testcases/t/166-assign.t | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/testcases/t/166-assign.t b/testcases/t/166-assign.t
index d79c1000..a4a70c8b 100644
--- a/testcases/t/166-assign.t
+++ b/testcases/t/166-assign.t
@@ -206,24 +206,16 @@ sub i3nagbar_running {
$config = < $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
@@ -233,7 +225,7 @@ $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
ok(@{$content->{floating_nodes}} == 0, 'one floating con');
@docked = get_dock_clients;
-is(@docked, 2, 'two dock clients now');
+is(@docked, 1, 'one dock client now');
$window->destroy;
From c5d047215865fad385f4f91798e3e3bd3959ebea Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
Date: Fri, 29 Jun 2012 23:13:25 +0200
Subject: [PATCH 015/200] Explicitly disconnect in the 'exit' command
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes a race condition when running the tests. I think that the X11
server has more time to clean up the resources when we do an explicit
disconnect. The symptom I was seeing was that sometimes, i3 couldn’t
become the window manager on one of the Xdummy instances.
---
src/commands.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/commands.c b/src/commands.c
index 6f0d0c5e..f30d6612 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -1410,6 +1410,7 @@ void cmd_layout(I3_CMD, char *layout_str) {
*/
void cmd_exit(I3_CMD) {
LOG("Exiting due to user command.\n");
+ xcb_disconnect(conn);
exit(0);
/* unreached */
From f0f45aa84d5eee0002ee4eca2646ec92fae56746 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
Date: Fri, 29 Jun 2012 23:20:46 +0200
Subject: [PATCH 016/200] tests: t/166-assign.t: use wait_for_window
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
While it’s generally intended that wait_for_window is not called within
this testcase, in the first test instruction it was a mistake. The
window in fact gets mapped and therefore we should call wait_for_window.
---
testcases/t/166-assign.t | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/t/166-assign.t b/testcases/t/166-assign.t
index a4a70c8b..3a8a10d5 100644
--- a/testcases/t/166-assign.t
+++ b/testcases/t/166-assign.t
@@ -57,6 +57,7 @@ my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $window = open_special;
+wait_for_map($window);
ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace');
From a65394646cf24d679bd5c3d546db72e7cde6a65b Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
Date: Fri, 29 Jun 2012 23:21:32 +0200
Subject: [PATCH 017/200] tests: t/504: ensure cursor position
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Otherwise, the cursor might be at (1025, 0) due to previous testcases
and we wouldn’t start up on the correct workspace.
---
testcases/t/504-move-workspace-to-output.t | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testcases/t/504-move-workspace-to-output.t b/testcases/t/504-move-workspace-to-output.t
index 57e56943..8357e0da 100644
--- a/testcases/t/504-move-workspace-to-output.t
+++ b/testcases/t/504-move-workspace-to-output.t
@@ -9,6 +9,10 @@ use i3test i3_autostart => 0;
# TODO:
# introduce 'move workspace 3 to output |