aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-03 13:08:45 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-03 13:08:45 -0400
commit5f4761c4f40f5d6ec550ccabaebe0f990b6e8bbc (patch)
tree75f4da71db52745ffd833e0bb7b110ff0044c084 /sway/tree/workspace.c
parentmove output code out of the tree (diff)
downloadsway-5f4761c4f40f5d6ec550ccabaebe0f990b6e8bbc.tar.gz
sway-5f4761c4f40f5d6ec550ccabaebe0f990b6e8bbc.tar.zst
sway-5f4761c4f40f5d6ec550ccabaebe0f990b6e8bbc.zip
unify workspace create functions
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 7d180009..d5a16410 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -179,35 +179,6 @@ struct sway_container *workspace_by_name(const char *name) {
179 } 179 }
180} 180}
181 181
182struct sway_container *workspace_create(const char *name) {
183 struct sway_container *parent;
184 // Search for workspace<->output pair
185 int i, e = config->workspace_outputs->length;
186 for (i = 0; i < e; ++i) {
187 struct workspace_output *wso = config->workspace_outputs->items[i];
188 if (strcasecmp(wso->workspace, name) == 0) {
189 // Find output to use if it exists
190 e = root_container.children->length;
191 for (i = 0; i < e; ++i) {
192 parent = root_container.children->items[i];
193 if (strcmp(parent->name, wso->output) == 0) {
194 return container_workspace_create(parent, name);
195 }
196 }
197 break;
198 }
199 }
200 // Otherwise create a new one
201 struct sway_seat *seat = input_manager_current_seat(input_manager);
202 struct sway_container *focus =
203 seat_get_focus_inactive(seat, &root_container);
204 parent = focus;
205 parent = container_parent(parent, C_OUTPUT);
206 struct sway_container *new_ws = container_workspace_create(parent, name);
207 ipc_event_workspace(NULL, new_ws, "init");
208 return new_ws;
209}
210
211/** 182/**
212 * Get the previous or next workspace on the specified output. Wraps around at 183 * Get the previous or next workspace on the specified output. Wraps around at
213 * the end and beginning. If next is false, the previous workspace is returned, 184 * the end and beginning. If next is false, the previous workspace is returned,
@@ -319,7 +290,9 @@ bool workspace_switch(struct sway_container *workspace) {
319 && active_ws == workspace 290 && active_ws == workspace
320 && prev_workspace_name) { 291 && prev_workspace_name) {
321 struct sway_container *new_ws = workspace_by_name(prev_workspace_name); 292 struct sway_container *new_ws = workspace_by_name(prev_workspace_name);
322 workspace = new_ws ? new_ws : workspace_create(prev_workspace_name); 293 workspace = new_ws ?
294 new_ws :
295 container_workspace_create(NULL, prev_workspace_name);
323 } 296 }
324 297
325 if (!prev_workspace_name || (strcmp(prev_workspace_name, active_ws->name) 298 if (!prev_workspace_name || (strcmp(prev_workspace_name, active_ws->name)