[gtk: 6/9] gdk/x11: Handle high-resolution scroll events
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 6/9] gdk/x11: Handle high-resolution scroll events
- Date: Wed, 10 Aug 2022 16:51:56 +0000 (UTC)
commit 37a561eb53ae42e5d786eed1309fd17b872c6ee1
Author: José Expósito <jose exposito89 gmail com>
Date: Mon Sep 20 20:00:04 2021 +0200
gdk/x11: Handle high-resolution scroll events
gdk/x11/gdkdevicemanager-xi2.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index a146333b5d..44e3342338 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1729,6 +1729,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
&xev->valuators, &delta_x, &delta_y))
{
GdkModifierType state;
+ GdkScrollDirection direction;
GDK_DISPLAY_NOTE (display, EVENTS,
g_message ("smooth scroll: \n\tdevice: %u\n\tsource device: %u\n\twindow %ld\n\tdeltas:
%f %f",
@@ -1737,21 +1738,19 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
+ if (delta_x > 0)
+ direction = GDK_SCROLL_RIGHT;
+ else if (delta_x < 0)
+ direction = GDK_SCROLL_LEFT;
+ else if (delta_y > 0)
+ direction = GDK_SCROLL_DOWN;
+ else
+ direction = GDK_SCROLL_UP;
+
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHPAD &&
((delta_x == 0.0 && ABS (delta_y) == 1.0) ||
(ABS (delta_x) == 1.0 && delta_y == 0.0)))
{
- GdkScrollDirection direction;
-
- if (delta_x > 0)
- direction = GDK_SCROLL_RIGHT;
- else if (delta_x < 0)
- direction = GDK_SCROLL_LEFT;
- else if (delta_y > 0)
- direction = GDK_SCROLL_DOWN;
- else
- direction = GDK_SCROLL_UP;
-
event = gdk_scroll_event_new_discrete (surface,
device,
NULL,
@@ -1759,6 +1758,17 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
state,
direction);
}
+ else if (gdk_device_get_source (source_device) == GDK_SOURCE_MOUSE)
+ {
+ event = gdk_scroll_event_new_value120 (surface,
+ device,
+ NULL,
+ xev->time,
+ state,
+ direction,
+ delta_x * 120.0,
+ delta_y * 120.0);
+ }
else
{
event = gdk_scroll_event_new (surface,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]