summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qapplication_lite.cpp40
-rw-r--r--src/gui/kernel/qapplication_p.h1
-rw-r--r--src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp17
3 files changed, 58 insertions, 0 deletions
diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp
index 0615073..f551228 100644
--- a/src/gui/kernel/qapplication_lite.cpp
+++ b/src/gui/kernel/qapplication_lite.cpp
@@ -575,6 +575,45 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev)
}
+//### there's a lot of duplicated logic here -- refactoring required!
+
+void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev)
+{
+// QPoint localPoint = ev.pos();
+ QPoint globalPoint = ev.globalPos();
+// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
+ QWidget *mouseWidget = tlw;
+
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+
+ QWidget *mouseWindow = tlw;
+
+ // find the tlw if we didn't get it from the plugin
+ if (!mouseWindow) {
+ mouseWindow = QApplication::topLevelAt(globalPoint);
+ }
+
+ if (!mouseWindow)
+ return;
+
+ if (app_do_modal && !qt_try_modal(mouseWindow, &ev) ) {
+ qDebug() << "modal blocked wheel event" << mouseWindow;
+ return;
+ }
+ QPoint p = mouseWindow->mapFromGlobal(globalPoint);
+ QWidget *w = mouseWindow->childAt(p);
+ if (w) {
+ mouseWidget = w;
+ p = mouseWidget->mapFromGlobal(globalPoint);
+ }
+
+ QWheelEvent e(p, globalPoint, ev.delta(), ev.buttons(), ev.modifiers(),
+ ev.orientation());
+ QApplication::sendSpontaneousEvent(mouseWidget, &e);
+}
+
+
// Remember, Qt convention is: keyboard state is state *before*
@@ -628,4 +667,5 @@ void QApplicationPrivate::handleCloseEvent(QWidget *tlw)
tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 9cd3f4c..32004ba 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -582,6 +582,7 @@ public:
static void handleKeyEvent(QWidget *tlw, QKeyEvent *e);
static void handleGeometryChange(QWidget *tlw, const QRect &newRect);
static void handleCloseEvent(QWidget *tlw);
+ static void handleWheelEvent(QWidget *tlw, QWheelEvent &e);
#endif
#if defined(Q_WS_S60)
diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
index 2ad3224..c2ad094 100644
--- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
+++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
@@ -174,6 +174,23 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev)
case Button1: button = Qt::LeftButton; break;
case Button2: button = Qt::MidButton; break;
case Button3: button = Qt::RightButton; break;
+ case Button4:
+ case Button5:
+ case 6:
+ case 7: {
+ //mouse wheel
+ if (type == QEvent::MouseButtonPress) {
+ //logic borrowed from qapplication_x11.cpp
+ int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1);
+ bool hor = (((e->button == Button4 || e->button == Button5)
+ && (modifiers & Qt::AltModifier))
+ || (e->button == 6 || e->button == 7));
+ QWheelEvent we(QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta,
+ buttons, modifiers, hor ? Qt::Horizontal : Qt::Vertical);
+ QApplicationPrivate::handleWheelEvent(window(),we);
+ }
+ return;
+ }
default: break;
}
}