summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-09-06 21:44:18 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-09-06 22:27:05 +0200
commit3f32b38aed1506723b6c634f6e9f079192c13089 (patch)
tree54f6b657d183a23199bc07ce35d2e7ff6c930655
parent6d43b06d2b8f101f72d798d10e692fa134963849 (diff)
Allow activating decoration buttons with touchv5.4.0-alpha1
Task-number: QTBUG-41142 Change-Id: Ifad600d375d3b5ba197c384ece54a93db9aa0d2d Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
-rw-r--r--src/client/qwaylanddecoration.cpp19
-rw-r--r--src/client/qwaylandinputdevice.cpp6
2 files changed, 19 insertions, 6 deletions
diff --git a/src/client/qwaylanddecoration.cpp b/src/client/qwaylanddecoration.cpp
index c9ab23c0..ed497872 100644
--- a/src/client/qwaylanddecoration.cpp
+++ b/src/client/qwaylanddecoration.cpp
@@ -340,12 +340,21 @@ bool QWaylandDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPo
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;
+ bool handled = state == Qt::TouchPointPressed;
+ if (handled) {
+ if (closeButtonRect().contains(local))
+ QWindowSystemInterface::handleCloseEvent(m_window);
+ else if (maximizeButtonRect().contains(local))
+ m_window->setWindowState(m_wayland_window->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
+ else if (minimizeButtonRect().contains(local))
+ m_window->setWindowState(Qt::WindowMinimized);
+ else if (local.y() <= m_margins.top())
+ m_wayland_window->shellSurface()->move(inputDevice);
+ else
+ handled = false;
}
- return false;
+
+ return handled;
}
bool QWaylandDecoration::inMouseButtonPressedState() const
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index c0406768..9e3fbabb 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -973,7 +973,11 @@ void QWaylandInputDevice::Touch::touch_frame()
if (mFocus) {
const QWindowSystemInterface::TouchPoint &tp = mTouchPoints.last();
- QPointF localPos(window->mapFromGlobal(tp.area.center().toPoint()));
+ // When the touch event is received, the global pos is calculated with the margins
+ // in mind. Now we need to adjust again to get the correct local pos back.
+ QMargins margins = window->frameMargins();
+ QPoint p = tp.area.center().toPoint();
+ QPointF localPos(window->mapFromGlobal(QPoint(p.x() + margins.left(), p.y() + margins.top())));
if (mFocus->touchDragDecoration(mParent, localPos, tp.area.center(), tp.state, mParent->modifiers()))
return;
}