mirror of
https://github.com/danog/patches.git
synced 2024-11-30 04:19:34 +01:00
206 lines
8.8 KiB
Diff
206 lines
8.8 KiB
Diff
|
diff --git a/src/client/qwaylandabstractdecoration.cpp b/src/client/qwaylandabstractdecoration.cpp
|
||
|
index 03f94f86..ffe57be6 100644
|
||
|
--- a/src/client/qwaylandabstractdecoration.cpp
|
||
|
+++ b/src/client/qwaylandabstractdecoration.cpp
|
||
|
@@ -169,20 +169,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 d1b11928..ece1a25c 100644
|
||
|
--- a/src/client/qwaylandabstractdecoration_p.h
|
||
|
+++ b/src/client/qwaylandabstractdecoration_p.h
|
||
|
@@ -107,8 +107,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 fbd98fcb..d4fb03ae 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 319930ed..002f0367 100644
|
||
|
--- a/src/client/qwaylandinputdevice_p.h
|
||
|
+++ b/src/client/qwaylandinputdevice_p.h
|
||
|
@@ -132,6 +132,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 873193ae..c7d02d16 100644
|
||
|
--- a/src/client/qwaylandshellsurface_p.h
|
||
|
+++ b/src/client/qwaylandshellsurface_p.h
|
||
|
@@ -77,6 +77,7 @@ public:
|
||
|
~QWaylandShellSurface() override {}
|
||
|
virtual bool resize(QWaylandInputDevice *, Qt::Edges) { 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 setAppId(const QString & /*appId*/) {}
|
||
|
|
||
|
diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp
|
||
|
index 83dc8604..1bf67bbc 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 5d7b62f4..b1cb38e9 100644
|
||
|
--- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
|
||
|
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
|
||
|
@@ -96,6 +96,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 c54da2dc..ef4c7bc0 100644
|
||
|
--- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
|
||
|
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
|
||
|
@@ -86,6 +86,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 ba3b5671..9db6d435 100644
|
||
|
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
|
||
|
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
|
||
|
@@ -259,6 +259,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 a93292ae..3e473e95 100644
|
||
|
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
|
||
|
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
|
||
|
@@ -81,6 +81,7 @@ public:
|
||
|
|
||
|
bool 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 5884f772..c446430d 100644
|
||
|
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
|
||
|
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
|
||
|
@@ -287,6 +287,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 23c3b135..aec70cd1 100644
|
||
|
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
|
||
|
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
|
||
|
@@ -84,6 +84,7 @@ public:
|
||
|
|
||
|
bool 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;
|