]> git.eshelyaron.com Git - emacs.git/commitdiff
Ignore irrelevant button events on Haiku scroll bars
authorPo Lu <luangruo@yahoo.com>
Sat, 26 Feb 2022 12:25:51 +0000 (12:25 +0000)
committerPo Lu <luangruo@yahoo.com>
Sat, 26 Feb 2022 12:25:51 +0000 (12:25 +0000)
* src/haiku_support.cc (MouseDown): Ignore if there are too many
buttons pressed.

src/haiku_support.cc

index fe91986e8c46162df1945c816ea4844ffbbe0f5c..12990b3378dcb15203a8b81d94cbdd0529421930 100644 (file)
@@ -1684,33 +1684,51 @@ public:
     struct haiku_scroll_bar_drag_event rq;
     struct haiku_scroll_bar_part_event part;
     BRegion r;
+    BLooper *looper;
+    BMessage *message;
+    int32 buttons;
 
-    r = ButtonRegionFor (HAIKU_SCROLL_BAR_UP_BUTTON);
+    looper = Looper ();
 
-    if (r.Contains (pt))
+    if (!looper)
+      GetMouse (&pt, (uint32 *) &buttons, false);
+    else
       {
-       part.scroll_bar = this;
-       part.window = Window ();
-       part.part = HAIKU_SCROLL_BAR_UP_BUTTON;
-       dragging = 1;
-       current_part = HAIKU_SCROLL_BAR_UP_BUTTON;
-
-       haiku_write (SCROLL_BAR_PART_EVENT, &part);
-       goto out;
-      }
+       message = looper->CurrentMessage ();
 
-    r = ButtonRegionFor (HAIKU_SCROLL_BAR_DOWN_BUTTON);
+       if (!message || message->FindInt32 ("buttons", &buttons) != B_OK)
+         GetMouse (&pt, (uint32 *) &buttons, false);
+      }
 
-    if (r.Contains (pt))
+    if (buttons == B_PRIMARY_MOUSE_BUTTON)
       {
-       part.scroll_bar = this;
-       part.window = Window ();
-       part.part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
-       dragging = 1;
-       current_part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
-
-       haiku_write (SCROLL_BAR_PART_EVENT, &part);
-       goto out;
+       r = ButtonRegionFor (HAIKU_SCROLL_BAR_UP_BUTTON);
+
+       if (r.Contains (pt))
+         {
+           part.scroll_bar = this;
+           part.window = Window ();
+           part.part = HAIKU_SCROLL_BAR_UP_BUTTON;
+           dragging = 1;
+           current_part = HAIKU_SCROLL_BAR_UP_BUTTON;
+
+           haiku_write (SCROLL_BAR_PART_EVENT, &part);
+           goto out;
+         }
+
+       r = ButtonRegionFor (HAIKU_SCROLL_BAR_DOWN_BUTTON);
+
+       if (r.Contains (pt))
+         {
+           part.scroll_bar = this;
+           part.window = Window ();
+           part.part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
+           dragging = 1;
+           current_part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
+
+           haiku_write (SCROLL_BAR_PART_EVENT, &part);
+           goto out;
+         }
       }
 
     rq.dragging_p = 1;