Check input_mode to see whether window switcher is active or not

...rather than "if (server->osd_state.cycle_view){..}".
This commit is contained in:
tokyo4j 2024-12-28 17:42:26 +09:00 committed by Johan Malm
parent 398b80b26f
commit 5d3ce3e190
6 changed files with 17 additions and 14 deletions

View file

@ -29,7 +29,8 @@ foreign_request_fullscreen(struct foreign_toplevel *toplevel, bool fullscreen)
void void
foreign_request_activate(struct foreign_toplevel *toplevel) foreign_request_activate(struct foreign_toplevel *toplevel)
{ {
if (toplevel->view->server->osd_state.cycle_view) { if (toplevel->view->server->input_mode
== LAB_INPUT_STATE_WINDOW_SWITCHER) {
wlr_log(WLR_INFO, "Preventing focus request while in window switcher"); wlr_log(WLR_INFO, "Preventing focus request while in window switcher");
return; return;
} }

View file

@ -614,7 +614,8 @@ cursor_process_motion(struct server *server, uint32_t time, double *sx, double *
} }
if ((ctx.view || ctx.surface) && rc.focus_follow_mouse if ((ctx.view || ctx.surface) && rc.focus_follow_mouse
&& !server->osd_state.cycle_view) { && server->input_mode
!= LAB_INPUT_STATE_WINDOW_SWITCHER) {
desktop_focus_view_or_surface(seat, ctx.view, ctx.surface, desktop_focus_view_or_surface(seat, ctx.view, ctx.surface,
rc.raise_on_focus); rc.raise_on_focus);
} }
@ -655,7 +656,8 @@ _cursor_update_focus(struct server *server)
if ((ctx.view || ctx.surface) && rc.focus_follow_mouse if ((ctx.view || ctx.surface) && rc.focus_follow_mouse
&& !rc.focus_follow_mouse_requires_movement && !rc.focus_follow_mouse_requires_movement
&& !server->osd_state.cycle_view) { && server->input_mode
!= LAB_INPUT_STATE_WINDOW_SWITCHER) {
/* Prevents changing keyboard focus during A-Tab */ /* Prevents changing keyboard focus during A-Tab */
desktop_focus_view_or_surface(&server->seat, ctx.view, desktop_focus_view_or_surface(&server->seat, ctx.view,
ctx.surface, rc.raise_on_focus); ctx.surface, rc.raise_on_focus);
@ -901,7 +903,7 @@ static void
handle_release_mousebinding(struct server *server, handle_release_mousebinding(struct server *server,
struct cursor_context *ctx, uint32_t button) struct cursor_context *ctx, uint32_t button)
{ {
if (server->osd_state.cycle_view) { if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
return; return;
} }
@ -968,7 +970,7 @@ static bool
handle_press_mousebinding(struct server *server, struct cursor_context *ctx, handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
uint32_t button) uint32_t button)
{ {
if (server->osd_state.cycle_view) { if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
return false; return false;
} }

View file

@ -133,10 +133,12 @@ keyboard_modifiers_notify(struct wl_listener *listener, void *data)
overlay_update(seat); overlay_update(seat);
} }
if (server->osd_state.cycle_view bool window_switcher_active = server->input_mode
|| seat->workspace_osd_shown_by_modifier) { == LAB_INPUT_STATE_WINDOW_SWITCHER;
if (window_switcher_active || seat->workspace_osd_shown_by_modifier) {
if (!keyboard_any_modifiers_pressed(wlr_keyboard)) { if (!keyboard_any_modifiers_pressed(wlr_keyboard)) {
if (server->osd_state.cycle_view) { if (window_switcher_active) {
if (key_state_nr_bound_keys()) { if (key_state_nr_bound_keys()) {
should_cancel_cycling_on_next_key_release = true; should_cancel_cycling_on_next_key_release = true;
} else { } else {
@ -570,9 +572,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
key_state_store_pressed_key_as_bound(event->keycode); key_state_store_pressed_key_as_bound(event->keycode);
handle_menu_keys(server, &keyinfo.translated); handle_menu_keys(server, &keyinfo.translated);
return true; return true;
} } else if (server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
if (server->osd_state.cycle_view) {
key_state_store_pressed_key_as_bound(event->keycode); key_state_store_pressed_key_as_bound(event->keycode);
handle_cycle_view_key(server, &keyinfo); handle_cycle_view_key(server, &keyinfo);
return true; return true;

View file

@ -60,7 +60,7 @@ osd_on_view_destroy(struct view *view)
assert(view); assert(view);
struct osd_state *osd_state = &view->server->osd_state; struct osd_state *osd_state = &view->server->osd_state;
if (!osd_state->cycle_view) { if (view->server->input_mode != LAB_INPUT_STATE_WINDOW_SWITCHER) {
/* OSD not active, no need for clean up */ /* OSD not active, no need for clean up */
return; return;
} }

View file

@ -874,7 +874,7 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data)
return; return;
} }
if (view->server->osd_state.cycle_view) { if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
wlr_log(WLR_INFO, "Preventing focus request while in window switcher"); wlr_log(WLR_INFO, "Preventing focus request while in window switcher");
return; return;
} }

View file

@ -402,7 +402,7 @@ handle_request_activate(struct wl_listener *listener, void *data)
return; return;
} }
if (view->server->osd_state.cycle_view) { if (view->server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER) {
wlr_log(WLR_INFO, "Preventing focus request while in window switcher"); wlr_log(WLR_INFO, "Preventing focus request while in window switcher");
return; return;
} }