From abd8e971c6324a9a289fa3e456169e2ca67acb40 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Fri, 29 Mar 2024 02:53:53 +0100 Subject: [PATCH] osd: prevent handling cursor actions in preview mode Fixes: #1640 Co-Authored-By: tokyo4j --- src/foreign.c | 6 ++++++ src/input/cursor.c | 11 ++++++++++- src/xdg.c | 5 +++++ src/xwayland.c | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/foreign.c b/src/foreign.c index f76144a7..982e7840 100644 --- a/src/foreign.c +++ b/src/foreign.c @@ -34,6 +34,12 @@ handle_request_activate(struct wl_listener *listener, void *data) { struct view *view = wl_container_of(listener, view, toplevel.activate); // struct wlr_foreign_toplevel_handle_v1_activated_event *event = data; + + if (view->server->osd_state.cycle_view) { + wlr_log(WLR_INFO, "Preventing focus request while in window switcher"); + return; + } + /* In a multi-seat world we would select seat based on event->seat here. */ desktop_focus_view(view, /*raise*/ true); } diff --git a/src/input/cursor.c b/src/input/cursor.c index 01c3dbe7..626caeab 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -521,7 +521,8 @@ process_cursor_motion(struct server *server, uint32_t time) dnd_icons_move(seat, seat->cursor->x, seat->cursor->y); } - if ((ctx.view || ctx.surface) && rc.focus_follow_mouse) { + if ((ctx.view || ctx.surface) && rc.focus_follow_mouse + && !server->osd_state.cycle_view) { desktop_focus_view_or_surface(seat, ctx.view, ctx.surface, rc.raise_on_focus); } @@ -798,6 +799,10 @@ static bool handle_release_mousebinding(struct server *server, struct cursor_context *ctx, uint32_t button) { + if (server->osd_state.cycle_view) { + return false; + } + struct mousebind *mousebind; bool consumed_by_frame_context = false; @@ -884,6 +889,10 @@ static bool handle_press_mousebinding(struct server *server, struct cursor_context *ctx, uint32_t button, uint32_t resize_edges) { + if (server->osd_state.cycle_view) { + return false; + } + struct mousebind *mousebind; bool double_click = is_double_click(rc.doubleclick_time, button, ctx); bool consumed_by_frame_context = false; diff --git a/src/xdg.c b/src/xdg.c index 78c549b0..488f67fd 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -725,6 +725,11 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data) return; } + if (view->server->osd_state.cycle_view) { + wlr_log(WLR_INFO, "Preventing focus request while in window switcher"); + return; + } + wlr_log(WLR_DEBUG, "Activating surface"); desktop_focus_view(view, /*raise*/ true); } diff --git a/src/xwayland.c b/src/xwayland.c index d59e0fb7..eda5aad7 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -409,6 +409,11 @@ handle_request_activate(struct wl_listener *listener, void *data) return; } + if (view->server->osd_state.cycle_view) { + wlr_log(WLR_INFO, "Preventing focus request while in window switcher"); + return; + } + desktop_focus_view(view, /*raise*/ true); }