From bafbcdd139e19b29a49682525dfa4ccc4256cb69 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Fri, 15 May 2026 12:26:39 +0200 Subject: [PATCH] Only set initial focus on focused output --- sway/lock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sway/lock.c b/sway/lock.c index 6f7d4c206..43384fdb5 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -82,12 +82,12 @@ static void handle_surface_map(struct wl_listener *listener, void *data) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *focused_ws = seat_get_focused_workspace(seat); - struct sway_output *focused_output = NULL; - if (focused_ws != NULL) { - focused_output = focused_ws->output; - } + struct sway_output *focused_output = focused_ws ? focused_ws->output : NULL; - if (surf->lock->focused == NULL || focused_output == surf->output) { + // Only set the initial focus surface when it's on the focused output. + // Fallback to the first mapped surface if no focused output can be found. + if (focused_output == surf->output + || (!focused_output && surf->lock->focused == NULL)) { focus_surface(surf->lock, surf->surface->surface); } cursor_rebase_all();