Allow activating decoration buttons with touch

Task-number: QTBUG-41142
Change-Id: Ifad600d375d3b5ba197c384ece54a93db9aa0d2d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
This commit is contained in:
Laszlo Agocs 2014-09-06 21:44:18 +02:00
parent c1ed159653
commit 0fdbe40ad4
2 changed files with 19 additions and 6 deletions

View File

@ -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

View File

@ -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;
}