From 677859b7af143e3bb2f8f15bb47ff7b7773dc955 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 21 Nov 2021 03:40:36 +0000 Subject: [PATCH] Add pixel delta support for wheel events on Haiku * src/haiku_support.cc (EmacsWindow.MessageReceived): Stop adjusting scroll deltas. * src/haikuterm.c (haiku_read_socket): Handle pixel deltas correctly. --- src/haiku_support.cc | 4 ++-- src/haikuterm.c | 32 ++++++++++++++------------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 99d4ee79140..5f9fe7e234f 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -631,8 +631,8 @@ public: if (msg->FindFloat ("be:wheel_delta_x", &dx) == B_OK && msg->FindFloat ("be:wheel_delta_y", &dy) == B_OK) { - rq.delta_x = dx * 10; - rq.delta_y = dy * 10; + rq.delta_x = dx; + rq.delta_y = dy; haiku_write (WHEEL_MOVE_EVENT, &rq); }; diff --git a/src/haikuterm.c b/src/haikuterm.c index 05fbd1021b8..6b3c5dbe483 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -3005,34 +3005,26 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) if (signbit (py) != signbit (b->delta_y)) py = 0; - px += b->delta_x; - py += b->delta_y; + px += b->delta_x * pow (FRAME_PIXEL_HEIGHT (f), 2.0 / 3.0); + py += b->delta_y * pow (FRAME_PIXEL_HEIGHT (f), 2.0 / 3.0); - if (fabsf (py) >= FRAME_LINE_HEIGHT (f)) + if (fabsf (py) >= FRAME_LINE_HEIGHT (f) + || fabsf (px) >= FRAME_COLUMN_WIDTH (f) + || !x_coalesce_scroll_events) { - inev.kind = WHEEL_EVENT; + inev.kind = (fabsf (px) > fabs (py) + ? HORIZ_WHEEL_EVENT + : WHEEL_EVENT); inev.code = 0; XSETINT (inev.x, x); XSETINT (inev.y, y); - XSETINT (inev.arg, lrint (fabsf (py) / FRAME_LINE_HEIGHT (f))); + inev.arg = list3 (Qnil, make_float (px), + make_float (py)); XSETFRAME (inev.frame_or_window, f); inev.modifiers |= signbit (py) ? up_modifier : down_modifier; py = 0.0f; - } - - if (fabsf (px) >= FRAME_COLUMN_WIDTH (f)) - { - inev2.kind = HORIZ_WHEEL_EVENT; - inev2.code = 0; - - XSETINT (inev2.x, x); - XSETINT (inev2.y, y); - XSETINT (inev2.arg, lrint (fabsf (px) / FRAME_COLUMN_WIDTH (f))); - XSETFRAME (inev2.frame_or_window, f); - - inev2.modifiers |= signbit (px) ? up_modifier : down_modifier; px = 0.0f; } @@ -3548,6 +3540,10 @@ syms_of_haikuterm (void) doc: /* SKIP: real doc in xterm.c. */); Vx_toolkit_scroll_bars = Qt; + DEFVAR_BOOL ("x-coalesce-scroll-events", x_coalesce_scroll_events, + doc: /* SKIP: real doc in xterm.c. */); + x_coalesce_scroll_events = true; + DEFVAR_BOOL ("haiku-debug-on-fatal-error", haiku_debug_on_fatal_error, doc: /* If non-nil, Emacs will launch the system debugger upon a fatal error. */); haiku_debug_on_fatal_error = 1; -- 2.39.5