From adcef7fc30122c3ffd9fc472ccb5a6a6819cc28c Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 29 May 2025 16:15:25 -0700 Subject: [PATCH] core/popupwindow: wait for polish to reposition --- src/window/popupwindow.cpp | 17 +++++++++++++++-- src/window/popupwindow.hpp | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/window/popupwindow.cpp b/src/window/popupwindow.cpp index 7454d363..99c471c7 100644 --- a/src/window/popupwindow.cpp +++ b/src/window/popupwindow.cpp @@ -126,7 +126,20 @@ qint32 ProxyPopupWindow::relativeY() const { PopupAnchor* ProxyPopupWindow::anchor() { return &this->mAnchor; } void ProxyPopupWindow::reposition() { - if (this->window != nullptr) { - PopupPositioner::instance()->reposition(&this->mAnchor, this->window); + // not gated on pendingReposition as a polish might not be triggered in edge cases + if (this->window) { + this->pendingReposition = true; + this->schedulePolish(); + } +} + +void ProxyPopupWindow::onPolished() { + this->ProxyWindowBase::onPolished(); + if (this->pendingReposition) { + this->pendingReposition = false; + + if (this->window) { + PopupPositioner::instance()->reposition(&this->mAnchor, this->window); + } } } diff --git a/src/window/popupwindow.hpp b/src/window/popupwindow.hpp index a1e535f7..63ae97ff 100644 --- a/src/window/popupwindow.hpp +++ b/src/window/popupwindow.hpp @@ -87,6 +87,7 @@ public: void completeWindow() override; void postCompleteWindow() override; + void onPolished() override; void setScreen(QuickshellScreenInfo* screen) override; void setVisible(bool visible) override; @@ -119,4 +120,5 @@ private: PopupAnchor mAnchor {this}; bool wantsVisible = false; + bool pendingReposition = false; };