summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
authorLibravatar Zandr Martin <zandrmartin+git@gmail.com>2016-05-28 18:18:46 -0500
committerLibravatar Zandr Martin <zandrmartin+git@gmail.com>2016-05-28 18:18:46 -0500
commitd291a29f305efdf0b739d48a23170bf6057ac3a6 (patch)
tree129d1b66f8be0afc1a486096bb31cd9ac458e87f /sway/container.c
parentMerge pull request #675 from zandrmartin/add-workspace-sorting (diff)
downloadsway-d291a29f305efdf0b739d48a23170bf6057ac3a6.tar.gz
sway-d291a29f305efdf0b739d48a23170bf6057ac3a6.tar.zst
sway-d291a29f305efdf0b739d48a23170bf6057ac3a6.zip
enforce workspace output assignents
when creating a new output, move to that output all extant workspaces that are assigned to that output. (unrelated) remove comment that was no longer applicable, fix spacing in an assignment
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/sway/container.c b/sway/container.c
index 20b7905b..4883a648 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -134,32 +134,39 @@ swayc_t *new_output(wlc_handle handle) {
134 134
135 // Create workspace 135 // Create workspace
136 char *ws_name = NULL; 136 char *ws_name = NULL;
137 swayc_t *ws = NULL;
138
137 if (name) { 139 if (name) {
138 for (i = 0; i < config->workspace_outputs->length; ++i) { 140 for (i = 0; i < config->workspace_outputs->length; ++i) {
139 struct workspace_output *wso = config->workspace_outputs->items[i]; 141 struct workspace_output *wso = config->workspace_outputs->items[i];
140 if (strcasecmp(wso->output, name) == 0) { 142 if (strcasecmp(wso->output, name) == 0) {
141 sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output); 143 sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
142 // Check if any other workspaces are using this name 144 // Check if any other workspaces are using this name
143 if (workspace_by_name(wso->workspace)) { 145 if ((ws = workspace_by_name(wso->workspace))) {
144 sway_log(L_DEBUG, "But it's already taken"); 146 // if yes, move those to this output, because they should be here
145 break; 147 move_workspace_to(ws, output);
148 } else if (!ws_name) {
149 // set a workspace name in case we need to create a default one
150 ws_name = strdup(wso->workspace);
146 } 151 }
147 sway_log(L_DEBUG, "So we're going to use it");
148 ws_name = strdup(wso->workspace);
149 break;
150 } 152 }
151 } 153 }
152 } 154 }
153 if (!ws_name) {
154 ws_name = workspace_next_name(output->name);
155 }
156 155
157 // create and initialize default workspace 156 if (output->children->length == 0) {
158 swayc_t *ws = new_workspace(output, ws_name); 157 if (!ws_name) {
159 ws->is_focused = true; 158 ws_name = workspace_next_name(output->name);
159 }
160 // create and initialize default workspace
161 sway_log(L_DEBUG, "Creating default workspace %s", ws_name);
162 ws = new_workspace(output, ws_name);
163 ws->is_focused = true;
164 } else {
165 sort_workspaces(output);
166 set_focused_container(output->children->items[0]);
167 }
160 168
161 free(ws_name); 169 free(ws_name);
162
163 return output; 170 return output;
164} 171}
165 172