summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-01-11 11:22:23 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-01-14 08:08:32 +0000
commit312c74a4aa7124b5125c2ca6165805c50e23e828 (patch)
treef145b22e72b4eb35b85e84e5a9883a78a5071035
parent8a638d510db90364cef990e770b84f372bde9f6b (diff)
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>
-rw-r--r--src/client/qwaylandabstractdecoration.cpp21
-rw-r--r--src/client/qwaylandabstractdecoration_p.h2
-rw-r--r--src/client/qwaylandinputdevice.cpp5
-rw-r--r--src/client/qwaylandinputdevice_p.h2
-rw-r--r--src/client/qwaylandshellsurface_p.h1
-rw-r--r--src/plugins/decorations/bradient/main.cpp2
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp7
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h1
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp10
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h1
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp10
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h1
12 files changed, 57 insertions, 6 deletions
diff --git a/src/client/qwaylandabstractdecoration.cpp b/src/client/qwaylandabstractdecoration.cpp
index 3196af3b0..32fa6e1b5 100644
--- a/src/client/qwaylandabstractdecoration.cpp
+++ b/src/client/qwaylandabstractdecoration.cpp
@@ -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)
{
Q_D(QWaylandAbstractDecoration);
- if (!(d->m_mouseButtons & Qt::LeftButton) && (newMouseButtonState & Qt::LeftButton))
- return true;
- return false;
+ return !(d->m_mouseButtons & Qt::LeftButton) && (newMouseButtonState & Qt::LeftButton);
+}
+
+bool QWaylandAbstractDecoration::isRightClicked(Qt::MouseButtons newMouseButtonState)
+{
+ Q_D(QWaylandAbstractDecoration);
+ return !(d->m_mouseButtons & Qt::RightButton) && (newMouseButtonState & Qt::RightButton);
}
bool QWaylandAbstractDecoration::isLeftReleased(Qt::MouseButtons newMouseButtonState)
{
Q_D(QWaylandAbstractDecoration);
- if ((d->m_mouseButtons & Qt::LeftButton) && !(newMouseButtonState & Qt::LeftButton))
- return true;
- return false;
+ return (d->m_mouseButtons & Qt::LeftButton) && !(newMouseButtonState & Qt::LeftButton);
}
bool QWaylandAbstractDecoration::isDirty() const
diff --git a/src/client/qwaylandabstractdecoration_p.h b/src/client/qwaylandabstractdecoration_p.h
index f5b1854dd..81c8e1771 100644
--- a/src/client/qwaylandabstractdecoration_p.h
+++ b/src/client/qwaylandabstractdecoration_p.h
@@ -105,8 +105,10 @@ protected:
void startResize(QWaylandInputDevice *inputDevice, Qt::Edges edges, Qt::MouseButtons buttons);
void startMove(QWaylandInputDevice *inputDevice, Qt::MouseButtons buttons);
+ void showWindowMenu(QWaylandInputDevice *inputDevice);
bool isLeftClicked(Qt::MouseButtons newMouseButtonState);
+ bool isRightClicked(Qt::MouseButtons newMouseButtonState);
bool isLeftReleased(Qt::MouseButtons newMouseButtonState);
};
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index 2dff4b6c3..31495a453 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -331,6 +331,11 @@ QWaylandWindow *QWaylandInputDevice::touchFocus() const
return mTouch ? mTouch->mFocus : nullptr;
}
+QPointF QWaylandInputDevice::pointerSurfacePosition() const
+{
+ return mPointer ? mPointer->mSurfacePos : QPointF();
+}
+
Qt::KeyboardModifiers QWaylandInputDevice::modifiers() const
{
if (!mKeyboard)
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h
index f27f329be..c2fd57bb0 100644
--- a/src/client/qwaylandinputdevice_p.h
+++ b/src/client/qwaylandinputdevice_p.h
@@ -129,6 +129,8 @@ public:
QWaylandWindow *keyboardFocus() const;
QWaylandWindow *touchFocus() const;
+ QPointF pointerSurfacePosition() const;
+
Qt::KeyboardModifiers modifiers() const;
uint32_t serial() const;
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index f683d9e01..d33a98a1e 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -76,6 +76,7 @@ public:
virtual void resize(QWaylandInputDevice * /*inputDevice*/, Qt::Edges /*edges*/) {}
virtual bool move(QWaylandInputDevice *) { return false; }
+ virtual bool showWindowMenu(QWaylandInputDevice *seat) { Q_UNUSED(seat); return false; }
virtual void setTitle(const QString & /*title*/) {}
virtual void setAppId(const QString & /*appId*/) {}
diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp
index 83dc8604b..1bf67bbc3 100644
--- a/src/plugins/decorations/bradient/main.cpp
+++ b/src/plugins/decorations/bradient/main.cpp
@@ -333,6 +333,8 @@ void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevic
processMouseLeft(inputDevice, local, b, mods);
} else if (local.x() > window()->width() + margins().left()) {
processMouseRight(inputDevice, local, b, mods);
+ } else if (isRightClicked(b)) {
+ showWindowMenu(inputDevice);
} else if (closeButtonRect().contains(local)) {
if (clickButton(b, Close))
QWindowSystemInterface::handleCloseEvent(window());
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
index b691ee747..e9f64e2e6 100644
--- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
@@ -95,6 +95,13 @@ bool QWaylandXdgSurfaceV5::move(QWaylandInputDevice *inputDevice)
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)
{
if (!parent)
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
index 231a56d84..feebee7f4 100644
--- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
@@ -84,6 +84,7 @@ public:
using QtWayland::xdg_surface_v5::move;
bool move(QWaylandInputDevice *inputDevice) override;
+ bool showWindowMenu(QWaylandInputDevice *seat) override;
void setTitle(const QString &title) override;
void setAppId(const QString &appId) override;
diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
index e12573ad0..01122769e 100644
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
@@ -251,6 +251,16 @@ bool QWaylandXdgSurfaceV6::move(QWaylandInputDevice *inputDevice)
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)
{
if (m_toplevel)
diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
index 5a2867379..e688f751a 100644
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
@@ -79,6 +79,7 @@ public:
void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override;
bool move(QWaylandInputDevice *inputDevice) override;
+ bool showWindowMenu(QWaylandInputDevice *seat) override;
void setTitle(const QString &title) override;
void setAppId(const QString &appId) override;
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index 8759cb8c9..cabba5b3b 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -279,6 +279,16 @@ bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
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)
{
if (m_toplevel)
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
index 1dc1def23..416feee2c 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -82,6 +82,7 @@ public:
void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override;
bool move(QWaylandInputDevice *inputDevice) override;
+ bool showWindowMenu(QWaylandInputDevice *seat) override;
void setTitle(const QString &title) override;
void setAppId(const QString &appId) override;
void setWindowFlags(Qt::WindowFlags flags) override;