[gtk+/smooth-scrolling-for-3.4: 8/20] quartz: Implement smooth scrolling
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/smooth-scrolling-for-3.4: 8/20] quartz: Implement smooth scrolling
- Date: Thu, 23 Feb 2012 13:49:52 +0000 (UTC)
commit 29bf1d2a5a2a7aa2debc50c354d8c184df4d231d
Author: Michael Natterer <mitch lanedo com>
Date: Tue Jan 24 00:41:49 2012 +0100
quartz: Implement smooth scrolling
nsevent scrollingDeltaX/Y (available on OSX >= Lion) is used to
provide the smooth scrolling values. In any case, old fashioned
events are still sent, setting _gdk_event_set_pointer_emulated()
if the event contains both smooth and non-smooth values.
gdk/quartz/gdkevents-quartz.c | 56 +++++++++++++++++++++++++++++++++++------
1 files changed, 48 insertions(+), 8 deletions(-)
---
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 67934c5..3e2bc5a 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -870,6 +870,8 @@ fill_scroll_event (GdkWindow *window,
gint y,
gint x_root,
gint y_root,
+ gdouble delta_x,
+ gdouble delta_y,
GdkScrollDirection direction)
{
NSPoint point;
@@ -886,6 +888,8 @@ fill_scroll_event (GdkWindow *window,
event->scroll.state = get_keyboard_modifiers_from_ns_event (nsevent);
event->scroll.direction = direction;
event->scroll.device = _gdk_display->core_pointer;
+ event->scroll.delta_x = delta_x;
+ event->scroll.delta_y = delta_y;
}
static void
@@ -1320,28 +1324,64 @@ gdk_event_translate (GdkEvent *event,
case NSScrollWheel:
{
- float dx = [nsevent deltaX];
- float dy = [nsevent deltaY];
- GdkScrollDirection direction;
+ GdkScrollDirection direction;
+ float dx;
+ float dy;
- if (dy != 0)
+ if (gdk_quartz_osx_version() >= GDK_OSX_LION &&
+ [nsevent hasPreciseScrollingDeltas])
+ {
+ dx = [nsevent scrollingDeltaX];
+ dy = [nsevent scrollingDeltaY];
+ direction = GDK_SCROLL_SMOOTH;
+
+ fill_scroll_event (window, event, nsevent, x, y, x_root, y_root,
+ -dx, -dy, direction);
+
+ /* Fall through for scroll buttons emulation */
+ }
+
+ dx = [nsevent deltaX];
+ dy = [nsevent deltaY];
+
+ if (dy != 0.0)
{
if (dy < 0.0)
direction = GDK_SCROLL_DOWN;
else
direction = GDK_SCROLL_UP;
- fill_scroll_event (window, event, nsevent, x, y, x_root, y_root, direction);
+ dy = fabs (dy);
+ dx = 0.0;
}
-
- if (dx != 0)
+ else if (dx != 0.0)
{
if (dx < 0.0)
direction = GDK_SCROLL_RIGHT;
else
direction = GDK_SCROLL_LEFT;
- fill_scroll_event (window, event, nsevent, x, y, x_root, y_root, direction);
+ dx = fabs (dx);
+ dy = 0.0;
+ }
+
+ if (dx != 0.0 || dy != 0.0)
+ {
+ if ([nsevent hasPreciseScrollingDeltas])
+ {
+ GdkEvent *emulated_event;
+
+ emulated_event = gdk_event_new (GDK_SCROLL);
+ _gdk_event_set_pointer_emulated (emulated_event, TRUE);
+ fill_scroll_event (window, emulated_event, nsevent,
+ x, y, x_root, y_root,
+ dx, dy, direction);
+ append_event (emulated_event, TRUE);
+ }
+ else
+ fill_scroll_event (window, event, nsevent,
+ x, y, x_root, y_root,
+ dx, dy, direction);
}
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]