diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-03-04 11:08:03 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-03-04 11:08:03 -0500 |
commit | ef5d8969464e1bfde08a081f1285b33014aa1707 (patch) | |
tree | 4f4400de4a29dfa18ae10da6e71ea60146190155 /sway | |
parent | 79bfd620d6f7a3d089898ec6391411c2c6b22668 (diff) | |
parent | 8ddafeeaae44db77bfdb55d1776513d88a58f68e (diff) |
Merge pull request #501 from mikkeloscar/ws-on-output
Fix assigning workspaces to outputs
Diffstat (limited to 'sway')
-rw-r--r-- | sway/container.c | 2 | ||||
-rw-r--r-- | sway/layout.c | 2 | ||||
-rw-r--r-- | sway/workspace.c | 26 |
3 files changed, 26 insertions, 4 deletions
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) { } } if (!ws_name) { - ws_name = workspace_next_name(); + ws_name = workspace_next_name(output->name); } // 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) { // make sure source output has a workspace if (src_op->children->length == 0) { - char *ws_name = workspace_next_name(); + char *ws_name = workspace_next_name(src_op->name); swayc_t *ws = new_workspace(src_op, ws_name); ws->is_focused = true; 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 { const char *name; }; -char *workspace_next_name(void) { - sway_log(L_DEBUG, "Workspace: Generating new name"); +static bool workspace_valid_on_output(const char *output_name, const char *ws_name) { + int i; + for (i = 0; i < config->workspace_outputs->length; ++i) { + struct workspace_output *wso = config->workspace_outputs->items[i]; + if (strcasecmp(wso->workspace, ws_name) == 0) { + if (strcasecmp(wso->output, output_name) != 0) { + return false; + } + } + } + + return true; +} + +char *workspace_next_name(const char *output_name) { + sway_log(L_DEBUG, "Workspace: Generating new workspace name for output %s", output_name); int i; int l = 1; // Scan all workspace bindings to find the next available workspace name, @@ -73,6 +87,14 @@ char *workspace_next_name(void) { free(_target); continue; } + + // make sure that the workspace can appear on the given + // output + if (!workspace_valid_on_output(output_name, _target)) { + free(_target); + continue; + } + if (binding->order < order) { order = binding->order; target = _target; |