From 9750fd8be75319bac746e9696ec1567052d75e5b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 17 May 2023 14:57:09 +0300 Subject: [PATCH] Avoid emitting excessive changed signals If the layer shell surface properties don't change, don't emit the changed signals and issue wayland requests. --- src/interfaces/window.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/interfaces/window.cpp b/src/interfaces/window.cpp index 0219e64..1c92956 100644 --- a/src/interfaces/window.cpp +++ b/src/interfaces/window.cpp @@ -47,8 +47,10 @@ Window::~Window() void Window::setAnchors(Anchors anchors) { - d->anchors = anchors; - Q_EMIT anchorsChanged(); + if (d->anchors != anchors) { + d->anchors = anchors; + Q_EMIT anchorsChanged(); + } } Window::Anchors Window::anchors() const @@ -58,8 +60,10 @@ Window::Anchors Window::anchors() const void Window::setExclusiveZone(int32_t zone) { - d->exclusionZone = zone; - Q_EMIT exclusionZoneChanged(); + if (d->exclusionZone != zone) { + d->exclusionZone = zone; + Q_EMIT exclusionZoneChanged(); + } } int32_t Window::exclusionZone() const @@ -69,8 +73,10 @@ int32_t Window::exclusionZone() const void Window::setMargins(const QMargins &margins) { - d->margins = margins; - Q_EMIT marginsChanged(); + if (d->margins != margins) { + d->margins = margins; + Q_EMIT marginsChanged(); + } } QMargins Window::margins() const @@ -80,8 +86,10 @@ QMargins Window::margins() const void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity) { - d->keyboardInteractivity = interactivity; - Q_EMIT keyboardInteractivityChanged(); + if (d->keyboardInteractivity != interactivity) { + d->keyboardInteractivity = interactivity; + Q_EMIT keyboardInteractivityChanged(); + } } Window::KeyboardInteractivity Window::keyboardInteractivity() const @@ -91,8 +99,10 @@ Window::KeyboardInteractivity Window::keyboardInteractivity() const void Window::setLayer(Layer layer) { - d->layer = layer; - Q_EMIT layerChanged(); + if (d->layer != layer) { + d->layer = layer; + Q_EMIT layerChanged(); + } } void Window::setScope(const QString &scope)