mirror of
https://github.com/labwc/labwc.git
synced 2026-03-26 07:58:08 -04:00
src/cursor.c: Use 'handled' for state of consumed cursor actions
This commit is contained in:
parent
bd4a0f15b8
commit
97dc681c3b
1 changed files with 24 additions and 25 deletions
49
src/cursor.c
49
src/cursor.c
|
|
@ -634,8 +634,8 @@ 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 activated_any = false;
|
bool handled = false;
|
||||||
bool activated_any_frame = 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);
|
||||||
|
|
@ -658,30 +658,30 @@ 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
|
||||||
*/
|
*/
|
||||||
activated_any = true;
|
handled = true;
|
||||||
activated_any_frame |=
|
handled_in_compositor |=
|
||||||
mousebind->context == LAB_SSD_FRAME;
|
mousebind->context == LAB_SSD_FRAME;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
activated_any = true;
|
handled = true;
|
||||||
activated_any_frame |= 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Clear "pressed" status for all bindings of this mouse button,
|
* Clear "pressed" status for all bindings of this mouse button,
|
||||||
* regardless of whether activated or not
|
* regardless of whether handled or not
|
||||||
*/
|
*/
|
||||||
wl_list_for_each(mousebind, &rc.mousebinds, link) {
|
wl_list_for_each(mousebind, &rc.mousebinds, link) {
|
||||||
if (mousebind->button == button) {
|
if (mousebind->button == button) {
|
||||||
mousebind->pressed_in_context = false;
|
mousebind->pressed_in_context = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return activated_any && activated_any_frame;
|
return handled && handled_in_compositor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -719,8 +719,8 @@ 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 activated_any = false;
|
bool handled = false;
|
||||||
bool activated_any_frame = 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);
|
||||||
|
|
@ -742,8 +742,8 @@ 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
|
||||||
*/
|
*/
|
||||||
activated_any = true;
|
handled = true;
|
||||||
activated_any_frame |=
|
handled_in_compositor |=
|
||||||
mousebind->context == LAB_SSD_FRAME;
|
mousebind->context == LAB_SSD_FRAME;
|
||||||
mousebind->pressed_in_context = true;
|
mousebind->pressed_in_context = true;
|
||||||
}
|
}
|
||||||
|
|
@ -758,12 +758,12 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
activated_any = true;
|
handled = true;
|
||||||
activated_any_frame |= 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 activated_any && activated_any_frame;
|
return handled && handled_in_compositor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set in cursor_button_press(), used in cursor_button_release() */
|
/* Set in cursor_button_press(), used in cursor_button_release() */
|
||||||
|
|
@ -805,10 +805,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 triggered_frame_binding = handle_press_mousebinding(
|
bool handled = handle_press_mousebinding(
|
||||||
server, &ctx, event->button, resize_edges);
|
server, &ctx, event->button, resize_edges);
|
||||||
|
|
||||||
if (ctx.surface && !triggered_frame_binding) {
|
if (ctx.surface && !handled) {
|
||||||
/* 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);
|
||||||
|
|
@ -851,10 +851,9 @@ 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 triggered_frame_binding =
|
bool handled = handle_release_mousebinding(server, &ctx, event->button);
|
||||||
handle_release_mousebinding(server, &ctx, event->button);
|
|
||||||
|
|
||||||
if (ctx.surface && !triggered_frame_binding) {
|
if (ctx.surface && !handled) {
|
||||||
/* 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);
|
||||||
|
|
@ -887,7 +886,7 @@ handle_cursor_axis(struct server *server, struct cursor_context *ctx,
|
||||||
struct wlr_pointer_axis_event *event)
|
struct wlr_pointer_axis_event *event)
|
||||||
{
|
{
|
||||||
struct mousebind *mousebind;
|
struct mousebind *mousebind;
|
||||||
bool activated_any = false;
|
bool handled = 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);
|
||||||
|
|
@ -910,12 +909,12 @@ handle_cursor_axis(struct server *server, struct cursor_context *ctx,
|
||||||
&& mousebind->button == button
|
&& mousebind->button == button
|
||||||
&& modifiers == mousebind->modifiers
|
&& modifiers == mousebind->modifiers
|
||||||
&& mousebind->mouse_event == MOUSE_ACTION_SCROLL) {
|
&& mousebind->mouse_event == MOUSE_ACTION_SCROLL) {
|
||||||
activated_any = true;
|
handled = true;
|
||||||
actions_run(ctx->view, server, &mousebind->actions, /*resize_edges*/ 0);
|
actions_run(ctx->view, server, &mousebind->actions, /*resize_edges*/ 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return activated_any;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -932,9 +931,9 @@ cursor_axis(struct wl_listener *listener, void *data)
|
||||||
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
|
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
|
||||||
|
|
||||||
/* Bindings swallow mouse events if activated */
|
/* Bindings swallow mouse events if activated */
|
||||||
bool triggered_axis_binding = handle_cursor_axis(server, &ctx, event);
|
bool handled = handle_cursor_axis(server, &ctx, event);
|
||||||
|
|
||||||
if (ctx.surface && !triggered_axis_binding) {
|
if (ctx.surface && !handled) {
|
||||||
/* Make sure we are sending the events to the surface under the cursor */
|
/* Make sure we are sending the events to the surface under the cursor */
|
||||||
cursor_update_common(server, &ctx, event->time_msec, false);
|
cursor_update_common(server, &ctx, event->time_msec, false);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue