aboutsummaryrefslogtreecommitdiff
path: root/sway/workspace.c
diff options
context:
space:
mode:
authortaiyu <taiyu.len@gmail.com>2015-09-10 11:07:40 -0700
committertaiyu <taiyu.len@gmail.com>2015-09-10 11:07:40 -0700
commitaaa0923bc4fe4ffda114482a9b8023c90c26c8dc (patch)
tree7c12a435bf56e4ebfcae689ce46280eeeb330346 /sway/workspace.c
parent6388241abb7e2e66e716fc128e658d3d3419442a (diff)
cmd status + workspace ws output op
Diffstat (limited to 'sway/workspace.c')
-rw-r--r--sway/workspace.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sway/workspace.c b/sway/workspace.c
index 7eb422c4..658f79bc 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -76,7 +76,26 @@ char *workspace_next_name(void) {
}
swayc_t *workspace_create(const char* name) {
- swayc_t *parent = get_focused_container(&root_container);
+ swayc_t *parent;
+ // Search for workspace<->output pair
+ int i, e = config->workspace_outputs->length;
+ for (i = 0; i < e; ++i) {
+ struct workspace_output *wso = config->workspace_outputs->items[i];
+ if (strcasecmp(wso->workspace, name) == 0)
+ {
+ // Find output to use if it exists
+ e = root_container.children->length;
+ for (i = 0; i < e; ++i) {
+ parent = root_container.children->items[i];
+ if (strcmp(parent->name, wso->output) == 0) {
+ return new_workspace(parent, name);
+ }
+ }
+ break;
+ }
+ }
+ // Otherwise create a new one
+ parent = get_focused_container(&root_container);
parent = swayc_parent_by_type(parent, C_OUTPUT);
return new_workspace(parent, name);
}