diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index a8de135f..5e031321 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 |
@@ -458,7 +460,11 @@ static bool handle_view_created(wlc_handle handle) { | |||
458 | 460 | ||
459 | if (newview) { | 461 | if (newview) { |
460 | ipc_event_window(newview, "new"); | 462 | ipc_event_window(newview, "new"); |
461 | set_focused_container(newview); | 463 | swayc_t *workspace = swayc_parent_by_type(newview, C_WORKSPACE); |
464 | if ((workspace && workspace->children->length == 1) | ||
465 | || !criteria_any(newview, config->no_focus)) { | ||
466 | set_focused_container(newview); | ||
467 | } | ||
462 | wlc_view_set_mask(handle, VISIBLE); | 468 | wlc_view_set_mask(handle, VISIBLE); |
463 | swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT); | 469 | swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT); |
464 | arrange_windows(output, -1, -1); | 470 | arrange_windows(output, -1, -1); |
@@ -477,7 +483,7 @@ static bool handle_view_created(wlc_handle handle) { | |||
477 | // refocus in-between command lists | 483 | // refocus in-between command lists |
478 | set_focused_container(newview); | 484 | set_focused_container(newview); |
479 | } | 485 | } |
480 | swayc_t *workspace = swayc_parent_by_type(focused, C_WORKSPACE); | 486 | workspace = swayc_parent_by_type(focused, C_WORKSPACE); |
481 | if (workspace && workspace->fullscreen) { | 487 | if (workspace && workspace->fullscreen) { |
482 | set_focused_container(workspace->fullscreen); | 488 | set_focused_container(workspace->fullscreen); |
483 | } | 489 | } |