]> git.eshelyaron.com Git - emacs.git/commitdiff
Make C-mouse-3 on scroll bars work on Haiku
authorPo Lu <luangruo@yahoo.com>
Sat, 12 Mar 2022 02:47:03 +0000 (02:47 +0000)
committerPo Lu <luangruo@yahoo.com>
Sat, 12 Mar 2022 02:47:03 +0000 (02:47 +0000)
* src/haiku_support.cc (class EmacsScrollBar): New field
`handle_button'.
(MouseDown, MouseUp): Pass button events with ControlMask to
parent view.

src/haiku_support.cc

index 07e3ee2bb649380833a4659c2e6e057375275a80..c95cd6d940f078c0e1489f5e2c4b3cfddb8e37fa 100644 (file)
@@ -1563,6 +1563,9 @@ public:
   float old_value;
   scroll_bar_info info;
 
+  /* True if button events should be passed to the parent.  */
+  bool handle_button = false;
+
   EmacsScrollBar (int x, int y, int x1, int y1, bool horizontal_p) :
     BScrollBar (BRect (x, y, x1, y1), NULL, NULL, 0, 0, horizontal_p ?
                B_HORIZONTAL : B_VERTICAL)
@@ -1703,9 +1706,11 @@ public:
     BRegion r;
     BLooper *looper;
     BMessage *message;
-    int32 buttons;
+    int32 buttons, mods;
+    BView *parent;
 
     looper = Looper ();
+    message = NULL;
 
     if (!looper)
       GetMouse (&pt, (uint32 *) &buttons, false);
@@ -1717,6 +1722,18 @@ public:
          GetMouse (&pt, (uint32 *) &buttons, false);
       }
 
+    if (message && (message->FindInt32 ("modifiers", &mods)
+                   == B_OK)
+       && mods & B_CONTROL_KEY)
+      {
+       /* Allow C-mouse-3 to split the window on a scroll bar.   */
+       handle_button = true;
+       parent = Parent ();
+       parent->MouseDown (ConvertToParent (pt));
+
+       return;
+      }
+
     if (buttons == B_PRIMARY_MOUSE_BUTTON)
       {
        r = ButtonRegionFor (HAIKU_SCROLL_BAR_UP_BUTTON);
@@ -1762,6 +1779,17 @@ public:
   MouseUp (BPoint pt)
   {
     struct haiku_scroll_bar_drag_event rq;
+    BView *parent;
+
+    if (handle_button)
+      {
+       handle_button = false;
+       parent = Parent ();
+       parent->MouseUp (ConvertToParent (pt));
+
+       return;
+      }
+
     rq.dragging_p = 0;
     rq.scroll_bar = this;
     rq.window = Window ();