@@ -126,7 +126,7 @@ void XPanelWindow::connectWindow() {
126
126
this ->ProxyWindowBase ::connectWindow ();
127
127
128
128
this ->window ->installEventFilter (&this ->eventFilter );
129
- this ->connectScreen ();
129
+ this ->updateScreen ();
130
130
131
131
QObject::connect (
132
132
this ->window ,
@@ -169,7 +169,7 @@ void XPanelWindow::trySetHeight(qint32 implicitHeight) {
169
169
170
170
void XPanelWindow::setScreen (QuickshellScreenInfo* screen) {
171
171
this ->ProxyWindowBase ::setScreen (screen);
172
- this ->connectScreen ();
172
+ this ->updateScreen ();
173
173
}
174
174
175
175
void XPanelWindow::xInit () {
@@ -192,12 +192,17 @@ void XPanelWindow::xInit() {
192
192
);
193
193
}
194
194
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
+
196
201
if (this ->mTrackedScreen != nullptr ) {
197
202
QObject::disconnect (this ->mTrackedScreen , nullptr , this , nullptr );
198
203
}
199
204
200
- this ->mTrackedScreen = this -> mScreen ;
205
+ this ->mTrackedScreen = newScreen ;
201
206
202
207
if (this ->mTrackedScreen != nullptr ) {
203
208
QObject::connect (
@@ -212,7 +217,6 @@ void XPanelWindow::connectScreen() {
212
217
&QScreen::virtualGeometryChanged,
213
218
this ,
214
219
&XPanelWindow::onScreenVirtualGeometryChanged
215
-
216
220
);
217
221
}
218
222
@@ -231,10 +235,11 @@ void XPanelWindow::onScreenVirtualGeometryChanged() {
231
235
void XPanelWindow::updateDimensionsSlot () { this ->updateDimensions (); }
232
236
233
237
void 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 )
235
240
return ;
236
241
237
- auto screenGeometry = this ->mScreen ->geometry ();
242
+ auto screenGeometry = this ->mTrackedScreen ->geometry ();
238
243
239
244
if (this ->bExclusionMode != ExclusionMode::Ignore) {
240
245
for (auto * panel: XPanelStack::instance ()->panels (this )) {
@@ -244,7 +249,7 @@ void XPanelWindow::updateDimensions(bool propagate) {
244
249
// we only care about windows in the same layer
245
250
if (panel->bAboveWindows != this ->bAboveWindows ) continue ;
246
251
247
- if (panel->mScreen != this ->mScreen ) continue ;
252
+ if (panel->mTrackedScreen != this ->mTrackedScreen ) continue ;
248
253
249
254
auto edge = this ->bcExclusionEdge .value ();
250
255
auto exclusiveZone = this ->bcExclusiveZone .value ();
0 commit comments