]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow holding down scroll bar buttons on Haiku when overscrolling
authorPo Lu <luangruo@yahoo.com>
Thu, 24 Mar 2022 05:32:34 +0000 (05:32 +0000)
committerPo Lu <luangruo@yahoo.com>
Thu, 24 Mar 2022 05:32:34 +0000 (05:32 +0000)
* src/haiku_support.cc (EmacsWindow): Set appropriate pulse
rate.
(class EmacsScrollBar, ValueChanged): Don't send any part events
here.
(MouseDown): Set dragging to a value larger than 1 if the scroll
bar is at the end.
(Pulse): New method.

src/haiku_support.cc

index 5ad3c7c794daf65cbf9f9ebf3911190c64257861..b58420fcb99b09a54fbd5b920588302a80c1947b 100644 (file)
@@ -422,6 +422,10 @@ public:
                            B_NORMAL_WINDOW_FEEL, B_NO_SERVER_SIDE_WINDOW_MODIFIERS)
   {
     window_id = current_window_id++;
+
+    /* This pulse rate is used by scroll bars for repeating a button
+       action while a button is held down.  */
+    SetPulseRate (30000);
   }
 
   ~EmacsWindow ()
@@ -1765,11 +1769,36 @@ public:
     BScrollBar::MessageReceived (msg);
   }
 
+  void
+  Pulse (void)
+  {
+    struct haiku_scroll_bar_part_event rq;
+    BPoint point;
+    uint32 buttons;
+
+    if (!dragging)
+      {
+       SetFlags (Flags () & ~B_PULSE_NEEDED);
+       return;
+      }
+
+    GetMouse (&point, &buttons, false);
+
+    if (ButtonRegionFor (current_part).Contains (point))
+      {
+       rq.scroll_bar = this;
+       rq.window = Window ();
+       rq.part = current_part;
+       haiku_write (SCROLL_BAR_PART_EVENT, &rq);
+      }
+
+    BScrollBar::Pulse ();
+  }
+
   void
   ValueChanged (float new_value)
   {
     struct haiku_scroll_bar_value_event rq;
-    struct haiku_scroll_bar_part_event part;
 
     new_value = Value ();
 
@@ -1780,11 +1809,7 @@ public:
            if (dragging > 1)
              {
                SetValue (old_value);
-
-               part.scroll_bar = this;
-               part.window = Window ();
-               part.part = current_part;
-               haiku_write (SCROLL_BAR_PART_EVENT, &part);
+               SetFlags (Flags () | B_PULSE_NEEDED);
              }
            else
              dragging++;
@@ -1924,6 +1949,12 @@ public:
            dragging = 1;
            current_part = HAIKU_SCROLL_BAR_DOWN_BUTTON;
 
+           if (Value () == max_value)
+             {
+               SetFlags (Flags () | B_PULSE_NEEDED);
+               dragging = 2;
+             }
+
            haiku_write (SCROLL_BAR_PART_EVENT, &part);
            goto out;
          }
@@ -1967,7 +1998,7 @@ public:
     rq.window = Window ();
 
     haiku_write (SCROLL_BAR_DRAG_EVENT, &rq);
-    dragging = false;
+    dragging = 0;
 
     BScrollBar::MouseUp (pt);
   }