summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-18 08:20:59 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-18 08:30:21 -0400
commita64b10df83f84e7ee8933ac139f10c59bfd76466 (patch)
tree4b0f517cb27be923f8f41508e8c778d660bd6fcf /sway/container.c
parentRevert "config handles comments better" (diff)
downloadsway-a64b10df83f84e7ee8933ac139f10c59bfd76466.tar.gz
sway-a64b10df83f84e7ee8933ac139f10c59bfd76466.tar.zst
sway-a64b10df83f84e7ee8933ac139f10c59bfd76466.zip
Fix switching between focused outputs
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sway/container.c b/sway/container.c
index e679e823..c83cd720 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -37,6 +37,10 @@ static void free_swayc(swayc_t *c) {
37 37
38/* New containers */ 38/* New containers */
39 39
40static bool workspace_test(swayc_t *view, void *name) {
41 return strcasecmp(view->name, (char *)name);
42}
43
40swayc_t *new_output(wlc_handle handle) { 44swayc_t *new_output(wlc_handle handle) {
41 const struct wlc_size* size = wlc_output_get_resolution(handle); 45 const struct wlc_size* size = wlc_output_get_resolution(handle);
42 const char *name = wlc_output_get_name(handle); 46 const char *name = wlc_output_get_name(handle);
@@ -58,6 +62,10 @@ swayc_t *new_output(wlc_handle handle) {
58 struct workspace_output *wso = config->workspace_outputs->items[i]; 62 struct workspace_output *wso = config->workspace_outputs->items[i];
59 if (strcasecmp(wso->output, name) == 0) { 63 if (strcasecmp(wso->output, name) == 0) {
60 sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output); 64 sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
65 // Check if any other workspaces are using this name
66 if (find_container(&root_container, workspace_test, wso->workspace)) {
67 break;
68 }
61 ws_name = strdup(wso->workspace); 69 ws_name = strdup(wso->workspace);
62 break; 70 break;
63 } 71 }
@@ -206,6 +214,18 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
206 // NOTE: This is called from elsewhere without checking children length 214 // NOTE: This is called from elsewhere without checking children length
207 // TODO move containers to other workspaces? 215 // TODO move containers to other workspaces?
208 // for now just dont delete 216 // for now just dont delete
217
218 // Do not destroy this if it's the last workspace on this output
219 swayc_t *output = workspace->parent;
220 while (output && output->type != C_OUTPUT) {
221 output = output->parent;
222 }
223 if (output) {
224 if (output->children->length == 1) {
225 return NULL;
226 }
227 }
228
209 if (workspace->children->length == 0) { 229 if (workspace->children->length == 0) {
210 sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name); 230 sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name);
211 swayc_t *parent = workspace->parent; 231 swayc_t *parent = workspace->parent;