]> git.eshelyaron.com Git - emacs.git/commitdiff
Use window beneath mouse for determining scroll deltas on Haiku
authorPo Lu <luangruo@yahoo.com>
Tue, 11 Jan 2022 01:30:14 +0000 (01:30 +0000)
committerPo Lu <luangruo@yahoo.com>
Tue, 11 Jan 2022 01:30:14 +0000 (01:30 +0000)
* src/haikuterm.c (haiku_read_socket): Use window underneath
wheel for calculating scroll deltas.

src/haikuterm.c

index 2304f718c31c0b8054063aea1874dc2f1319f376..be28649aef2a091913f0b6896b90b74885416b5d 100644 (file)
@@ -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)