]> git.mdlowis.com Git - proto/labwc.git/commitdiff
desktop: harden window stacking order while window switching
authortokyo4j <hrak1529@gmail.com>
Mon, 24 Feb 2025 12:40:46 +0000 (21:40 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 9 Mar 2025 20:41:26 +0000 (20:41 +0000)
This commit moves the check against server->input_mode from the callers
of desktop_focus_view() into desktop_focus_view() itself. This
eliminates code duplications and makes it harder to mess up the window
stacking order while window switching.

I also added the same check in view_minimize() so that minimize requests
from panels never messes up the window stacking order (I think only this
should be described in the release note).

src/desktop.c
src/foreign-toplevel/foreign.c
src/input/cursor.c
src/view.c
src/xdg.c
src/xwayland.c

index e3380705043cd5ce4c0bb7ec71fc5f089dd402be..45a6fc6755233e3db3d4d4d1e7386ea1156cdc1e 100644 (file)
@@ -51,6 +51,11 @@ desktop_focus_view(struct view *view, bool raise)
                return;
        }
 
+       if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
+               wlr_log(WLR_DEBUG, "not focusing window while window switching");
+               return;
+       }
+
        if (view->minimized) {
                /*
                 * Unminimizing will map the view which triggers a call to this
index 6f626c6e9b0751e6fde4badb7106ac70cc12f03c..a469305c0ba848a1bdbe5f3d0df7b7b14af5e69f 100644 (file)
@@ -29,12 +29,6 @@ foreign_request_fullscreen(struct foreign_toplevel *toplevel, bool fullscreen)
 void
 foreign_request_activate(struct foreign_toplevel *toplevel)
 {
-       if (toplevel->view->server->input_mode
-                       == LAB_INPUT_STATE_WINDOW_SWITCHER) {
-               wlr_log(WLR_INFO, "Preventing focus request while in window switcher");
-               return;
-       }
-
        desktop_focus_view(toplevel->view, /*raise*/ true);
 }
 
index e9ae9ad0bce9f687e8a49a01003bac2ccaeb2ff9..1a261ca953b271b66bdd359322a345e9e0bbd909 100644 (file)
@@ -599,9 +599,7 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
                dnd_icons_move(seat, seat->cursor->x, seat->cursor->y);
        }
 
-       if ((ctx.view || ctx.surface) && rc.focus_follow_mouse
-                       && server->input_mode
-                               != LAB_INPUT_STATE_WINDOW_SWITCHER) {
+       if ((ctx.view || ctx.surface) && rc.focus_follow_mouse) {
                desktop_focus_view_or_surface(seat, ctx.view, ctx.surface,
                        rc.raise_on_focus);
        }
@@ -641,15 +639,10 @@ _cursor_update_focus(struct server *server)
        struct cursor_context ctx = get_cursor_context(server);
 
        if ((ctx.view || ctx.surface) && rc.focus_follow_mouse
-                       && !rc.focus_follow_mouse_requires_movement
-                       && server->input_mode
-                               != LAB_INPUT_STATE_WINDOW_SWITCHER) {
+                       && !rc.focus_follow_mouse_requires_movement) {
                /*
                 * Always focus the surface below the cursor when
                 * followMouse=yes and followMouseRequiresMovement=no.
-                *
-                * We should ignore them while window-switching though, because
-                * calling desktop_focus_view() un-minimizes previewed window.
                 */
                desktop_focus_view_or_surface(&server->seat, ctx.view,
                        ctx.surface, rc.raise_on_focus);
index cc5af20df97edfe9d1d2dc457b2ca855efb5330e..f50412624c06fb27624a7c6e99487667637bedd3 100644 (file)
@@ -803,6 +803,12 @@ void
 view_minimize(struct view *view, bool minimized)
 {
        assert(view);
+
+       if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
+               wlr_log(WLR_ERROR, "not minimizing window while window switching");
+               return;
+       }
+
        /*
         * Minimize the root window first because some xwayland clients send a
         * request-unmap to sub-windows at this point (for example gimp and its
index cd2200f2a5f7bf4f0c297ab4bf70459e9a731469..4b8c9f96bdda54ee974af5dcbffbf0f35c91e7a3 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -875,11 +875,6 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data)
                return;
        }
 
-       if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
-               wlr_log(WLR_INFO, "Preventing focus request while in window switcher");
-               return;
-       }
-
        wlr_log(WLR_DEBUG, "Activating surface");
        desktop_focus_view(view, /*raise*/ true);
 }
index 1eb9c1a367875d213368f47dbeb5a149200452e4..a295e03a9fa86f0aff47a9eccc714de6d7c4bb2f 100644 (file)
@@ -402,11 +402,6 @@ handle_request_activate(struct wl_listener *listener, void *data)
                return;
        }
 
-       if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
-               wlr_log(WLR_INFO, "Preventing focus request while in window switcher");
-               return;
-       }
-
        desktop_focus_view(view, /*raise*/ true);
 }