emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 97f9eeaaef: Allow holding down scroll bar buttons on Haiku when o


From: Po Lu
Subject: master 97f9eeaaef: Allow holding down scroll bar buttons on Haiku when overscrolling
Date: Thu, 24 Mar 2022 01:33:49 -0400 (EDT)

branch: master
commit 97f9eeaaefebf5f3852b062535f7c041831609bd
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Allow holding down scroll bar buttons on Haiku when overscrolling
    
    * 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 | 45 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 5ad3c7c794..b58420fcb9 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -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);
   }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]