From 25e6a687aca4547349add4d80eb23eefaffdc4f1 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Mon, 7 Nov 2022 20:26:37 +0000 Subject: [PATCH] cursor: combine two variables relating to frame-context Mouse bindings, unlike key bindings, are made within contexts which represent what was clicked/dragged. The context 'Frame' refers to the entire window frame including both the window decorations (if any) and the client window itself. It is typically used for alti + left/right click to move/resize the window. 'Frame' is a special case in that when a button is bound in this context, the action will not be forwarded to the client, which is what we describe with the 'consumed_by_frame_context' variable. --- src/cursor.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/cursor.c b/src/cursor.c index 9b70ffc2..e63a5178 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -634,8 +634,7 @@ handle_release_mousebinding(struct server *server, struct cursor_context *ctx, uint32_t button) { struct mousebind *mousebind; - bool handled = false; - bool handled_in_compositor = false; + bool consumed_by_frame_context = false; uint32_t modifiers = wlr_keyboard_get_modifiers( &server->seat.keyboard_group->keyboard); @@ -658,16 +657,14 @@ handle_release_mousebinding(struct server *server, * Swallow the release event as well as * the press one */ - handled = true; - handled_in_compositor |= + consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME; } continue; default: continue; } - handled = true; - handled_in_compositor |= mousebind->context == LAB_SSD_FRAME; + consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME; actions_run(ctx->view, server, &mousebind->actions, /*resize_edges*/ 0); } @@ -681,7 +678,7 @@ handle_release_mousebinding(struct server *server, mousebind->pressed_in_context = false; } } - return handled && handled_in_compositor; + return consumed_by_frame_context; } static bool @@ -719,8 +716,7 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx, { struct mousebind *mousebind; bool double_click = is_double_click(rc.doubleclick_time, button, ctx->view); - bool handled = false; - bool handled_in_compositor = false; + bool consumed_by_frame_context = false; uint32_t modifiers = wlr_keyboard_get_modifiers( &server->seat.keyboard_group->keyboard); @@ -742,8 +738,7 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx, * Swallow the press event as well as * the release one */ - handled = true; - handled_in_compositor |= + consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME; mousebind->pressed_in_context = true; } @@ -758,12 +753,11 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx, default: continue; } - handled = true; - handled_in_compositor |= mousebind->context == LAB_SSD_FRAME; + consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME; actions_run(ctx->view, server, &mousebind->actions, resize_edges); } } - return handled && handled_in_compositor; + return consumed_by_frame_context; } /* Set in cursor_button_press(), used in cursor_button_release() */ @@ -805,10 +799,10 @@ cursor_button_press(struct seat *seat, struct wlr_pointer_button_event *event) } /* Bindings to the Frame context swallow mouse events if activated */ - bool handled = handle_press_mousebinding( - server, &ctx, event->button, resize_edges); + bool consumed_by_frame_context = + handle_press_mousebinding(server, &ctx, event->button, resize_edges); - if (ctx.surface && !handled) { + if (ctx.surface && !consumed_by_frame_context) { /* Notify client with pointer focus of button press */ wlr_seat_pointer_notify_button(seat->seat, event->time_msec, event->button, event->state); @@ -851,9 +845,10 @@ cursor_button_release(struct seat *seat, struct wlr_pointer_button_event *event) } /* Bindings to the Frame context swallow mouse events if activated */ - bool handled = handle_release_mousebinding(server, &ctx, event->button); + bool consumed_by_frame_context = + handle_release_mousebinding(server, &ctx, event->button); - if (ctx.surface && !handled) { + if (ctx.surface && !consumed_by_frame_context) { /* Notify client with pointer focus of button release */ wlr_seat_pointer_notify_button(seat->seat, event->time_msec, event->button, event->state);