]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: More reliably clear "pressed" status of mouse bindings
authorJohn Lindgren <john@jlindgren.net>
Sat, 8 Jan 2022 07:47:30 +0000 (02:47 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 8 Jan 2022 09:31:53 +0000 (09:31 +0000)
The "pressed" status of the mouse button is stored per-binding, and
the first binding activated causes us to break out of the loop that
cleared the "pressed" status -- as a result, some statused weren't
cleared when another binding was activated.

The bug could be seen when clicking the maximize button on a window
and then moving the mouse: the DRAG action would continue to move
the window (unmaximizing it) even though the mouse button was no
longer held.

src/cursor.c

index 12d7298156cf45ca7d9e47e2796d21f4a1eb914a..fd9b6e31c0e9180f6ecf04c74dc73dc01cb74e02 100644 (file)
@@ -481,10 +481,8 @@ handle_release_mousebinding(struct view *view, struct server *server,
                        case MOUSE_ACTION_RELEASE:
                                break;
                        case MOUSE_ACTION_CLICK:
-                               if (mousebind->pressed_in_context) {
-                                       mousebind->pressed_in_context = false;
+                               if (mousebind->pressed_in_context)
                                        break;
-                               }
                                continue;
                        default:
                                continue;
@@ -493,8 +491,14 @@ handle_release_mousebinding(struct view *view, struct server *server,
                        activated_any_frame |= mousebind->context == LAB_SSD_FRAME;
                        action(view, server, &mousebind->actions, resize_edges);
                }
-               /* For the drag events */
-               mousebind->pressed_in_context = false;
+       }
+       /*
+        * Clear "pressed" status for all bindings of this mouse button,
+        * regardless of whether activated or not
+        */
+       wl_list_for_each(mousebind, &rc.mousebinds, link) {
+               if (mousebind->button == button)
+                       mousebind->pressed_in_context = false;
        }
        return activated_any && activated_any_frame;
 }