diff --git a/panels/dock/pluginmanagerextension.cpp b/panels/dock/pluginmanagerextension.cpp index 945be4c5e..6e1ca3514 100644 --- a/panels/dock/pluginmanagerextension.cpp +++ b/panels/dock/pluginmanagerextension.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include #include #include @@ -345,12 +345,20 @@ PluginPopup::PluginPopup(PluginManager *manager, , m_popupType(popupType) , m_height(1) , m_width(1) + , m_sizeChangeTimer(new QTimer(this)) + , m_hasPendingChanged(false) + , m_pendingHeight(1) + , m_pendingWidth(1) { Q_UNUSED(x) Q_UNUSED(y) init(resource.resource()); setExtensionContainer(surface); QWaylandCompositorExtension::initialize(); + + m_sizeChangeTimer->setInterval(50); + m_sizeChangeTimer->setSingleShot(true); + connect(m_sizeChangeTimer, &QTimer::timeout, this, &PluginPopup::onProcessPendingSizeChanges); } QWaylandSurface* PluginPopup::surface() const @@ -446,14 +454,11 @@ void PluginPopup::plugin_popup_source_size(Resource *resource, int32_t width, in if (width == 0 || height == 0) return; - if (height != m_height) { - m_height = height; - Q_EMIT heightChanged(); - } - - if (width != m_width) { - m_width = width; - Q_EMIT widthChanged(); + m_pendingWidth = width; + m_pendingHeight = height; + m_hasPendingChanged = true; + if (!m_sizeChangeTimer->isActive()) { + m_sizeChangeTimer->start(); } } @@ -463,6 +468,22 @@ void PluginPopup::plugin_popup_set_cursor(Resource *resource, int32_t cursor_sha Q_EMIT cursorShapeRequested(cursor_shape); } +void PluginPopup::onProcessPendingSizeChanges() +{ + if (!m_hasPendingChanged) + return; + + if (m_pendingHeight != m_height) { + m_height = m_pendingHeight; + Q_EMIT heightChanged(); + } + if (m_pendingWidth != m_width) { + m_width = m_pendingWidth; + Q_EMIT widthChanged(); + } + m_hasPendingChanged = false; +} + PluginManager::PluginManager(QWaylandCompositor *compositor) : QWaylandCompositorExtensionTemplate(compositor) { diff --git a/panels/dock/pluginmanagerextension_p.h b/panels/dock/pluginmanagerextension_p.h index 4df253400..2db94aef9 100644 --- a/panels/dock/pluginmanagerextension_p.h +++ b/panels/dock/pluginmanagerextension_p.h @@ -268,6 +268,9 @@ class PluginPopup : public QWaylandShellSurfaceTemplate, public QtW void widthChanged(); void cursorShapeRequested(int cursorShape); +private slots: + void onProcessPendingSizeChanges(); + private: PluginManager* m_manager; QPointer m_surface; @@ -280,6 +283,10 @@ class PluginPopup : public QWaylandShellSurfaceTemplate, public QtW int32_t m_y; int m_height; int m_width; + QTimer* m_sizeChangeTimer; + bool m_hasPendingChanged; + int m_pendingHeight; + int m_pendingWidth; }; Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(PluginManager)