summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-03-05 00:12:27 (GMT)
committerMatthias Clasen <mclasen@redhat.com>2012-03-05 00:12:27 (GMT)
commit3dd5e88c07f659d66ee0f7305a96b51b7fe1072d (patch)
tree214c6a043dc1322e4fb469e03febba5873dbf1ab
parent47c190a1b732225a9c26bfd492f8c392f5adc931 (diff)
downloadgtk+-3dd5e88c07f659d66ee0f7305a96b51b7fe1072d.zip
gtk+-3dd5e88c07f659d66ee0f7305a96b51b7fe1072d.tar.xz
xi2: Normalize scroll deltas
XI2 provides us with an increment for each scroll valuator, and by dividing the delta by the increment, we obtain normalized values in some abstract 'scroll unit'. For mouse wheels, the evdev driver reports an increment of -1, so doing this division fixes the inverted scrolling with wheels that we've seen recently.
-rw-r--r--gdk/x11/gdkdevice-xi2.c7
-rw-r--r--gdk/x11/gdkdevicemanager-xi2.c8
-rw-r--r--gdk/x11/gdkprivate-x11.h3
3 files changed, 12 insertions, 6 deletions
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 6e49626..263b3f3 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -38,6 +38,7 @@ struct _ScrollValuator
guint direction : 4;
guint last_value_valid : 1;
gdouble last_value;
+ gdouble increment;
};
struct _GdkX11DeviceXI2
@@ -791,7 +792,8 @@ _gdk_x11_device_xi2_translate_state (XIModifierState *mods_state,
void
_gdk_x11_device_xi2_add_scroll_valuator (GdkX11DeviceXI2 *device,
guint n_valuator,
- GdkScrollDirection direction)
+ GdkScrollDirection direction,
+ gdouble increment)
{
ScrollValuator scroll;
@@ -801,6 +803,7 @@ _gdk_x11_device_xi2_add_scroll_valuator (GdkX11DeviceXI2 *device,
scroll.n_valuator = n_valuator;
scroll.direction = direction;
scroll.last_value_valid = FALSE;
+ scroll.increment = increment;
g_array_append_val (device->scroll_valuators, scroll);
}
@@ -834,7 +837,7 @@ _gdk_x11_device_xi2_get_scroll_delta (GdkX11DeviceXI2 *device,
if (scroll->last_value_valid)
{
if (delta_ret)
- *delta_ret = valuator_value - scroll->last_value;
+ *delta_ret = (valuator_value - scroll->last_value) / scroll->increment;
scroll->last_value = valuator_value;
}
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index b4a0256..6f93fd2 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -247,15 +247,17 @@ translate_device_classes (GdkDisplay *display,
direction = GDK_SCROLL_RIGHT;
GDK_NOTE (INPUT,
- g_message ("\n\tscroll valuator %d: %s",
+ g_message ("\n\tscroll valuator %d: %s, increment %f",
scroll_info->number,
scroll_info->scroll_type == XIScrollTypeVertical
? "vertical"
- : "horizontal"));
+ : "horizontal",
+ scroll_info->increment));
_gdk_x11_device_xi2_add_scroll_valuator (GDK_X11_DEVICE_XI2 (device),
scroll_info->number,
- direction);
+ direction,
+ scroll_info->increment);
}
#endif /* XINPUT_2_2 */
default:
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 14ab2fd..d17d4fd 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -239,7 +239,8 @@ GdkDevice * _gdk_x11_device_manager_xi2_lookup (GdkX11DeviceManagerXI2 *devic
gint device_id);
void _gdk_x11_device_xi2_add_scroll_valuator (GdkX11DeviceXI2 *device,
guint n_valuator,
- GdkScrollDirection direction);
+ GdkScrollDirection direction,
+ gdouble increment);
gboolean _gdk_x11_device_xi2_get_scroll_delta (GdkX11DeviceXI2 *device,
guint n_valuator,
gdouble valuator_value,