]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: only focus topmost view if unmapped view was focused
authorJohn Lindgren <john@jlindgren.net>
Sun, 15 Oct 2023 02:29:24 +0000 (22:29 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 15 Oct 2023 20:15:11 +0000 (21:15 +0100)
The unmap() handlers should only call desktop_focus_topmost_view() if
the unmapped view was the focused view. Unmapping a view that was not
focused should not change the focus.

I expect this rarely had any effect in practice; it would only matter in
a focus-follows-mouse config where some view other than the one on top
was focused. But it still seems better to fix.

Rather than repeating the logic in two places, create a small
view_impl_unmap() helper. Perhaps more common "unmap" logic could be
moved there in future.

include/view-impl-common.h
src/view-impl-common.c
src/xdg.c
src/xwayland.c

index 2912653fde7f8ae1e934f4112252a76f4acbf4ee..7e75b048941fdd03f4c31239bf7486326456ca7e 100644 (file)
@@ -19,6 +19,7 @@ void view_impl_move_to_front(struct view *view);
 void view_impl_move_to_back(struct view *view);
 void view_impl_move_sub_views(struct view *parent, enum z_direction z_direction);
 void view_impl_map(struct view *view);
+void view_impl_unmap(struct view *view);
 
 /*
  * Updates view geometry at commit based on current position/size,
index ea0fe1a7a0882f313c284418b5b49bcab28bc53f..cc2109e0db3231d203c4c2808f92d56e2ea67735 100644 (file)
@@ -75,6 +75,15 @@ view_impl_map(struct view *view)
                view_get_string_prop(view, "title"));
 }
 
+void
+view_impl_unmap(struct view *view)
+{
+       struct seat *seat = &view->server->seat;
+       if (seat->seat->keyboard_state.focused_surface == view->surface) {
+               desktop_focus_topmost_view(view->server);
+       }
+}
+
 static bool
 resizing_edge(struct view *view, uint32_t edge)
 {
index f916087d708a84017401812175890d766d49d852..61130101601e94ce3ce8aa89f0f4d6088e7b578d 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -554,7 +554,7 @@ xdg_toplevel_view_unmap(struct view *view, bool client_request)
                view->mapped = false;
                wlr_scene_node_set_enabled(&view->scene_tree->node, false);
                wl_list_remove(&view->commit.link);
-               desktop_focus_topmost_view(view->server);
+               view_impl_unmap(view);
        }
 }
 
index 97337c4527df467b627f8150309a75741fe8ac1e..e2c74fb135498bdef079c81c2917e032200f91f9 100644 (file)
@@ -531,7 +531,7 @@ xwayland_view_unmap(struct view *view, bool client_request)
        view->mapped = false;
        wl_list_remove(&view->commit.link);
        wlr_scene_node_set_enabled(&view->scene_tree->node, false);
-       desktop_focus_topmost_view(view->server);
+       view_impl_unmap(view);
 
        /*
         * If the view was explicitly unmapped by the client (rather