summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2022-10-23 00:01:33 +0400
committerIlya Fedin <fedin-ilja2010@ya.ru>2022-10-23 17:19:05 +0400
commitf3a6f3c502536c0bac7f845d8f1e3179aa1a0365 (patch)
treeaecacfce845c0a646aa5e3cc91d228483a7ba1e4 /src
parent47ebd2ae5e40f5d1228edd3a35d0272dcf545585 (diff)
downloadqtwayland-f3a6f3c502536c0bac7f845d8f1e3179aa1a0365.tar.gz
Implement window alert with xdg-activation
This is implemented by not specifying serial, as mentioned in https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9#note_854977 Tested on KDE Plasma Change-Id: I4ef0975040bbce581b615b0318f90601e080235c Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/client/qwaylandshellsurface_p.h3
-rw-r--r--src/client/qwaylandwindow.cpp14
-rw-r--r--src/client/qwaylandwindow_p.h3
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp7
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h3
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp23
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h3
7 files changed, 52 insertions, 4 deletions
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index 5e269510..8f176e28 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -71,6 +71,9 @@ public:
virtual void setXdgActivationToken(const QString &token);
virtual void requestXdgActivationToken(quint32 serial);
+ virtual void setAlertState(bool enabled) { Q_UNUSED(enabled); }
+ virtual bool isAlertState() const { return false; }
+
virtual QString externWindowHandle() { return QString(); }
inline QWaylandWindow *window() { return m_window; }
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 4fd012de..c8d5121f 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -502,6 +502,20 @@ void QWaylandWindow::setMask(const QRegion &mask)
mSurface->commit();
}
+void QWaylandWindow::setAlertState(bool enabled)
+{
+ if (mShellSurface)
+ mShellSurface->setAlertState(enabled);
+}
+
+bool QWaylandWindow::isAlertState() const
+{
+ if (mShellSurface)
+ return mShellSurface->isAlertState();
+
+ return false;
+}
+
void QWaylandWindow::applyConfigureWhenPossible()
{
QMutexLocker resizeLocker(&mResizeLock);
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 298f3f2d..2e68cc2e 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -143,6 +143,9 @@ public:
void setMask(const QRegion &region) override;
+ void setAlertState(bool enabled) override;
+ bool isAlertState() const override;
+
qreal scale() const;
qreal devicePixelRatio() const override;
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp
index e921ca46..8efc0408 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp
@@ -23,7 +23,8 @@ QWaylandXdgActivationV1::~QWaylandXdgActivationV1()
QWaylandXdgActivationTokenV1 *
QWaylandXdgActivationV1::requestXdgActivationToken(QWaylandDisplay *display,
- struct ::wl_surface *surface, uint32_t serial,
+ struct ::wl_surface *surface,
+ std::optional<uint32_t> serial,
const QString &app_id)
{
auto wl = get_activation_token();
@@ -36,8 +37,8 @@ QWaylandXdgActivationV1::requestXdgActivationToken(QWaylandDisplay *display,
if (!app_id.isEmpty())
provider->set_app_id(app_id);
- if (display->lastInputDevice())
- provider->set_serial(serial, display->lastInputDevice()->wl_seat());
+ if (serial && display->lastInputDevice())
+ provider->set_serial(*serial, display->lastInputDevice()->wl_seat());
provider->commit();
return provider;
}
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h
index d5d18459..2f42d925 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h
@@ -47,7 +47,8 @@ public:
QWaylandXdgActivationTokenV1 *requestXdgActivationToken(QWaylandDisplay *display,
struct ::wl_surface *surface,
- uint32_t serial, const QString &app_id);
+ std::optional<uint32_t> serial,
+ const QString &app_id);
};
QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index bd5e3fe5..fad8b581 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -541,6 +541,29 @@ void QWaylandXdgSurface::setXdgActivationToken(const QString &token)
}
}
+void QWaylandXdgSurface::setAlertState(bool enabled)
+{
+ if (m_alertState == enabled)
+ return;
+
+ m_alertState = enabled;
+
+ if (!m_alertState)
+ return;
+
+ auto *activation = m_shell->activation();
+ if (!activation)
+ return;
+
+ const auto tokenProvider = activation->requestXdgActivationToken(
+ m_shell->m_display, m_window->wlSurface(), std::nullopt, m_appId);
+ connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this,
+ [this, tokenProvider](const QString &token) {
+ m_shell->activation()->activate(token, m_window->wlSurface());
+ tokenProvider->deleteLater();
+ });
+}
+
QString QWaylandXdgSurface::externWindowHandle()
{
if (!m_toplevel || !m_shell->exporter()) {
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
index d3cdb9d4..dfd61105 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -64,6 +64,8 @@ public:
bool requestActivate() override;
void setXdgActivationToken(const QString &token) override;
void requestXdgActivationToken(quint32 serial) override;
+ void setAlertState(bool enabled) override;
+ bool isAlertState() const override { return m_alertState; }
QString externWindowHandle() override;
void setSizeHints();
@@ -132,6 +134,7 @@ private:
uint m_appliedConfigureSerial = 0;
QString m_activationToken;
QString m_appId;
+ bool m_alertState = false;
friend class QWaylandXdgShell;
};