From 3f32b38aed1506723b6c634f6e9f079192c13089 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 6 Sep 2014 21:44:18 +0200 Subject: Allow activating decoration buttons with touch Task-number: QTBUG-41142 Change-Id: Ifad600d375d3b5ba197c384ece54a93db9aa0d2d Reviewed-by: Giulio Camuffo --- src/client/qwaylanddecoration.cpp | 19 ++++++++++++++----- src/client/qwaylandinputdevice.cpp | 6 +++++- 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; } -- cgit v1.2.1