diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-18 08:20:59 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-18 08:30:21 -0400 |
commit | a64b10df83f84e7ee8933ac139f10c59bfd76466 (patch) | |
tree | 4b0f517cb27be923f8f41508e8c778d660bd6fcf | |
parent | Revert "config handles comments better" (diff) | |
download | sway-a64b10df83f84e7ee8933ac139f10c59bfd76466.tar.gz sway-a64b10df83f84e7ee8933ac139f10c59bfd76466.tar.zst sway-a64b10df83f84e7ee8933ac139f10c59bfd76466.zip |
Fix switching between focused outputs
-rw-r--r-- | sway/container.c | 20 | ||||
-rw-r--r-- | sway/focus.c | 2 | ||||
-rw-r--r-- | sway/workspace.c | 11 |
3 files changed, 32 insertions, 1 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 | ||
40 | static bool workspace_test(swayc_t *view, void *name) { | ||
41 | return strcasecmp(view->name, (char *)name); | ||
42 | } | ||
43 | |||
40 | swayc_t *new_output(wlc_handle handle) { | 44 | swayc_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; |
diff --git a/sway/focus.c b/sway/focus.c index 99cb2570..7e3af56c 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -16,7 +16,7 @@ static void update_focus(swayc_t *c) { | |||
16 | switch (c->type) { | 16 | switch (c->type) { |
17 | case C_ROOT: return; | 17 | case C_ROOT: return; |
18 | case C_OUTPUT: | 18 | case C_OUTPUT: |
19 | wlc_output_focus(c->parent->handle); | 19 | wlc_output_focus(c->handle); |
20 | break; | 20 | break; |
21 | // switching workspaces | 21 | // switching workspaces |
22 | case C_WORKSPACE: | 22 | case C_WORKSPACE: |
diff --git a/sway/workspace.c b/sway/workspace.c index bc0fa2c8..ed545804 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -174,6 +174,17 @@ void workspace_prev() { | |||
174 | } | 174 | } |
175 | 175 | ||
176 | void workspace_switch(swayc_t *workspace) { | 176 | void workspace_switch(swayc_t *workspace) { |
177 | if (!workspace) { | ||
178 | return; | ||
179 | } | ||
180 | sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); | ||
181 | |||
182 | // Remove focus from current view | ||
183 | swayc_t *current = get_focused_view(&root_container); | ||
184 | if (current && current->type == C_VIEW) { | ||
185 | wlc_view_set_state(current->handle, WLC_BIT_ACTIVATED, false); | ||
186 | } | ||
187 | |||
177 | set_focused_container(workspace); | 188 | set_focused_container(workspace); |
178 | active_workspace = workspace; | 189 | active_workspace = workspace; |
179 | } | 190 | } |