Skip to content

Commit 59d29bb

Browse files
committed
x11/panelwindow: use Qt window default screen if none is provided
Fixes panels not updating geometry or attachments under X if a screen was not explicitly provided by the user.
1 parent 9604302 commit 59d29bb

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/x11/panel_window.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

170170
void XPanelWindow::setScreen(QuickshellScreenInfo* screen) {
171171
this->ProxyWindowBase::setScreen(screen);
172-
this->connectScreen();
172+
this->updateScreen();
173173
}
174174

175175
void 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() {
231235
void XPanelWindow::updateDimensionsSlot() { this->updateDimensions(); }
232236

233237
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)
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();

src/x11/panel_window.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private slots:
9292
void onScreenVirtualGeometryChanged();
9393

9494
private:
95-
void connectScreen();
95+
void updateScreen();
9696
void updateStrut(bool propagate = true);
9797
void updateStrutCb() { this->updateStrut(); }
9898
void updateAboveWindows();

0 commit comments

Comments
 (0)