summaryrefslogtreecommitdiffstats
path: root/sway/workspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/workspace.c')
-rw-r--r--sway/workspace.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/sway/workspace.c b/sway/workspace.c
index ad989de9..90edc6e9 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -25,8 +25,22 @@ struct workspace_by_number_data {
25 const char *name; 25 const char *name;
26}; 26};
27 27
28char *workspace_next_name(void) { 28static bool workspace_valid_on_output(const char *output_name, const char *ws_name) {
29 sway_log(L_DEBUG, "Workspace: Generating new name"); 29 int i;
30 for (i = 0; i < config->workspace_outputs->length; ++i) {
31 struct workspace_output *wso = config->workspace_outputs->items[i];
32 if (strcasecmp(wso->workspace, ws_name) == 0) {
33 if (strcasecmp(wso->output, output_name) != 0) {
34 return false;
35 }
36 }
37 }
38
39 return true;
40}
41
42char *workspace_next_name(const char *output_name) {
43 sway_log(L_DEBUG, "Workspace: Generating new workspace name for output %s", output_name);
30 int i; 44 int i;
31 int l = 1; 45 int l = 1;
32 // Scan all workspace bindings to find the next available workspace name, 46 // Scan all workspace bindings to find the next available workspace name,
@@ -73,6 +87,14 @@ char *workspace_next_name(void) {
73 free(_target); 87 free(_target);
74 continue; 88 continue;
75 } 89 }
90
91 // make sure that the workspace can appear on the given
92 // output
93 if (!workspace_valid_on_output(output_name, _target)) {
94 free(_target);
95 continue;
96 }
97
76 if (binding->order < order) { 98 if (binding->order < order) {
77 order = binding->order; 99 order = binding->order;
78 target = _target; 100 target = _target;