summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsmousehandler.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-02-10 09:32:16 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-02-10 09:42:25 +0100
commitfc35f714340d5361231506dfbead132122f59460 (patch)
treefd80498d9417c87b386a011f5849f1e4e48ad3fa /src/plugins/platforms/windows/qwindowsmousehandler.cpp
parent6389160f04322449c34bd1ecfe53983e3b588943 (diff)
parent0d990b9ca117514fe83f53b39f25d6272304f2fb (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro src/gui/image/qimage_conversions.cpp src/gui/opengl/qopenglextensions_p.h src/gui/text/qtextengine.cpp src/network/ssl/qsslsocket_openssl.cpp src/plugins/platforms/eglfs/qeglfshooks_stub.cpp src/plugins/platforms/eglfs/qeglfsscreen.cpp src/plugins/platforms/eglfs/qeglfswindow.cpp src/plugins/platforms/windows/qwindowsfontdatabase.cpp src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp src/plugins/platforms/windows/qwindowsnativeinterface.cpp src/plugins/platforms/windows/qwindowsscreen.cpp src/plugins/platforms/windows/qwindowswindow.cpp src/plugins/platforms/windows/qwindowswindow.h src/plugins/platforms/xcb/qxcbdrag.h src/widgets/itemviews/qabstractitemview.cpp src/widgets/kernel/qwidget.cpp src/widgets/util/qsystemtrayicon_p.h tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp Thanks to Friedemann Kleint for resolving the qwindowsfontdatabase.cpp conflicts. Change-Id: I937232c30523d5121c195d947d92aec6f129b03e
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmousehandler.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp86
1 files changed, 83 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index acb692579b..0fa34041d6 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -422,11 +422,12 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND,
}
// from bool QApplicationPrivate::translateTouchEvent()
-bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
+bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
#ifndef Q_OS_WINCE
+ Q_UNUSED(hwnd);
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
@@ -495,8 +496,87 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
m_touchDevice,
touchPoints);
return true;
-#else
- return false;
+#else //Q_OS_WINCE
+ GESTUREINFO gi;
+ memset(&gi, 0, sizeof(GESTUREINFO));
+ gi.cbSize = sizeof(GESTUREINFO);
+
+ if (!GetGestureInfo((HGESTUREINFO)msg.lParam, &gi))
+ return false;
+
+ const QPoint position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+
+ if (gi.dwID != GID_DIRECTMANIPULATION)
+ return true;
+ static QPoint lastTouchPos;
+ const QRect screenGeometry = window->screen()->geometry();
+ QWindowSystemInterface::TouchPoint touchPoint;
+ static QWindowSystemInterface::TouchPoint touchPoint2;
+ touchPoint.id = 0;//gi.dwInstanceID;
+ touchPoint.pressure = 1.0;
+
+ if (gi.dwFlags & GF_BEGIN)
+ touchPoint.state = Qt::TouchPointPressed;
+ else if (gi.dwFlags & GF_END)
+ touchPoint.state = Qt::TouchPointReleased;
+ else if (gi.dwFlags == 0)
+ touchPoint.state = Qt::TouchPointMoved;
+ else
+ return true;
+ touchPoint2.pressure = 1.0;
+ touchPoint2.id = 1;
+ const QPoint winEventPosition = position;
+ const int deltaX = GID_DIRECTMANIPULATION_DELTA_X(gi.ullArguments);
+ const int deltaY = GID_DIRECTMANIPULATION_DELTA_Y(gi.ullArguments);
+ //Touch points are taken from the whole screen so map the position to the screen
+ const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition);
+ const QPoint globalPosition2 = QWindowsGeometryHint::mapToGlobal(hwnd, QPoint(position.x() + deltaX, position.y() + deltaY));
+
+ touchPoint.normalPosition =
+ QPointF( (qreal)globalPosition.x() / screenGeometry.width(), (qreal)globalPosition.y() / screenGeometry.height() );
+
+ touchPoint.area.moveCenter(globalPosition);
+
+ QList<QWindowSystemInterface::TouchPoint> pointList;
+ pointList.append(touchPoint);
+ if (deltaX != 0 && deltaY != 0) {
+ touchPoint2.state = m_had2ndTouchPoint ? Qt::TouchPointMoved : Qt::TouchPointPressed;
+ m_had2ndTouchPoint = true;
+ touchPoint2.normalPosition =
+ QPointF( (qreal)globalPosition2.x() / screenGeometry.width(), (qreal)globalPosition2.y() / screenGeometry.height() );
+
+ touchPoint2.area.moveCenter(globalPosition2);
+ lastTouchPos = globalPosition2;
+ pointList.append(touchPoint2);
+ } else if (m_had2ndTouchPoint) {
+ touchPoint2.normalPosition =
+ QPointF( (qreal)lastTouchPos.x() / screenGeometry.width(), (qreal)lastTouchPos.y() / screenGeometry.height() );
+
+ touchPoint2.area.moveCenter(lastTouchPos);
+ touchPoint2.state = Qt::TouchPointReleased;
+ pointList.append(touchPoint2);
+ m_had2ndTouchPoint = false;
+ }
+
+ if (!m_touchDevice) {
+ m_touchDevice = new QTouchDevice;
+ // TODO: Device used to be hardcoded to screen in previous code.
+ m_touchDevice->setType(QTouchDevice::TouchScreen);
+ m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
+ QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+ }
+
+ QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, pointList);
+ // handle window focusing in/out
+ if (window != m_windowUnderMouse) {
+ if (m_windowUnderMouse)
+ QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse);
+ if (window)
+ QWindowSystemInterface::handleEnterEvent(window);
+ m_windowUnderMouse = window;
+ }
+
+ return true;
#endif
}