Bug 958868 - Add support for GDK_SCROLL_SMOOTH; r=karlt

This commit is contained in:
Andrew Comminos 2014-06-24 18:02:10 +09:00
parent 5fee249d8f
commit bb27e2b35f
3 changed files with 42 additions and 1 deletions

View File

@ -490,8 +490,10 @@ STUB(gtk_window_unmaximize)
#endif
#ifdef GTK3_SYMBOLS
STUB(gdk_device_get_source)
STUB(gdk_device_manager_get_client_pointer)
STUB(gdk_display_get_device_manager)
STUB(gdk_event_get_source_device)
STUB(gdk_window_get_type)
STUB(gdk_x11_window_get_xid)
STUB(gtk_cairo_should_draw_window)

View File

@ -136,6 +136,9 @@ const gint kEvents = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
GDK_VISIBILITY_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
#if GTK_CHECK_VERSION(3,4,0)
GDK_SMOOTH_SCROLL_MASK |
#endif
GDK_SCROLL_MASK |
GDK_POINTER_MOTION_MASK;
@ -381,6 +384,10 @@ nsWindow::nsWindow()
mTransparencyBitmapWidth = 0;
mTransparencyBitmapHeight = 0;
#if GTK_CHECK_VERSION(3,4,0)
mLastScrollEventTime = GDK_CURRENT_TIME;
#endif
}
nsWindow::~nsWindow()
@ -3078,10 +3085,37 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent)
// check to see if we should rollup
if (CheckForRollup(aEvent->x_root, aEvent->y_root, true, false))
return;
#if GTK_CHECK_VERSION(3,4,0)
// check for duplicate legacy scroll event, see GNOME bug 726878
if (mLastScrollEventTime == aEvent->time)
return;
#endif
WidgetWheelEvent wheelEvent(true, NS_WHEEL_WHEEL, this);
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
switch (aEvent->direction) {
#if GTK_CHECK_VERSION(3,4,0)
case GDK_SCROLL_SMOOTH:
{
// As of GTK 3.4, all directional scroll events are provided by
// the GDK_SCROLL_SMOOTH direction on XInput2 devices.
mLastScrollEventTime = aEvent->time;
// TODO - use a more appropriate scrolling unit than lines.
// Multiply event deltas by 3 to emulate legacy behaviour.
wheelEvent.deltaX = aEvent->delta_x * 3;
wheelEvent.deltaY = aEvent->delta_y * 3;
wheelEvent.mIsNoLineOrPageDelta = true;
// This next step manually unsets smooth scrolling for touch devices
// that trigger GDK_SCROLL_SMOOTH. We use the slave device, which
// represents the actual input.
GdkDevice *device = gdk_event_get_source_device((GdkEvent*)aEvent);
GdkInputSource source = gdk_device_get_source(device);
if (source == GDK_SOURCE_TOUCHSCREEN ||
source == GDK_SOURCE_TOUCHPAD) {
wheelEvent.scrollType = WidgetWheelEvent::SCROLL_ASYNCHRONOUSELY;
}
break;
}
#endif
case GDK_SCROLL_UP:
wheelEvent.deltaY = wheelEvent.lineOrPageDeltaY = -3;
break;

View File

@ -363,6 +363,11 @@ private:
int32_t mTransparencyBitmapWidth;
int32_t mTransparencyBitmapHeight;
#if GTK_CHECK_VERSION(3,4,0)
// This field omits duplicate scroll events caused by GNOME bug 726878.
guint32 mLastScrollEventTime;
#endif
#ifdef MOZ_HAVE_SHMIMAGE
// If we're using xshm rendering, mThebesSurface wraps mShmImage
nsRefPtr<nsShmImage> mShmImage;