aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-04-26 17:14:24 -0400
committerDrew DeVault <sir@cmpwn.com>2017-04-26 17:14:24 -0400
commit537261f23f194e152c0adf25a2740375929e9cd3 (patch)
tree97fabe0d36c2c5574a2ff47238eeed58fa200fd0
parentffd0d020d61a4c3fb034571515731d31879ee9ec (diff)
downloadsway-537261f23f194e152c0adf25a2740375929e9cd3.zip
sway-537261f23f194e152c0adf25a2740375929e9cd3.tar.gz
sway-537261f23f194e152c0adf25a2740375929e9cd3.tar.bz2
Fix handling of floating windows
-rw-r--r--sway/handlers.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 5e03132..da765d6 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -460,11 +460,7 @@ static bool handle_view_created(wlc_handle handle) {
if (newview) {
ipc_event_window(newview, "new");
- swayc_t *workspace = swayc_parent_by_type(newview, C_WORKSPACE);
- if ((workspace && workspace->children->length == 1)
- || !criteria_any(newview, config->no_focus)) {
- set_focused_container(newview);
- }
+ set_focused_container(newview);
wlc_view_set_mask(handle, VISIBLE);
swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
arrange_windows(output, -1, -1);
@@ -483,7 +479,7 @@ static bool handle_view_created(wlc_handle handle) {
// refocus in-between command lists
set_focused_container(newview);
}
- workspace = swayc_parent_by_type(focused, C_WORKSPACE);
+ swayc_t *workspace = swayc_parent_by_type(focused, C_WORKSPACE);
if (workspace && workspace->fullscreen) {
set_focused_container(workspace->fullscreen);
}
@@ -506,6 +502,16 @@ static bool handle_view_created(wlc_handle handle) {
workspace_switch(current_ws);
set_focused_container(get_focused_container(current_ws));
}
+ if (prev_focus && prev_focus->type == C_VIEW
+ && newview && criteria_any(newview, config->no_focus)) {
+ // Restore focus
+ swayc_t *ws = swayc_parent_by_type(newview, C_WORKSPACE);
+ if (!ws || ws != newview->parent
+ || ws->children->length + ws->floating->length != 1) {
+ sway_log(L_DEBUG, "no_focus: restoring focus to %s", prev_focus->name);
+ set_focused_container(prev_focus);
+ }
+ }
suspend_workspace_cleanup = false;
ws_cleanup();