]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: combine two variables relating to frame-context
authorJohan Malm <jgm323@gmail.com>
Mon, 7 Nov 2022 20:26:37 +0000 (20:26 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 15 Nov 2022 22:23:14 +0000 (22:23 +0000)
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

index e5c906339444dba0f39bcbaf5248b28ac24b6633..888b032702c7c5ce6f55c3417a6334c064409aea 100644 (file)
@@ -642,8 +642,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);
@@ -666,16 +665,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);
                }
@@ -689,7 +686,7 @@ handle_release_mousebinding(struct server *server,
                        mousebind->pressed_in_context = false;
                }
        }
-       return handled && handled_in_compositor;
+       return consumed_by_frame_context;
 }
 
 static bool
@@ -727,8 +724,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);
@@ -750,8 +746,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;
                                }
@@ -766,12 +761,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() */
@@ -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 */
-       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);
@@ -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 */
-       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);