From cae96b0cce441dd9f1981c312ae0108b3b4e42c9 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Sat, 23 Sep 2023 12:20:44 -0400 Subject: [PATCH] desktop: try harder to avoid focusing unfocusable views Make desktop_focus_view() do nothing if the view is not focusable. --- src/desktop.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/desktop.c b/src/desktop.c index 7376555e..1b34e983 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -38,14 +38,16 @@ void desktop_focus_view(struct view *view, bool raise) { assert(view); + if (!view_isfocusable(view)) { + return; + } + /* * Guard against views with no mapped surfaces when handling * 'request_activate' and 'request_minimize'. - * See notes by view_isfocusable() + * view_isfocusable() should return false for those views. */ - if (!view->surface) { - return; - } + assert(view->surface); struct server *server = view->server; if (input_inhibit_blocks_surface(&server->seat, view->surface->resource) @@ -62,9 +64,11 @@ desktop_focus_view(struct view *view, bool raise) return; } - if (!view->mapped) { - return; - } + /* + * view_isfocusable() should return false for any views that are + * neither mapped nor minimized. + */ + assert(view->mapped); /* * Switch workspace if necessary to make the view visible -- 2.52.0