summaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c14
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) {
390 } 390 }
391 } 391 }
392 392
393 swayc_t *prev_focus = get_focused_container(&root_container);
394
393 if (!focused || focused->type == C_OUTPUT) { 395 if (!focused || focused->type == C_OUTPUT) {
394 focused = get_focused_container(&root_container); 396 focused = prev_focus;
395 // Move focus from floating view 397 // Move focus from floating view
396 if (focused->is_floating) { 398 if (focused->is_floating) {
397 // To workspace if there are no children 399 // To workspace if there are no children
@@ -500,6 +502,16 @@ static bool handle_view_created(wlc_handle handle) {
500 workspace_switch(current_ws); 502 workspace_switch(current_ws);
501 set_focused_container(get_focused_container(current_ws)); 503 set_focused_container(get_focused_container(current_ws));
502 } 504 }
505 if (prev_focus && prev_focus->type == C_VIEW
506 && newview && criteria_any(newview, config->no_focus)) {
507 // Restore focus
508 swayc_t *ws = swayc_parent_by_type(newview, C_WORKSPACE);
509 if (!ws || ws != newview->parent
510 || ws->children->length + ws->floating->length != 1) {
511 sway_log(L_DEBUG, "no_focus: restoring focus to %s", prev_focus->name);
512 set_focused_container(prev_focus);
513 }
514 }
503 515
504 suspend_workspace_cleanup = false; 516 suspend_workspace_cleanup = false;
505 ws_cleanup(); 517 ws_cleanup();