diff options
author | Drew DeVault <[email protected]> | 2017-04-26 17:20:12 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2017-04-26 17:20:12 -0400 |
commit | 11b4c3454c65375db88901165f0a69c978e3977f (patch) | |
tree | 97fabe0d36c2c5574a2ff47238eeed58fa200fd0 /sway/handlers.c | |
parent | 3c1fc00f12e2777f6349a5d671b8d66c5997eb2b (diff) | |
parent | 537261f23f194e152c0adf25a2740375929e9cd3 (diff) |
Merge pull request #1196 from SirCmpwn/no_focus
Implement no_focus
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index a8de135f..da765d6d 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -390,8 +390,10 @@ static bool handle_view_created(wlc_handle handle) { } } + swayc_t *prev_focus = get_focused_container(&root_container); + if (!focused || focused->type == C_OUTPUT) { - focused = get_focused_container(&root_container); + focused = prev_focus; // Move focus from floating view if (focused->is_floating) { // To workspace if there are no children @@ -500,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(); |