summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-09-01 17:04:09 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-09-01 18:08:01 +0200
commit3538efae35dcbd4adf1361598deae0d198bbe13f (patch)
treeeced3589f84661c5e54191f998928f8d97171bdc /src
parentae54be549e6ebeef829d5c1089d5307d00d0b791 (diff)
downloadqtwayland-3538efae35dcbd4adf1361598deae0d198bbe13f.tar.gz
Wayland: can drag a window by its titlebar using the touchscreen
It was already possible to drag it via the mouse but not via touch. Task-number: QTBUG-41085 Change-Id: Ia52c7124fb2f1aa0331897bd072fcf09fb78aa1a Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/client/qwaylanddecoration.cpp13
-rw-r--r--src/client/qwaylanddecoration_p.h1
-rw-r--r--src/client/qwaylandinputdevice.cpp10
-rw-r--r--src/client/qwaylandwindow.cpp7
-rw-r--r--src/client/qwaylandwindow_p.h3
5 files changed, 32 insertions, 2 deletions
diff --git a/src/client/qwaylanddecoration.cpp b/src/client/qwaylanddecoration.cpp
index b288debe..c9ab23c0 100644
--- a/src/client/qwaylanddecoration.cpp
+++ b/src/client/qwaylanddecoration.cpp
@@ -335,6 +335,19 @@ bool QWaylandDecoration::handleMouse(QWaylandInputDevice *inputDevice, const QPo
return true;
}
+bool QWaylandDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods)
+{
+ Q_UNUSED(inputDevice);
+ Q_UNUSED(global);
+ Q_UNUSED(mods);
+
+ if (state == Qt::TouchPointPressed && local.y() <= m_margins.top()) {
+ m_wayland_window->shellSurface()->move(inputDevice);
+ return true;
+ }
+ return false;
+}
+
bool QWaylandDecoration::inMouseButtonPressedState() const
{
return m_mouseButtons & Qt::NoButton;
diff --git a/src/client/qwaylanddecoration_p.h b/src/client/qwaylanddecoration_p.h
index 14bf4a92..c240b9c9 100644
--- a/src/client/qwaylanddecoration_p.h
+++ b/src/client/qwaylanddecoration_p.h
@@ -75,6 +75,7 @@ public:
bool isDirty() const;
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global,Qt::MouseButtons b,Qt::KeyboardModifiers mods);
+ bool handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods);
bool inMouseButtonPressedState() const;
void startResize(QWaylandInputDevice *inputDevice,enum wl_shell_surface_resize resize, Qt::MouseButtons buttons);
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index 014303f7..5be76d90 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -853,8 +853,8 @@ void QWaylandInputDevice::Touch::touch_down(uint32_t serial,
wl_fixed_t x,
wl_fixed_t y)
{
- Q_UNUSED(serial);
- Q_UNUSED(time);
+ mParent->mTime = time;
+ mParent->mSerial = serial;
mFocus = QWaylandWindow::fromWlSurface(surface);
mParent->handleTouchPoint(id, wl_fixed_to_double(x), wl_fixed_to_double(y), Qt::TouchPointPressed);
}
@@ -966,6 +966,12 @@ void QWaylandInputDevice::Touch::touch_frame()
QWindow *window = mFocus ? mFocus->window() : 0;
+ if (mFocus) {
+ const QWindowSystemInterface::TouchPoint &tp = mTouchPoints.last();
+ QPointF localPos(window->mapFromGlobal(tp.area.center().toPoint()));
+ if (mFocus->touchDragDecoration(mParent, localPos, tp.area.center(), tp.state, mParent->modifiers()))
+ return;
+ }
QWindowSystemInterface::handleTouchEvent(window, mParent->mTouchDevice, mTouchPoints);
const bool allReleased = allTouchPointsReleased();
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index fb3095d4..278825e8 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -583,6 +583,13 @@ void QWaylandWindow::handleMouseLeave(QWaylandInputDevice *inputDevice)
restoreMouseCursor(inputDevice);
}
+bool QWaylandWindow::touchDragDecoration(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods)
+{
+ if (!mWindowDecoration)
+ return false;
+ return mWindowDecoration->handleTouch(inputDevice, local, global, state, mods);
+}
+
void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, ulong timestamp, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
if (mWindowDecoration->handleMouse(inputDevice,local,global,b,mods))
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 0d0833e5..db0b5945 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -156,6 +156,9 @@ public:
void handleMouseEnter(QWaylandInputDevice *inputDevice);
void handleMouseLeave(QWaylandInputDevice *inputDevice);
+ bool touchDragDecoration(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global,
+ Qt::TouchPointState state, Qt::KeyboardModifiers mods);
+
bool createDecoration();
inline bool isMaximized() const { return mState == Qt::WindowMaximized; }