summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-03-04 11:08:03 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-03-04 11:08:03 -0500
commitef5d8969464e1bfde08a081f1285b33014aa1707 (patch)
tree4f4400de4a29dfa18ae10da6e71ea60146190155
parentMerge pull request #495 from gpyh/docswaybar (diff)
parentFix assigning workspaces to outputs (diff)
downloadsway-ef5d8969464e1bfde08a081f1285b33014aa1707.tar.gz
sway-ef5d8969464e1bfde08a081f1285b33014aa1707.tar.zst
sway-ef5d8969464e1bfde08a081f1285b33014aa1707.zip
Merge pull request #501 from mikkeloscar/ws-on-output
Fix assigning workspaces to outputs
-rw-r--r--include/workspace.h2
-rw-r--r--sway/container.c2
-rw-r--r--sway/layout.c2
-rw-r--r--sway/workspace.c26
4 files changed, 27 insertions, 5 deletions
diff --git a/include/workspace.h b/include/workspace.h
index c69ccdbb..6911e3d4 100644
--- a/include/workspace.h
+++ b/include/workspace.h
@@ -7,7 +7,7 @@
7 7
8extern char *prev_workspace_name; 8extern char *prev_workspace_name;
9 9
10char *workspace_next_name(void); 10char *workspace_next_name(const char *output_name);
11swayc_t *workspace_create(const char*); 11swayc_t *workspace_create(const char*);
12swayc_t *workspace_by_name(const char*); 12swayc_t *workspace_by_name(const char*);
13swayc_t *workspace_by_number(const char*); 13swayc_t *workspace_by_number(const char*);
diff --git a/sway/container.c b/sway/container.c
index 2db7b218..e4c20bc9 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -143,7 +143,7 @@ swayc_t *new_output(wlc_handle handle) {
143 } 143 }
144 } 144 }
145 if (!ws_name) { 145 if (!ws_name) {
146 ws_name = workspace_next_name(); 146 ws_name = workspace_next_name(output->name);
147 } 147 }
148 148
149 // create and initilize default workspace 149 // create and initilize default workspace
diff --git a/sway/layout.c b/sway/layout.c
index dca4e47f..e9998bc8 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -364,7 +364,7 @@ void move_workspace_to(swayc_t* workspace, swayc_t* destination) {
364 364
365 // make sure source output has a workspace 365 // make sure source output has a workspace
366 if (src_op->children->length == 0) { 366 if (src_op->children->length == 0) {
367 char *ws_name = workspace_next_name(); 367 char *ws_name = workspace_next_name(src_op->name);
368 swayc_t *ws = new_workspace(src_op, ws_name); 368 swayc_t *ws = new_workspace(src_op, ws_name);
369 ws->is_focused = true; 369 ws->is_focused = true;
370 free(ws_name); 370 free(ws_name);
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;