@@ -126,7 +126,7 @@ void XPanelWindow::connectWindow() {
126126 this ->ProxyWindowBase ::connectWindow ();
127127
128128 this ->window ->installEventFilter (&this ->eventFilter );
129- this ->connectScreen ();
129+ this ->updateScreen ();
130130
131131 QObject::connect (
132132 this ->window ,
@@ -169,7 +169,7 @@ void XPanelWindow::trySetHeight(qint32 implicitHeight) {
169169
170170void XPanelWindow::setScreen (QuickshellScreenInfo* screen) {
171171 this ->ProxyWindowBase ::setScreen (screen);
172- this ->connectScreen ();
172+ this ->updateScreen ();
173173}
174174
175175void XPanelWindow::xInit () {
@@ -192,12 +192,17 @@ void XPanelWindow::xInit() {
192192 );
193193}
194194
195- void XPanelWindow::connectScreen () {
195+ void XPanelWindow::updateScreen () {
196+ auto * newScreen =
197+ this ->mScreen ? this ->mScreen : (this ->window ? this ->window ->screen () : nullptr );
198+
199+ if (newScreen == this ->mTrackedScreen ) return ;
200+
196201 if (this ->mTrackedScreen != nullptr ) {
197202 QObject::disconnect (this ->mTrackedScreen , nullptr , this , nullptr );
198203 }
199204
200- this ->mTrackedScreen = this -> mScreen ;
205+ this ->mTrackedScreen = newScreen ;
201206
202207 if (this ->mTrackedScreen != nullptr ) {
203208 QObject::connect (
@@ -212,7 +217,6 @@ void XPanelWindow::connectScreen() {
212217 &QScreen::virtualGeometryChanged,
213218 this ,
214219 &XPanelWindow::onScreenVirtualGeometryChanged
215-
216220 );
217221 }
218222
@@ -231,10 +235,11 @@ void XPanelWindow::onScreenVirtualGeometryChanged() {
231235void XPanelWindow::updateDimensionsSlot () { this ->updateDimensions (); }
232236
233237void XPanelWindow::updateDimensions (bool propagate) {
234- if (this ->window == nullptr || this ->window ->handle () == nullptr || this ->mScreen == nullptr )
238+ if (this ->window == nullptr || this ->window ->handle () == nullptr
239+ || this ->mTrackedScreen == nullptr )
235240 return ;
236241
237- auto screenGeometry = this ->mScreen ->geometry ();
242+ auto screenGeometry = this ->mTrackedScreen ->geometry ();
238243
239244 if (this ->bExclusionMode != ExclusionMode::Ignore) {
240245 for (auto * panel: XPanelStack::instance ()->panels (this )) {
@@ -244,7 +249,7 @@ void XPanelWindow::updateDimensions(bool propagate) {
244249 // we only care about windows in the same layer
245250 if (panel->bAboveWindows != this ->bAboveWindows ) continue ;
246251
247- if (panel->mScreen != this ->mScreen ) continue ;
252+ if (panel->mTrackedScreen != this ->mTrackedScreen ) continue ;
248253
249254 auto edge = this ->bcExclusionEdge .value ();
250255 auto exclusiveZone = this ->bcExclusiveZone .value ();
0 commit comments