client: Allow resizing with touch input on client-side decorations
The touch input for client-side decorations had its own handling which only processed button clicks and moves. This meant that it was impossible to resize windows using touch events. This generalizes the mouse input code path and uses it for touch as well. We need to take care not to update any mouse state in the case of touch, since we only care about touch press events, so we pass in a PointerType and disable parts of the code path when the input is from a touch device. [ChangeLog][QtWaylandClient] Enable resizing windows using client-side decorations with touch input as well as mouse input. Task-number: QTBUG-108690 Change-Id: I761ebb0c7c4844c52f793caa74e8606d1593757f Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
2b49cf04a6
commit
389f01d835
@ -42,10 +42,15 @@ protected:
|
|||||||
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global,Qt::MouseButtons b,Qt::KeyboardModifiers mods) override;
|
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global,Qt::MouseButtons b,Qt::KeyboardModifiers mods) override;
|
||||||
bool handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) override;
|
bool handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) override;
|
||||||
private:
|
private:
|
||||||
void processMouseTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
enum class PointerType {
|
||||||
void processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
Mouse,
|
||||||
void processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
Touch
|
||||||
void processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
|
};
|
||||||
|
|
||||||
|
void processPointerTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods, PointerType type);
|
||||||
|
void processPointerBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods, PointerType type);
|
||||||
|
void processPointerLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods, PointerType type);
|
||||||
|
void processPointerRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods, PointerType type);
|
||||||
bool clickButton(Qt::MouseButtons b, Button btn);
|
bool clickButton(Qt::MouseButtons b, Button btn);
|
||||||
|
|
||||||
QRectF closeButtonRect() const;
|
QRectF closeButtonRect() const;
|
||||||
@ -235,13 +240,13 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c
|
|||||||
// Figure out what area mouse is in
|
// Figure out what area mouse is in
|
||||||
QRect wg = waylandWindow()->windowContentGeometry();
|
QRect wg = waylandWindow()->windowContentGeometry();
|
||||||
if (local.y() <= wg.top() + margins().top()) {
|
if (local.y() <= wg.top() + margins().top()) {
|
||||||
processMouseTop(inputDevice,local,b,mods);
|
processPointerTop(inputDevice, local, b, mods, PointerType::Mouse);
|
||||||
} else if (local.y() > wg.bottom() - margins().bottom()) {
|
} else if (local.y() > wg.bottom() - margins().bottom()) {
|
||||||
processMouseBottom(inputDevice,local,b,mods);
|
processPointerBottom(inputDevice, local, b, mods, PointerType::Mouse);
|
||||||
} else if (local.x() <= wg.left() + margins().left()) {
|
} else if (local.x() <= wg.left() + margins().left()) {
|
||||||
processMouseLeft(inputDevice,local,b,mods);
|
processPointerLeft(inputDevice, local, b, mods, PointerType::Mouse);
|
||||||
} else if (local.x() > wg.right() - margins().right()) {
|
} else if (local.x() > wg.right() - margins().right()) {
|
||||||
processMouseRight(inputDevice,local,b,mods);
|
processPointerRight(inputDevice, local, b, mods, PointerType::Mouse);
|
||||||
} else {
|
} else {
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->restoreMouseCursor(inputDevice);
|
waylandWindow()->restoreMouseCursor(inputDevice);
|
||||||
@ -256,113 +261,151 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c
|
|||||||
|
|
||||||
bool QWaylandBradientDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods)
|
bool QWaylandBradientDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods)
|
||||||
{
|
{
|
||||||
Q_UNUSED(inputDevice);
|
|
||||||
Q_UNUSED(global);
|
Q_UNUSED(global);
|
||||||
Q_UNUSED(mods);
|
QRect wg = waylandWindow()->windowContentGeometry();
|
||||||
|
|
||||||
bool handled = state == QEventPoint::Pressed;
|
bool handled = state == QEventPoint::Pressed;
|
||||||
if (handled) {
|
if (handled) {
|
||||||
if (closeButtonRect().contains(local))
|
if (local.y() <= wg.top() + margins().top()) {
|
||||||
QWindowSystemInterface::handleCloseEvent(window());
|
processPointerTop(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch);
|
||||||
else if (maximizeButtonRect().contains(local))
|
} else if (local.y() > wg.bottom() - margins().bottom()) {
|
||||||
window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
|
processPointerBottom(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch);
|
||||||
else if (minimizeButtonRect().contains(local))
|
} else if (local.x() <= wg.left() + margins().left()) {
|
||||||
window()->setWindowState(Qt::WindowMinimized);
|
processPointerLeft(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch);
|
||||||
else if (local.y() <= margins().top())
|
} else if (local.x() > wg.right() - margins().right()) {
|
||||||
waylandWindow()->shellSurface()->move(inputDevice);
|
processPointerRight(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch);
|
||||||
else
|
} else {
|
||||||
handled = false;
|
handled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
|
void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDevice,
|
||||||
|
const QPointF &local,
|
||||||
|
Qt::MouseButtons b,
|
||||||
|
Qt::KeyboardModifiers mods,
|
||||||
|
PointerType type)
|
||||||
{
|
{
|
||||||
|
#if !QT_CONFIG(cursor)
|
||||||
|
Q_UNUSED(type);
|
||||||
|
#endif
|
||||||
|
|
||||||
QRect wg = waylandWindow()->windowContentGeometry();
|
QRect wg = waylandWindow()->windowContentGeometry();
|
||||||
Q_UNUSED(mods);
|
Q_UNUSED(mods);
|
||||||
if (local.y() <= wg.top() + margins().bottom()) {
|
if (local.y() <= wg.top() + margins().bottom()) {
|
||||||
if (local.x() <= margins().left()) {
|
if (local.x() <= margins().left()) {
|
||||||
//top left bit
|
//top left bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::TopEdge | Qt::LeftEdge, b);
|
startResize(inputDevice, Qt::TopEdge | Qt::LeftEdge, b);
|
||||||
} else if (local.x() > wg.right() - margins().right()) {
|
} else if (local.x() > wg.right() - margins().right()) {
|
||||||
//top right bit
|
//top right bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::TopEdge | Qt::RightEdge, b);
|
startResize(inputDevice, Qt::TopEdge | Qt::RightEdge, b);
|
||||||
} else {
|
} else {
|
||||||
//top resize bit
|
//top resize bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::TopEdge, b);
|
startResize(inputDevice, Qt::TopEdge, b);
|
||||||
}
|
}
|
||||||
} else if (local.x() <= wg.left() + margins().left()) {
|
} else if (local.x() <= wg.left() + margins().left()) {
|
||||||
processMouseLeft(inputDevice, local, b, mods);
|
processPointerLeft(inputDevice, local, b, mods, type);
|
||||||
} else if (local.x() > wg.right() - margins().right()) {
|
} else if (local.x() > wg.right() - margins().right()) {
|
||||||
processMouseRight(inputDevice, local, b, mods);
|
processPointerRight(inputDevice, local, b, mods, type);
|
||||||
} else if (isRightClicked(b)) {
|
} else if (isRightClicked(b)) {
|
||||||
showWindowMenu(inputDevice);
|
showWindowMenu(inputDevice);
|
||||||
} else if (closeButtonRect().contains(local)) {
|
} else if (closeButtonRect().contains(local)) {
|
||||||
if (clickButton(b, Close))
|
if (type == PointerType::Touch || clickButton(b, Close))
|
||||||
QWindowSystemInterface::handleCloseEvent(window());
|
QWindowSystemInterface::handleCloseEvent(window());
|
||||||
} else if (maximizeButtonRect().contains(local)) {
|
} else if (maximizeButtonRect().contains(local)) {
|
||||||
if (clickButton(b, Maximize))
|
if (type == PointerType::Touch || clickButton(b, Maximize))
|
||||||
window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
|
window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
|
||||||
} else if (minimizeButtonRect().contains(local)) {
|
} else if (minimizeButtonRect().contains(local)) {
|
||||||
if (clickButton(b, Minimize))
|
if (type == PointerType::Touch || clickButton(b, Minimize))
|
||||||
window()->setWindowState(Qt::WindowMinimized);
|
window()->setWindowState(Qt::WindowMinimized);
|
||||||
} else {
|
} else {
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->restoreMouseCursor(inputDevice);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->restoreMouseCursor(inputDevice);
|
||||||
#endif
|
#endif
|
||||||
startMove(inputDevice,b);
|
startMove(inputDevice,b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandBradientDecoration::processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
|
void QWaylandBradientDecoration::processPointerBottom(QWaylandInputDevice *inputDevice,
|
||||||
|
const QPointF &local,
|
||||||
|
Qt::MouseButtons b,
|
||||||
|
Qt::KeyboardModifiers mods,
|
||||||
|
PointerType type)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mods);
|
Q_UNUSED(mods);
|
||||||
|
#if !QT_CONFIG(cursor)
|
||||||
|
Q_UNUSED(type);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (local.x() <= margins().left()) {
|
if (local.x() <= margins().left()) {
|
||||||
//bottom left bit
|
//bottom left bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::BottomEdge | Qt::LeftEdge, b);
|
startResize(inputDevice, Qt::BottomEdge | Qt::LeftEdge, b);
|
||||||
} else if (local.x() > window()->width() + margins().left()) {
|
} else if (local.x() > window()->width() + margins().left()) {
|
||||||
//bottom right bit
|
//bottom right bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::BottomEdge | Qt::RightEdge, b);
|
startResize(inputDevice, Qt::BottomEdge | Qt::RightEdge, b);
|
||||||
} else {
|
} else {
|
||||||
//bottom bit
|
//bottom bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::BottomEdge, b);
|
startResize(inputDevice, Qt::BottomEdge, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandBradientDecoration::processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
|
void QWaylandBradientDecoration::processPointerLeft(QWaylandInputDevice *inputDevice,
|
||||||
|
const QPointF &local,
|
||||||
|
Qt::MouseButtons b,
|
||||||
|
Qt::KeyboardModifiers mods,
|
||||||
|
PointerType type)
|
||||||
{
|
{
|
||||||
Q_UNUSED(local);
|
Q_UNUSED(local);
|
||||||
Q_UNUSED(mods);
|
Q_UNUSED(mods);
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(type);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::LeftEdge, b);
|
startResize(inputDevice, Qt::LeftEdge, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandBradientDecoration::processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
|
void QWaylandBradientDecoration::processPointerRight(QWaylandInputDevice *inputDevice,
|
||||||
|
const QPointF &local,
|
||||||
|
Qt::MouseButtons b,
|
||||||
|
Qt::KeyboardModifiers mods,
|
||||||
|
PointerType type)
|
||||||
{
|
{
|
||||||
Q_UNUSED(local);
|
Q_UNUSED(local);
|
||||||
Q_UNUSED(mods);
|
Q_UNUSED(mods);
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor);
|
if (type == PointerType::Mouse)
|
||||||
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(type);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::RightEdge, b);
|
startResize(inputDevice, Qt::RightEdge, b);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user