Skip to content

Commit 6cb7d89

Browse files
committed
x11/panelwindow: fix multi monitor struts
1 parent 95245cb commit 6cb7d89

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/x11/panel_window.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,28 @@ void XPanelWindow::connectScreen() {
239239
this,
240240
&XPanelWindow::updateDimensionsSlot
241241
);
242+
243+
QObject::connect(
244+
this->mTrackedScreen,
245+
&QScreen::virtualGeometryChanged,
246+
this,
247+
&XPanelWindow::onScreenVirtualGeometryChanged
248+
249+
);
242250
}
243251

244252
this->updateDimensions();
245253
}
246254

255+
// For some reason this gets sent multiple times with the same value.
256+
void XPanelWindow::onScreenVirtualGeometryChanged() {
257+
auto geometry = this->mTrackedScreen->virtualGeometry();
258+
if (geometry != this->lastScreenVirtualGeometry) {
259+
this->lastScreenVirtualGeometry = geometry;
260+
this->updateStrut(false);
261+
}
262+
}
263+
247264
void XPanelWindow::updateDimensionsSlot() { this->updateDimensions(); }
248265

249266
void XPanelWindow::updateDimensions(bool propagate) {
@@ -384,16 +401,22 @@ void XPanelWindow::updateStrut(bool propagate) {
384401
return;
385402
}
386403

387-
// Due to missing headers it isn't even possible to do this right.
388-
// We assume a single xinerama monitor with a matching size root.
404+
auto rootGeometry = this->window->screen()->virtualGeometry();
389405
auto screenGeometry = this->window->screen()->geometry();
390406
auto horizontal = side == 0 || side == 1;
391407

408+
switch (side) {
409+
case 0: exclusiveZone += screenGeometry.left(); break;
410+
case 1: exclusiveZone += rootGeometry.right() - screenGeometry.right(); break;
411+
case 2: exclusiveZone += screenGeometry.top(); break;
412+
case 3: exclusiveZone += rootGeometry.bottom() - screenGeometry.bottom(); break;
413+
default: break;
414+
}
415+
392416
auto data = std::array<quint32, 12>();
393417
data[side] = exclusiveZone;
394418

395-
auto start = horizontal ? screenGeometry.top() + this->window->y()
396-
: screenGeometry.left() + this->window->x();
419+
auto start = horizontal ? this->window->y() : this->window->x();
397420

398421
data[4 + side * 2] = start;
399422
data[5 + side * 2] = start + (horizontal ? this->window->height() : this->window->width());

src/x11/panel_window.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ private slots:
8181
void xInit();
8282
void updatePanelStack();
8383
void updateDimensionsSlot();
84+
void onScreenVirtualGeometryChanged();
8485

8586
private:
8687
void connectScreen();
@@ -97,6 +98,8 @@ private slots:
9798
Margins mMargins;
9899
qint32 mExclusiveZone = 0;
99100
ExclusionMode::Enum mExclusionMode = ExclusionMode::Auto;
101+
102+
QRect lastScreenVirtualGeometry;
100103
XPanelEventFilter eventFilter;
101104

102105
friend class XPanelStack;

0 commit comments

Comments
 (0)