]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: validate double-click against SSD part type
authorJohan Malm <jgm323@gmail.com>
Mon, 25 Mar 2024 21:49:46 +0000 (21:49 +0000)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 28 Mar 2024 05:00:06 +0000 (06:00 +0100)
...because click on different parts of a client should not be
interpreted as a double click.

Previously only cursor-button and view were validated to be the same
between clicks. This resulted in, for example a click on the client
surface itself quickly followed by a click on the SSD titlebar being
interpreted as a double-click on the titlebar.

Fixes: #1657
src/input/cursor.c

index ad5782ed366802443b96b6a589289f010e97db02..eb359e717b5f4264dbed7692d855a9971a369c6a 100644 (file)
@@ -855,8 +855,10 @@ handle_release_mousebinding(struct server *server,
 }
 
 static bool
-is_double_click(long double_click_speed, uint32_t button, struct view *view)
+is_double_click(long double_click_speed, uint32_t button,
+               struct cursor_context *ctx)
 {
+       static enum ssd_part_type last_type;
        static uint32_t last_button;
        static struct view *last_view;
        static struct timespec last_click;
@@ -866,9 +868,11 @@ is_double_click(long double_click_speed, uint32_t button, struct view *view)
        long ms = (now.tv_sec - last_click.tv_sec) * 1000 +
                (now.tv_nsec - last_click.tv_nsec) / 1000000;
        last_click = now;
-       if (last_button != button || last_view != view) {
+       if (last_button != button || last_view != ctx->view
+                       || last_type != ctx->type) {
                last_button = button;
-               last_view = view;
+               last_view = ctx->view;
+               last_type = ctx->type;
                return false;
        }
        if (ms < double_click_speed && ms >= 0) {
@@ -878,6 +882,7 @@ is_double_click(long double_click_speed, uint32_t button, struct view *view)
                 */
                last_button = 0;
                last_view = NULL;
+               last_type = 0;
                return true;
        }
        return false;
@@ -888,7 +893,7 @@ handle_press_mousebinding(struct server *server, struct cursor_context *ctx,
                uint32_t button, uint32_t resize_edges)
 {
        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);
        bool consumed_by_frame_context = false;
 
        uint32_t modifiers = wlr_keyboard_get_modifiers(