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.
This commit is contained in:
Johan Malm 2022-11-07 20:26:37 +00:00 committed by Johan Malm
parent 2a9a378176
commit 11cfc49b12

View file

@ -642,8 +642,7 @@ handle_release_mousebinding(struct server *server,
struct cursor_context *ctx, uint32_t button) struct cursor_context *ctx, uint32_t button)
{ {
struct mousebind *mousebind; struct mousebind *mousebind;
bool handled = false; bool consumed_by_frame_context = false;
bool handled_in_compositor = false;
uint32_t modifiers = wlr_keyboard_get_modifiers( uint32_t modifiers = wlr_keyboard_get_modifiers(
&server->seat.keyboard_group->keyboard); &server->seat.keyboard_group->keyboard);
@ -666,16 +665,14 @@ handle_release_mousebinding(struct server *server,
* Swallow the release event as well as * Swallow the release event as well as
* the press one * the press one
*/ */
handled = true; consumed_by_frame_context |=
handled_in_compositor |=
mousebind->context == LAB_SSD_FRAME; mousebind->context == LAB_SSD_FRAME;
} }
continue; continue;
default: default:
continue; continue;
} }
handled = true; consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME;
handled_in_compositor |= mousebind->context == LAB_SSD_FRAME;
actions_run(ctx->view, server, &mousebind->actions, actions_run(ctx->view, server, &mousebind->actions,
/*resize_edges*/ 0); /*resize_edges*/ 0);
} }
@ -689,7 +686,7 @@ handle_release_mousebinding(struct server *server,
mousebind->pressed_in_context = false; mousebind->pressed_in_context = false;
} }
} }
return handled && handled_in_compositor; return consumed_by_frame_context;
} }
static bool static bool
@ -727,8 +724,7 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
{ {
struct mousebind *mousebind; struct mousebind *mousebind;
bool double_click = is_double_click(rc.doubleclick_time, button, ctx->view); bool double_click = is_double_click(rc.doubleclick_time, button, ctx->view);
bool handled = false; bool consumed_by_frame_context = false;
bool handled_in_compositor = false;
uint32_t modifiers = wlr_keyboard_get_modifiers( uint32_t modifiers = wlr_keyboard_get_modifiers(
&server->seat.keyboard_group->keyboard); &server->seat.keyboard_group->keyboard);
@ -750,8 +746,7 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
* Swallow the press event as well as * Swallow the press event as well as
* the release one * the release one
*/ */
handled = true; consumed_by_frame_context |=
handled_in_compositor |=
mousebind->context == LAB_SSD_FRAME; mousebind->context == LAB_SSD_FRAME;
mousebind->pressed_in_context = true; mousebind->pressed_in_context = true;
} }
@ -766,12 +761,11 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
default: default:
continue; continue;
} }
handled = true; consumed_by_frame_context |= mousebind->context == LAB_SSD_FRAME;
handled_in_compositor |= mousebind->context == LAB_SSD_FRAME;
actions_run(ctx->view, server, &mousebind->actions, resize_edges); 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() */ /* Set in cursor_button_press(), used in cursor_button_release() */
@ -813,10 +807,10 @@ cursor_button_press(struct seat *seat, struct wlr_pointer_button_event *event)
} }
/* Bindings to the Frame context swallow mouse events if activated */ /* Bindings to the Frame context swallow mouse events if activated */
bool handled = handle_press_mousebinding( bool consumed_by_frame_context =
server, &ctx, event->button, resize_edges); 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 */ /* Notify client with pointer focus of button press */
wlr_seat_pointer_notify_button(seat->seat, event->time_msec, wlr_seat_pointer_notify_button(seat->seat, event->time_msec,
event->button, event->state); event->button, event->state);
@ -859,9 +853,10 @@ cursor_button_release(struct seat *seat, struct wlr_pointer_button_event *event)
} }
/* Bindings to the Frame context swallow mouse events if activated */ /* 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 */ /* Notify client with pointer focus of button release */
wlr_seat_pointer_notify_button(seat->seat, event->time_msec, wlr_seat_pointer_notify_button(seat->seat, event->time_msec,
event->button, event->state); event->button, event->state);