emacs-diffs
[Top][All Lists]
Advanced

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

master 81cb96df88: Use window beneath mouse for determining scroll delta


From: Po Lu
Subject: master 81cb96df88: Use window beneath mouse for determining scroll deltas on Haiku
Date: Mon, 10 Jan 2022 20:33:59 -0500 (EST)

branch: master
commit 81cb96df88c9bcaa582fbc76022625ab13a05ed8
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Use window beneath mouse for determining scroll deltas on Haiku
    
    * src/haikuterm.c (haiku_read_socket): Use window underneath
    wheel for calculating scroll deltas.
---
 src/haikuterm.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index 2304f718c3..be28649aef 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3045,13 +3045,28 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
          {
            struct haiku_wheel_move_event *b = buf;
            struct frame *f = haiku_window_to_frame (b->window);
-           int x, y;
+           int x, y, scroll_width, scroll_height;
            static float px = 0.0f, py = 0.0f;
+           Lisp_Object wheel_window;
 
            if (!f)
              continue;
+
            BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
+           wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+
+           if (NILP (wheel_window))
+             {
+               scroll_width = FRAME_PIXEL_WIDTH (f);
+               scroll_height = FRAME_PIXEL_HEIGHT (f);
+             }
+           else
+             {
+               scroll_width = XWINDOW (wheel_window)->pixel_width;
+               scroll_height = XWINDOW (wheel_window)->pixel_height;
+             }
+
            inev.modifiers = haiku_modifiers_to_emacs (b->modifiers);
 
            inev2.modifiers = inev.modifiers;
@@ -3063,9 +3078,9 @@ haiku_read_socket (struct terminal *terminal, struct 
input_event *hold_quit)
              py = 0;
 
            px += (b->delta_x
-                  * powf (FRAME_PIXEL_HEIGHT (f), 2.0f / 3.0f));
+                  * powf (scroll_width, 2.0f / 3.0f));
            py += (b->delta_y
-                  * powf (FRAME_PIXEL_HEIGHT (f), 2.0f / 3.0f));
+                  * powf (scroll_height, 2.0f / 3.0f));
 
            if (fabsf (py) >= FRAME_LINE_HEIGHT (f)
                || fabsf (px) >= FRAME_COLUMN_WIDTH (f)



reply via email to

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