Bugfix: less differentiation between named and numbered workspaces

(upstream git commit b88ab981fd0a5725ed886a9f9788a5b1e721534c)

Bugfix: fix stray workspaces "number 1" being created when having
workspace number 1 in your config (upstream git commit
ec4e6d1cdf5b76c79da2879635e4094e25a01f3d)

Fix for i3bar: don't wrap when changing workspaces by mouse wheel
scrolling (upstream git commit 4f93e0587a849de00a1f50bfcd48a549009178c0)
This commit is contained in:
dcoppa 2012-05-28 13:37:50 +00:00
parent 54bbdb42f3
commit c34dcd9b3e
4 changed files with 200 additions and 2 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.35 2012/05/14 07:47:05 dcoppa Exp $
# $OpenBSD: Makefile,v 1.36 2012/05/28 13:37:50 dcoppa Exp $
COMMENT = improved dynamic tiling window manager
DISTNAME = i3-4.2
REVISION = 2
REVISION = 3
CATEGORIES = x11
EXTRACT_SUFX = .tar.bz2

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-i3bar_src_xcb_c,v 1.5 2012/05/28 13:37:50 dcoppa Exp $
From 4f93e0587a849de00a1f50bfcd48a549009178c0 Mon Sep 17 00:00:00 2001
From: TunnelWicht <MilkFreeze@web.de>
Date: Tue, 01 May 2012 11:35:34 +0000
Subject: don't wrap when changing workspaces by mouse wheel scrolling
--- i3bar/src/xcb.c.orig Wed Apr 25 23:21:25 2012
+++ i3bar/src/xcb.c Mon May 28 12:39:58 2012
@@ -302,17 +302,13 @@ void handle_button(xcb_button_press_event_t *event) {
break;
case 4:
/* Mouse wheel down. We select the next ws */
- if (cur_ws == TAILQ_FIRST(walk->workspaces)) {
- cur_ws = TAILQ_LAST(walk->workspaces, ws_head);
- } else {
+ if (cur_ws != TAILQ_FIRST(walk->workspaces)) {
cur_ws = TAILQ_PREV(cur_ws, ws_head, tailq);
}
break;
case 5:
/* Mouse wheel up. We select the previos ws */
- if (cur_ws == TAILQ_LAST(walk->workspaces, ws_head)) {
- cur_ws = TAILQ_FIRST(walk->workspaces);
- } else {
+ if (cur_ws != TAILQ_LAST(walk->workspaces, ws_head)) {
cur_ws = TAILQ_NEXT(cur_ws, tailq);
}
break;

View File

@ -0,0 +1,141 @@
$OpenBSD: patch-src_commands_c,v 1.1 2012/05/28 13:37:50 dcoppa Exp $
From b88ab981fd0a5725ed886a9f9788a5b1e721534c Mon Sep 17 00:00:00 2001
From: Ondrej Grover <ondrej.grover@gmail.com>
Date: Wed, 02 May 2012 14:05:27 +0000
Subject: bugfix: less differentiation between named and numbered workspaces
calling workspace by number now also checks for switching back and forth
and creates a new workspace if no workspace starting with that number is
found
also removed the obsolete tree_render() in favor of setting
cmd_output->needs_tree_render to true
From 4eab046e8fa40535d1a2ad80533915983ef0ee7e Mon Sep 17 00:00:00 2001
From: Fernando Tarla Cardoso Lemos <fernandotcl@gmail.com>
Date: Sat, 21 Apr 2012 19:34:25 +0000
Subject: Allow focus w/ target when in fs in some cases.
If the target is in a different workspace, there's no reason why
we wouldn't allow the user to focus it. We already allow this when
focusing a workspace, for example.
--- src/commands.c.orig Wed Apr 25 23:21:25 2012
+++ src/commands.c Mon May 28 13:50:28 2012
@@ -65,6 +65,28 @@ static Output *get_output_from_string(Output *current_
return output;
}
+/*
+ * Checks whether we switched to a new workspace and returns false in that case,
+ * signaling that further workspace switching should be done by the calling function
+ * If not, calls workspace_back_and_forth() if workspace_auto_back_and_forth is set
+ * and return true, signaling that no further workspace switching should occur in the calling function.
+ *
+ */
+static bool maybe_back_and_forth(struct CommandResult *cmd_output, char *name) {
+ Con *ws = con_get_workspace(focused);
+
+ /* If we switched to a different workspace, do nothing */
+ if (strcmp(ws->name, name) != 0)
+ return false;
+
+ DLOG("This workspace is already focused.\n");
+ if (config.workspace_auto_back_and_forth) {
+ workspace_back_and_forth();
+ cmd_output->needs_tree_render = true;
+ }
+ return true;
+}
+
// This code is commented out because we might recycle it for popping up error
// messages on parser errors.
#if 0
@@ -752,12 +774,19 @@ void cmd_workspace_number(I3_CMD, char *which) {
child->num == parsed_num);
if (!workspace) {
- LOG("There is no workspace with number %d.\n", parsed_num);
+ LOG("There is no workspace with number %d, creating a new one.\n", parsed_num);
cmd_output->json_output = sstrdup("{\"success\": false, "
"\"error\": \"No such workspace\"}");
+ /* terminate the which string after the endposition of the number */
+ *endptr = '\0';
+ if (maybe_back_and_forth(cmd_output, which))
+ return;
+ workspace_show_by_name(which);
+ cmd_output->needs_tree_render = true;
return;
}
-
+ if (maybe_back_and_forth(cmd_output, which))
+ return;
workspace_show(workspace);
cmd_output->needs_tree_render = true;
@@ -789,20 +818,8 @@ void cmd_workspace_name(I3_CMD, char *name) {
}
DLOG("should switch to workspace %s\n", name);
-
- Con *ws = con_get_workspace(focused);
-
- /* Check if the command wants to switch to the current workspace */
- if (strcmp(ws->name, name) == 0) {
- DLOG("This workspace is already focused.\n");
- if (config.workspace_auto_back_and_forth) {
- workspace_back_and_forth();
- tree_render();
- }
- cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
- }
-
+ if (maybe_back_and_forth(cmd_output, name))
+ return;
workspace_show_by_name(name);
cmd_output->needs_tree_render = true;
@@ -1196,16 +1213,7 @@ void cmd_focus_level(I3_CMD, char *level) {
*/
void cmd_focus(I3_CMD) {
DLOG("current_match = %p\n", current_match);
- if (focused &&
- focused->type != CT_WORKSPACE &&
- focused->fullscreen_mode != CF_NONE) {
- LOG("Cannot change focus while in fullscreen mode.\n");
- cmd_output->json_output = sstrdup("{\"sucess\": false}");
- return;
- }
- owindow *current;
-
if (match_is_empty(current_match)) {
ELOG("You have to specify which window/container should be focused.\n");
ELOG("Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
@@ -1217,12 +1225,24 @@ void cmd_focus(I3_CMD) {
}
int count = 0;
+ owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
Con *ws = con_get_workspace(current->con);
/* If no workspace could be found, this was a dock window.
* Just skip it, you cannot focus dock windows. */
if (!ws)
continue;
+
+ /* Don't allow the focus switch if the focused and current
+ * containers are in the same workspace. */
+ if (focused &&
+ focused->type != CT_WORKSPACE &&
+ focused->fullscreen_mode != CF_NONE &&
+ con_get_workspace(focused) == ws) {
+ LOG("Cannot change focus while in fullscreen mode (same workspace).\n");
+ cmd_output->json_output = sstrdup("{\"success\": false}");
+ return;
+ }
/* If the container is not on the current workspace,
* workspace_show() will switch to a different workspace and (if

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-src_workspace_c,v 1.6 2012/05/28 13:37:50 dcoppa Exp $
From ec4e6d1cdf5b76c79da2879635e4094e25a01f3d Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Wed, 16 May 2012 04:24:16 +0000
Subject: Fix stray workspaces "number 1" being created when having workspace number 1 in your config
--- src/workspace.c.orig Wed Apr 25 23:21:25 2012
+++ src/workspace.c Mon May 28 13:59:35 2012
@@ -112,14 +112,15 @@ Con *create_workspace_on_output(Output *output, Con *c
DLOG("relevant command = %s\n", bind->command);
char *target = bind->command + strlen("workspace ");
/* We check if this is the workspace
- * next/prev/next_on_output/prev_on_output/back_and_forth command.
+ * 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" and "back_and_forth" are OK, so we check before
- * stripping the double quotes */
+ * "prev_on_output", "number" and "back_and_forth" 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)
continue;
if (*target == '"')