- wxEventType evtType;
-#ifdef __WXGTK20__
- if ( win->m_isScrolling )
- evtType = wxEVT_SCROLL_THUMBTRACK;
- // it could seem that UP/DOWN are inversed but this is what wxMSW does
- else if ( AreSameAdjustValues(diff, adjust->step_increment) )
- evtType = wxEVT_SCROLL_LINEDOWN;
- else if ( AreSameAdjustValues(diff, -adjust->step_increment) )
- evtType = wxEVT_SCROLL_LINEUP;
- else if ( AreSameAdjustValues(diff, adjust->page_increment) )
- evtType = wxEVT_SCROLL_PAGEDOWN;
- else if ( AreSameAdjustValues(diff, -adjust->page_increment) )
- evtType = wxEVT_SCROLL_PAGEUP;
- else if ( AreSameAdjustValues(adjust->value, adjust->lower) )
- evtType = wxEVT_SCROLL_TOP;
- else if ( AreSameAdjustValues(adjust->value, adjust->upper) )
- evtType = wxEVT_SCROLL_BOTTOM;
-#else
- evtType = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
-#endif
+ wxEventType eventType = wxEVT_NULL;
+ if (win->m_isScrolling)
+ {
+ eventType = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else if (win->m_scrollEventType != GTK_SCROLL_NONE)
+ {
+ // Scroll event from "move-slider" (keyboard)
+ eventType = GtkScrollTypeToWx(win->m_scrollEventType);
+ }
+ else if (win->m_mouseButtonDown)
+ {
+ // Difference from last change event
+ const double diff = adj->value - oldPos;
+ const bool isDown = diff > 0;
+
+ if (IsScrollIncrement(adj->page_increment, diff))
+ {
+ eventType = isDown ? wxEVT_SCROLL_PAGEDOWN : wxEVT_SCROLL_PAGEUP;
+ }
+ else if (wxIsSameDouble(adj->value, 0))
+ {
+ eventType = wxEVT_SCROLL_PAGEUP;
+ }
+ else if (wxIsSameDouble(adj->value, adj->upper))
+ {
+ eventType = wxEVT_SCROLL_PAGEDOWN;
+ }
+ else
+ {
+ // Assume track event
+ eventType = wxEVT_SCROLL_THUMBTRACK;
+ // Remember that we're tracking
+ win->m_isScrolling = true;
+ }
+ }
+
+ win->m_scrollEventType = GTK_SCROLL_NONE;
+
+ // If integral position has changed
+ if (wxRound(oldPos) != pos)
+ {
+ ProcessScrollEvent(win, eventType);
+ win->m_needThumbRelease = eventType == wxEVT_SCROLL_THUMBTRACK;
+ }
+}
+}