Commit 2cf832cf authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

[wayland] Get rid of some duplicated code

We duplicate ping code in a few places. This change introduces a dedicated
method for sending ping events to an xdg-toplevel. In long term, it can be
used for sending "test" ping messages at random interval.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision:
parent ec2204fb
......@@ -652,8 +652,7 @@ void XdgShellClient::closeWindow()
if (m_xdgShellSurface && isCloseable()) {
const qint32 pingSerial = static_cast<XdgShellInterface *>(m_xdgShellSurface->global())->ping(m_xdgShellSurface);
m_pingSerials.insert(pingSerial, PingReason::CloseWindow);
......@@ -989,8 +988,7 @@ void XdgShellClient::takeFocus()
if (rules()->checkAcceptFocus(wantsInput())) {
if (m_xdgShellSurface) {
const qint32 pingSerial = static_cast<XdgShellInterface *>(m_xdgShellSurface->global())->ping(m_xdgShellSurface);
m_pingSerials.insert(pingSerial, PingReason::FocusWindow);
......@@ -2043,4 +2041,13 @@ QRect XdgShellClient::adjustResizeGeometry(const QRect &rect) const
return geometry;
void XdgShellClient::ping(PingReason reason)
XdgShellInterface *shell = static_cast<XdgShellInterface *>(m_xdgShellSurface->global());
const quint32 serial = shell->ping(m_xdgShellSurface);
m_pingSerials.insert(serial, reason);
......@@ -188,6 +188,7 @@ private:
void unmap();
void markAsMapped();
QRect determineBufferGeometry() const;
void ping(PingReason reason);
static void deleteClient(XdgShellClient *c);
QRect adjustMoveGeometry(const QRect &rect) const;
......@@ -260,7 +261,7 @@ private:
QRect m_blockedRequestGeometry;
QString m_caption;
QString m_captionSuffix;
QHash<qint32, PingReason> m_pingSerials;
QHash<quint32, PingReason> m_pingSerials;
bool m_isInitialized = false;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment