aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-15 16:03:45 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-15 16:03:45 -0400
commitf606508bccac841925e8d669fe90595697fac8af (patch)
treee150b723ffb01ab4b482fc9f7d2fccda8daaf6bf
parentd5ff5e98fabfef53958b2a6782578756ba29fb7b (diff)
downloadsway-f606508bccac841925e8d669fe90595697fac8af.tar.xz
Fix switching focus between outputs
-rw-r--r--sway/container.c1
-rw-r--r--sway/workspace.c18
2 files changed, 15 insertions, 4 deletions
diff --git a/sway/container.c b/sway/container.c
index 189f064b..98941b2c 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -157,6 +157,7 @@ swayc_t *destroy_output(swayc_t *output) {
}
swayc_t *destroy_workspace(swayc_t *workspace) {
+ //NOTE: This is called from elsewhere without checking children length
//TODO move containers to other workspaces?
//for now just dont delete
if (workspace->children->length == 0) {
diff --git a/sway/workspace.c b/sway/workspace.c
index 9748c23f..6f46dd6b 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -94,7 +94,7 @@ swayc_t *workspace_find_by_name(const char* name) {
}
void workspace_switch(swayc_t *workspace) {
- swayc_t *parent = workspace;
+ swayc_t *parent = workspace->parent;
while (parent->type != C_OUTPUT) {
parent = parent->parent;
}
@@ -111,11 +111,21 @@ void workspace_switch(swayc_t *workspace) {
container_map(workspace, set_mask, &mask);
wlc_output_set_mask(wlc_get_focused_output(), 2);
- unfocus_all(&root_container);
- focus_view(workspace);
-
destroy_workspace(c_workspace);
}
+ unfocus_all(&root_container);
+ focus_view(workspace);
+
+ // focus the output this workspace is on
+ swayc_t *output = workspace->parent;
+ sway_log(L_DEBUG, "Switching focus to output %p (%d)", output, output->type);
+ while (output && output->type != C_OUTPUT) {
+ output = output->parent;
+ }
+ if (output) {
+ sway_log(L_DEBUG, "Switching focus to output %p (%d)", output, output->type);
+ wlc_output_focus(output->handle);
+ }
active_workspace = workspace;
}