Client decorations: Show menu on right click
[ChangeLog][QPA plugin] A window menu is now shown when the window decorations are right-clicked (if supported by the compositor). Change-Id: I13bf0c8cd91a6e5a3b44e47114dfdc2ff0e97f3a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
This commit is contained in:
parent
0552060620
commit
516c75d5d0
@ -333,6 +333,8 @@ void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevic
|
|||||||
processMouseLeft(inputDevice, local, b, mods);
|
processMouseLeft(inputDevice, local, b, mods);
|
||||||
} else if (local.x() > window()->width() + margins().left()) {
|
} else if (local.x() > window()->width() + margins().left()) {
|
||||||
processMouseRight(inputDevice, local, b, mods);
|
processMouseRight(inputDevice, local, b, mods);
|
||||||
|
} else if (isRightClicked(b)) {
|
||||||
|
showWindowMenu(inputDevice);
|
||||||
} else if (closeButtonRect().contains(local)) {
|
} else if (closeButtonRect().contains(local)) {
|
||||||
if (clickButton(b, Close))
|
if (clickButton(b, Close))
|
||||||
QWindowSystemInterface::handleCloseEvent(window());
|
QWindowSystemInterface::handleCloseEvent(window());
|
||||||
|
@ -95,6 +95,13 @@ bool QWaylandXdgSurfaceV5::move(QWaylandInputDevice *inputDevice)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandXdgSurfaceV5::showWindowMenu(QWaylandInputDevice *seat)
|
||||||
|
{
|
||||||
|
QPoint position = seat->pointerSurfacePosition().toPoint();
|
||||||
|
show_window_menu(seat->wl_seat(), seat->serial(), position.x(), position.y());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandXdgSurfaceV5::updateTransientParent(QWaylandWindow *parent)
|
void QWaylandXdgSurfaceV5::updateTransientParent(QWaylandWindow *parent)
|
||||||
{
|
{
|
||||||
if (!parent)
|
if (!parent)
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
|
|
||||||
using QtWayland::xdg_surface_v5::move;
|
using QtWayland::xdg_surface_v5::move;
|
||||||
bool move(QWaylandInputDevice *inputDevice) override;
|
bool move(QWaylandInputDevice *inputDevice) override;
|
||||||
|
bool showWindowMenu(QWaylandInputDevice *seat) override;
|
||||||
|
|
||||||
void setTitle(const QString &title) override;
|
void setTitle(const QString &title) override;
|
||||||
void setAppId(const QString &appId) override;
|
void setAppId(const QString &appId) override;
|
||||||
|
@ -251,6 +251,16 @@ bool QWaylandXdgSurfaceV6::move(QWaylandInputDevice *inputDevice)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandXdgSurfaceV6::showWindowMenu(QWaylandInputDevice *seat)
|
||||||
|
{
|
||||||
|
if (m_toplevel && m_toplevel->isInitialized()) {
|
||||||
|
QPoint position = seat->pointerSurfacePosition().toPoint();
|
||||||
|
m_toplevel->show_window_menu(seat->wl_seat(), seat->serial(), position.x(), position.y());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandXdgSurfaceV6::setTitle(const QString &title)
|
void QWaylandXdgSurfaceV6::setTitle(const QString &title)
|
||||||
{
|
{
|
||||||
if (m_toplevel)
|
if (m_toplevel)
|
||||||
|
@ -79,6 +79,7 @@ public:
|
|||||||
|
|
||||||
void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override;
|
void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override;
|
||||||
bool move(QWaylandInputDevice *inputDevice) override;
|
bool move(QWaylandInputDevice *inputDevice) override;
|
||||||
|
bool showWindowMenu(QWaylandInputDevice *seat) override;
|
||||||
void setTitle(const QString &title) override;
|
void setTitle(const QString &title) override;
|
||||||
void setAppId(const QString &appId) override;
|
void setAppId(const QString &appId) override;
|
||||||
|
|
||||||
|
@ -279,6 +279,16 @@ bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandXdgSurface::showWindowMenu(QWaylandInputDevice *seat)
|
||||||
|
{
|
||||||
|
if (m_toplevel && m_toplevel->isInitialized()) {
|
||||||
|
QPoint position = seat->pointerSurfacePosition().toPoint();
|
||||||
|
m_toplevel->show_window_menu(seat->wl_seat(), seat->serial(), position.x(), position.y());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandXdgSurface::setTitle(const QString &title)
|
void QWaylandXdgSurface::setTitle(const QString &title)
|
||||||
{
|
{
|
||||||
if (m_toplevel)
|
if (m_toplevel)
|
||||||
|
@ -82,6 +82,7 @@ public:
|
|||||||
|
|
||||||
void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override;
|
void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override;
|
||||||
bool move(QWaylandInputDevice *inputDevice) override;
|
bool move(QWaylandInputDevice *inputDevice) override;
|
||||||
|
bool showWindowMenu(QWaylandInputDevice *seat) override;
|
||||||
void setTitle(const QString &title) override;
|
void setTitle(const QString &title) override;
|
||||||
void setAppId(const QString &appId) override;
|
void setAppId(const QString &appId) override;
|
||||||
void setWindowFlags(Qt::WindowFlags flags) override;
|
void setWindowFlags(Qt::WindowFlags flags) override;
|
||||||
|
@ -164,20 +164,29 @@ void QWaylandAbstractDecoration::startMove(QWaylandInputDevice *inputDevice, Qt:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWaylandAbstractDecoration::showWindowMenu(QWaylandInputDevice *inputDevice)
|
||||||
|
{
|
||||||
|
Q_D(QWaylandAbstractDecoration);
|
||||||
|
if (auto *s = d->m_wayland_window->shellSurface())
|
||||||
|
s->showWindowMenu(inputDevice);
|
||||||
|
}
|
||||||
|
|
||||||
bool QWaylandAbstractDecoration::isLeftClicked(Qt::MouseButtons newMouseButtonState)
|
bool QWaylandAbstractDecoration::isLeftClicked(Qt::MouseButtons newMouseButtonState)
|
||||||
{
|
{
|
||||||
Q_D(QWaylandAbstractDecoration);
|
Q_D(QWaylandAbstractDecoration);
|
||||||
if (!(d->m_mouseButtons & Qt::LeftButton) && (newMouseButtonState & Qt::LeftButton))
|
return !(d->m_mouseButtons & Qt::LeftButton) && (newMouseButtonState & Qt::LeftButton);
|
||||||
return true;
|
}
|
||||||
return false;
|
|
||||||
|
bool QWaylandAbstractDecoration::isRightClicked(Qt::MouseButtons newMouseButtonState)
|
||||||
|
{
|
||||||
|
Q_D(QWaylandAbstractDecoration);
|
||||||
|
return !(d->m_mouseButtons & Qt::RightButton) && (newMouseButtonState & Qt::RightButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaylandAbstractDecoration::isLeftReleased(Qt::MouseButtons newMouseButtonState)
|
bool QWaylandAbstractDecoration::isLeftReleased(Qt::MouseButtons newMouseButtonState)
|
||||||
{
|
{
|
||||||
Q_D(QWaylandAbstractDecoration);
|
Q_D(QWaylandAbstractDecoration);
|
||||||
if ((d->m_mouseButtons & Qt::LeftButton) && !(newMouseButtonState & Qt::LeftButton))
|
return (d->m_mouseButtons & Qt::LeftButton) && !(newMouseButtonState & Qt::LeftButton);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaylandAbstractDecoration::isDirty() const
|
bool QWaylandAbstractDecoration::isDirty() const
|
||||||
|
@ -105,8 +105,10 @@ protected:
|
|||||||
|
|
||||||
void startResize(QWaylandInputDevice *inputDevice, Qt::Edges edges, Qt::MouseButtons buttons);
|
void startResize(QWaylandInputDevice *inputDevice, Qt::Edges edges, Qt::MouseButtons buttons);
|
||||||
void startMove(QWaylandInputDevice *inputDevice, Qt::MouseButtons buttons);
|
void startMove(QWaylandInputDevice *inputDevice, Qt::MouseButtons buttons);
|
||||||
|
void showWindowMenu(QWaylandInputDevice *inputDevice);
|
||||||
|
|
||||||
bool isLeftClicked(Qt::MouseButtons newMouseButtonState);
|
bool isLeftClicked(Qt::MouseButtons newMouseButtonState);
|
||||||
|
bool isRightClicked(Qt::MouseButtons newMouseButtonState);
|
||||||
bool isLeftReleased(Qt::MouseButtons newMouseButtonState);
|
bool isLeftReleased(Qt::MouseButtons newMouseButtonState);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -331,6 +331,11 @@ QWaylandWindow *QWaylandInputDevice::touchFocus() const
|
|||||||
return mTouch ? mTouch->mFocus : nullptr;
|
return mTouch ? mTouch->mFocus : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPointF QWaylandInputDevice::pointerSurfacePosition() const
|
||||||
|
{
|
||||||
|
return mPointer ? mPointer->mSurfacePos : QPointF();
|
||||||
|
}
|
||||||
|
|
||||||
Qt::KeyboardModifiers QWaylandInputDevice::modifiers() const
|
Qt::KeyboardModifiers QWaylandInputDevice::modifiers() const
|
||||||
{
|
{
|
||||||
if (!mKeyboard)
|
if (!mKeyboard)
|
||||||
|
@ -129,6 +129,8 @@ public:
|
|||||||
QWaylandWindow *keyboardFocus() const;
|
QWaylandWindow *keyboardFocus() const;
|
||||||
QWaylandWindow *touchFocus() const;
|
QWaylandWindow *touchFocus() const;
|
||||||
|
|
||||||
|
QPointF pointerSurfacePosition() const;
|
||||||
|
|
||||||
Qt::KeyboardModifiers modifiers() const;
|
Qt::KeyboardModifiers modifiers() const;
|
||||||
|
|
||||||
uint32_t serial() const;
|
uint32_t serial() const;
|
||||||
|
@ -76,6 +76,7 @@ public:
|
|||||||
virtual void resize(QWaylandInputDevice * /*inputDevice*/, Qt::Edges /*edges*/) {}
|
virtual void resize(QWaylandInputDevice * /*inputDevice*/, Qt::Edges /*edges*/) {}
|
||||||
|
|
||||||
virtual bool move(QWaylandInputDevice *) { return false; }
|
virtual bool move(QWaylandInputDevice *) { return false; }
|
||||||
|
virtual bool showWindowMenu(QWaylandInputDevice *seat) { Q_UNUSED(seat); return false; }
|
||||||
virtual void setTitle(const QString & /*title*/) {}
|
virtual void setTitle(const QString & /*title*/) {}
|
||||||
virtual void setAppId(const QString & /*appId*/) {}
|
virtual void setAppId(const QString & /*appId*/) {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user