Skip to content

Commit 815867c

Browse files
committed
x11/panelwindow: fix multi monitor
Previously attached panels to the virtual desktop geometry instead of the screen geometry.
1 parent 22c397b commit 815867c

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

src/core/proxywindow.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ void ProxyWindowBase::completeWindow() {
140140
if (this->mScreen != nullptr && this->window->screen() != this->mScreen) {
141141
if (this->window->isVisible()) this->window->setVisible(false);
142142
this->window->setScreen(this->mScreen);
143+
} else if (this->mScreen == nullptr) {
144+
this->mScreen = this->window->screen();
143145
}
144146

145147
this->setWidth(this->mWidth);
@@ -259,14 +261,16 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
259261
}
260262

261263
if (this->window == nullptr) {
262-
this->mScreen = qscreen;
263264
emit this->screenChanged();
264265
} else {
265266
auto reshow = this->isVisibleDirect();
266267
if (reshow) this->setVisibleDirect(false);
267268
if (this->window != nullptr) this->window->setScreen(qscreen);
268269
if (reshow) this->setVisibleDirect(true);
269270
}
271+
272+
if (qscreen) this->mScreen = qscreen;
273+
else this->mScreen = this->window->screen();
270274
}
271275

272276
void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }

src/x11/panel_window.cpp

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ void XPanelWindow::connectWindow() {
8888

8989
this->window->installEventFilter(&this->eventFilter);
9090
this->connectScreen();
91-
// clang-format off
92-
QObject::connect(this->window, &QQuickWindow::screenChanged, this, &XPanelWindow::connectScreen);
93-
QObject::connect(this->window, &QQuickWindow::visibleChanged, this, &XPanelWindow::updatePanelStack);
94-
// clang-format on
91+
92+
QObject::connect(
93+
this->window,
94+
&QQuickWindow::visibleChanged,
95+
this,
96+
&XPanelWindow::updatePanelStack
97+
);
9598

9699
// qt overwrites _NET_WM_STATE, so we have to use the qt api
97100
// QXcbWindow::WindowType::Dock in qplatformwindow_p.h
@@ -129,6 +132,11 @@ void XPanelWindow::setHeight(qint32 height) {
129132
}
130133
}
131134

135+
void XPanelWindow::setScreen(QuickshellScreenInfo* screen) {
136+
this->ProxyWindowBase::setScreen(screen);
137+
this->connectScreen();
138+
}
139+
132140
Anchors XPanelWindow::anchors() const { return this->mAnchors; }
133141

134142
void XPanelWindow::setAnchors(Anchors anchors) {
@@ -194,14 +202,14 @@ void XPanelWindow::xInit() {
194202
// Stick to every workspace
195203
auto desktop = 0xffffffff;
196204
xcb_change_property(
197-
conn,
198-
XCB_PROP_MODE_REPLACE,
199-
this->window->winId(),
200-
XAtom::_NET_WM_DESKTOP.atom(),
201-
XCB_ATOM_CARDINAL,
202-
32,
203-
1,
204-
&desktop
205+
conn,
206+
XCB_PROP_MODE_REPLACE,
207+
this->window->winId(),
208+
XAtom::_NET_WM_DESKTOP.atom(),
209+
XCB_ATOM_CARDINAL,
210+
32,
211+
1,
212+
&desktop
205213
);
206214
}
207215

@@ -210,7 +218,7 @@ void XPanelWindow::connectScreen() {
210218
QObject::disconnect(this->mTrackedScreen, nullptr, this, nullptr);
211219
}
212220

213-
this->mTrackedScreen = this->window->screen();
221+
this->mTrackedScreen = this->mScreen;
214222

215223
if (this->mTrackedScreen != nullptr) {
216224
QObject::connect(
@@ -220,12 +228,15 @@ void XPanelWindow::connectScreen() {
220228
&XPanelWindow::updateDimensions
221229
);
222230
}
231+
232+
this->updateDimensions();
223233
}
224234

225235
void XPanelWindow::updateDimensions() {
226-
if (this->window == nullptr || this->window->handle() == nullptr) return;
236+
if (this->window == nullptr || this->window->handle() == nullptr || this->mScreen == nullptr)
237+
return;
227238

228-
auto screenGeometry = this->window->screen()->virtualGeometry();
239+
auto screenGeometry = this->mScreen->geometry();
229240

230241
if (this->mExclusionMode != ExclusionMode::Ignore) {
231242
for (auto* panel: XPanelStack::instance()->panels(this)) {
@@ -235,6 +246,8 @@ void XPanelWindow::updateDimensions() {
235246
// we only care about windows in the same layer
236247
if (panel->mAboveWindows != this->mAboveWindows) continue;
237248

249+
if (panel->mScreen != this->mScreen) continue;
250+
238251
int side = -1;
239252
quint32 exclusiveZone = 0;
240253
panel->getExclusion(side, exclusiveZone);

src/x11/panel_window.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class XPanelWindow: public ProxyWindowBase {
4949
void setWidth(qint32 width) override;
5050
void setHeight(qint32 height) override;
5151

52+
void setScreen(QuickshellScreenInfo* screen) override;
53+
5254
[[nodiscard]] Anchors anchors() const;
5355
void setAnchors(Anchors anchors);
5456

@@ -77,11 +79,11 @@ class XPanelWindow: public ProxyWindowBase {
7779

7880
private slots:
7981
void xInit();
80-
void connectScreen();
8182
void updateDimensions();
8283
void updatePanelStack();
8384

8485
private:
86+
void connectScreen();
8587
void getExclusion(int& side, quint32& exclusiveZone);
8688
void updateStrut();
8789
void updateAboveWindows();

0 commit comments

Comments
 (0)