diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-12-08 15:52:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-12-08 16:11:10 +0000 |
commit | c5c1f8f710760d40ca1004c5fdd69f8fa2c87496 (patch) | |
tree | 4516b9371712d00862e68080eaea679c81fd1cb7 | |
parent | d48b2477aa6c768761ed9b369196b0bcd9a5bc21 (diff) |
Resolves: rhbz#1289398 unable to use scroll wheel under wayland
because we only get smooth scroll events, so implement that as
best we can.
Change-Id: I7701949cf7c9ffdc9d062f75b23db7c6add3c6a9
-rw-r--r-- | vcl/inc/unx/gtk/gtkframe.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkframe.cxx | 70 |
2 files changed, 52 insertions, 19 deletions
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 1ea2704e1041..4b09426b35f9 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -199,6 +199,7 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider Rectangle m_aRestorePosSize; #if GTK_CHECK_VERSION(3,0,0) + guint32 m_nLastScrollEventTime; long m_nWidthRequest; long m_nHeightRequest; cairo_region_t* m_pRegion; diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 554ba57908f3..92f995867b03 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -1012,6 +1012,7 @@ void GtkSalFrame::InitCommon() m_bSpanMonitorsWhenFullscreen = false; m_nState = GDK_WINDOW_STATE_WITHDRAWN; m_nVisibility = GDK_VISIBILITY_FULLY_OBSCURED; + m_nLastScrollEventTime = GDK_CURRENT_TIME; m_bSendModChangeOnRelease = false; m_pIMHandler = nullptr; m_hBackgroundPixmap = None; @@ -2438,29 +2439,60 @@ gboolean GtkSalFrame::signalScroll( GtkWidget*, GdkEvent* pEvent, gpointer frame GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); GdkEventScroll* pSEvent = reinterpret_cast<GdkEventScroll*>(pEvent); - //TODO: do something less feeble here - if (pSEvent->direction == GDK_SCROLL_SMOOTH) - return true; - - static sal_uLong nLines = 0; - if( ! nLines ) + // gnome#726878 check for duplicate legacy scroll event + if (pSEvent->direction != GDK_SCROLL_SMOOTH && + pThis->m_nLastScrollEventTime == pSEvent->time) { - char* pEnv = getenv( "SAL_WHEELLINES" ); - nLines = pEnv ? atoi( pEnv ) : 3; - if( nLines > 10 ) - nLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; + return true; } - bool bNeg = (pSEvent->direction == GDK_SCROLL_DOWN || pSEvent->direction == GDK_SCROLL_RIGHT ); SalWheelMouseEvent aEvent; - aEvent.mnTime = pSEvent->time; - aEvent.mnX = (sal_uLong)pSEvent->x; - aEvent.mnY = (sal_uLong)pSEvent->y; - aEvent.mnDelta = bNeg ? -120 : 120; - aEvent.mnNotchDelta = bNeg ? -1 : 1; - aEvent.mnScrollLines = nLines; - aEvent.mnCode = GetMouseModCode( pSEvent->state ); - aEvent.mbHorz = (pSEvent->direction == GDK_SCROLL_LEFT || pSEvent->direction == GDK_SCROLL_RIGHT); + + aEvent.mnTime = pSEvent->time; + fprintf(stderr, "time is %ld\n", aEvent.mnTime); + aEvent.mnX = (sal_uLong)pSEvent->x; + aEvent.mnY = (sal_uLong)pSEvent->y; + aEvent.mnCode = GetMouseModCode( pSEvent->state ); + aEvent.mnScrollLines = 3; + + fprintf(stderr, "scroll\n"); + + switch (pSEvent->direction) + { + case GDK_SCROLL_SMOOTH: + { + double delta_x, delta_y; + gdk_event_get_scroll_deltas(pEvent, &delta_x, &delta_y); + fprintf(stderr, "%f %f\n", delta_x, delta_y); + //pick the bigger one I guess + aEvent.mbHorz = fabs(delta_x) > fabs(delta_y); + if (aEvent.mbHorz) + aEvent.mnDelta = -delta_x; + else + aEvent.mnDelta = -delta_y; + aEvent.mnScrollLines = 1; + pThis->m_nLastScrollEventTime = pSEvent->time; + break; + } + case GDK_SCROLL_UP: + aEvent.mnDelta = 120; + aEvent.mbHorz = false; + break; + case GDK_SCROLL_DOWN: + aEvent.mnDelta = -120; + aEvent.mbHorz = false; + break; + case GDK_SCROLL_LEFT: + aEvent.mbHorz = true; + aEvent.mnDelta = -120; + break; + case GDK_SCROLL_RIGHT: + aEvent.mnDelta = -120; + aEvent.mbHorz = true; + break; + }; + + aEvent.mnNotchDelta = aEvent.mnDelta < 0 ? -1 : 1; // --- RTL --- (mirror mouse pos) if( AllSettings::GetLayoutRTL() ) |