aboutsummaryrefslogtreecommitdiff
path: root/src/workspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/workspace.c')
-rw-r--r--src/workspace.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/workspace.c b/src/workspace.c
index 1cacebf3..8c58b9a8 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -614,6 +614,7 @@ Con *workspace_next(void) {
}
} else {
/* If currently a numbered workspace, find next numbered workspace. */
+ bool found_current = false;
TAILQ_FOREACH (output, &(croot->nodes_head), nodes) {
/* Skip outputs starting with __, they are internal. */
if (con_is_internal(output)) {
@@ -638,6 +639,14 @@ Con *workspace_next(void) {
if (current->num < child->num && (!next || child->num < next->num)) {
next = child;
}
+
+ /* If two workspaces have the same number, but different names
+ * (eg '5:a', '5:b') then just take the next one. */
+ if (child == current) {
+ found_current = true;
+ } else if (found_current && current->num == child->num) {
+ return child;
+ }
}
}
}
@@ -692,6 +701,7 @@ Con *workspace_prev(void) {
}
} else {
/* If numbered workspace, find previous numbered workspace. */
+ bool found_current = false;
TAILQ_FOREACH_REVERSE (output, &(croot->nodes_head), nodes_head, nodes) {
/* Skip outputs starting with __, they are internal. */
if (con_is_internal(output)) {
@@ -716,6 +726,14 @@ Con *workspace_prev(void) {
if (current->num > child->num && (!prev || child->num > prev->num)) {
prev = child;
}
+
+ /* If two workspaces have the same number, but different names
+ * (eg '5:a', '5:b') then just take the previous one. */
+ if (child == current) {
+ found_current = true;
+ } else if (found_current && current->num == child->num) {
+ return child;
+ }
}
}
}
@@ -741,6 +759,7 @@ Con *workspace_next_on_output(void) {
next = TAILQ_NEXT(current, nodes);
} else {
/* If currently a numbered workspace, find next numbered workspace. */
+ bool found_current = false;
NODES_FOREACH (output_get_content(output)) {
if (child->type != CT_WORKSPACE) {
continue;
@@ -754,6 +773,14 @@ Con *workspace_next_on_output(void) {
if (current->num < child->num && (!next || child->num < next->num)) {
next = child;
}
+
+ /* If two workspaces have the same number, but different names
+ * (eg '5:a', '5:b') then just take the next one. */
+ if (child == current) {
+ found_current = true;
+ } else if (found_current && current->num == child->num) {
+ return child;
+ }
}
}
@@ -806,6 +833,7 @@ Con *workspace_prev_on_output(void) {
}
} else {
/* If numbered workspace, find previous numbered workspace. */
+ bool found_current = false;
NODES_FOREACH_REVERSE (output_get_content(output)) {
if (child->type != CT_WORKSPACE || child->num == -1) {
continue;
@@ -816,6 +844,14 @@ Con *workspace_prev_on_output(void) {
if (current->num > child->num && (!prev || child->num > prev->num)) {
prev = child;
}
+
+ /* If two workspaces have the same number, but different names
+ * (eg '5:a', '5:b') then just take the previous one. */
+ if (child == current) {
+ found_current = true;
+ } else if (found_current && current->num == child->num) {
+ return child;
+ }
}
}