From aeac5bf7cebb304eaf68bd7490294fc7021fe4c4 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 25 Jan 2011 10:35:13 +0100 Subject: Cocoa: disable scroll optimization for certain cases No reason to use the optimization when only scrolling in one direction. In those cases we are better off scrolling immidiatly when requested to minimize the shuffling of scrolls and repaints done by the application --- src/gui/kernel/qcocoaview_mac.mm | 10 ++++++---- src/gui/kernel/qt_cocoa_helpers_mac_p.h | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 1b81699..f0ae886 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -581,26 +581,28 @@ static int qCocoaViewCount = 0; #ifndef QT_NO_WHEELEVENT // ### Qt 5: Send one QWheelEvent with dx, dy and dz - QMacScrollOptimization::initNewScroll(); + if (deltaX != 0 && deltaY != 0) + QMacScrollOptimization::initDelayedScroll(); if (deltaX != 0) { QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal); qt_sendSpontaneousEvent(widgetToGetMouse, &qwe); } - if (deltaY) { + if (deltaY != 0) { QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical); qt_sendSpontaneousEvent(widgetToGetMouse, &qwe); } - if (deltaZ) { + if (deltaZ != 0) { // Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to // try to be ahead of the pack, I'm adding this extra value. QWheelEvent qwe(qlocal, qglobal, deltaZ, buttons, keyMods, (Qt::Orientation)3); qt_sendSpontaneousEvent(widgetToGetMouse, &qwe); } - QMacScrollOptimization::performDelayedScroll(); + if (deltaX != 0 && deltaY != 0) + QMacScrollOptimization::performDelayedScroll(); #endif //QT_NO_WHEELEVENT } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 9e09fd3..334d9e8 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -247,7 +247,7 @@ void qt_cocoaPostMessageAfterEventLoopExit(id target, SEL selector, int argCount #endif class QMacScrollOptimization { - // This class is made optimize for the case when the user + // This class is made to optimize for the case when the user // scrolls both horizontally and vertically at the same // time. This will result in two QWheelEvents (one for each // direction), which will typically result in two calls to @@ -261,7 +261,7 @@ class QMacScrollOptimization { static QRect _scrollRect; public: - static void initNewScroll() + static void initDelayedScroll() { _inWheelEvent = true; } -- cgit v0.12