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>
This commit is contained in:
parent
2b63b8eb2a
commit
425cceca83
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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; }
|
||||
|
@ -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);
|
||||
|
@ -143,6 +143,9 @@ public:
|
||||
|
||||
void setMask(const QRegion ®ion) override;
|
||||
|
||||
void setAlertState(bool enabled) override;
|
||||
bool isAlertState() const override;
|
||||
|
||||
qreal scale() const;
|
||||
qreal devicePixelRatio() const override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user