x11/panelwindow: fix multi monitor struts

This commit is contained in:
outfoxxed 2024-09-01 18:08:53 -07:00
parent 95245cb6a5
commit 6cb7d894ab
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 30 additions and 4 deletions

View file

@ -239,11 +239,28 @@ void XPanelWindow::connectScreen() {
this, this,
&XPanelWindow::updateDimensionsSlot &XPanelWindow::updateDimensionsSlot
); );
QObject::connect(
this->mTrackedScreen,
&QScreen::virtualGeometryChanged,
this,
&XPanelWindow::onScreenVirtualGeometryChanged
);
} }
this->updateDimensions(); this->updateDimensions();
} }
// For some reason this gets sent multiple times with the same value.
void XPanelWindow::onScreenVirtualGeometryChanged() {
auto geometry = this->mTrackedScreen->virtualGeometry();
if (geometry != this->lastScreenVirtualGeometry) {
this->lastScreenVirtualGeometry = geometry;
this->updateStrut(false);
}
}
void XPanelWindow::updateDimensionsSlot() { this->updateDimensions(); } void XPanelWindow::updateDimensionsSlot() { this->updateDimensions(); }
void XPanelWindow::updateDimensions(bool propagate) { void XPanelWindow::updateDimensions(bool propagate) {
@ -384,16 +401,22 @@ void XPanelWindow::updateStrut(bool propagate) {
return; return;
} }
// Due to missing headers it isn't even possible to do this right. auto rootGeometry = this->window->screen()->virtualGeometry();
// We assume a single xinerama monitor with a matching size root.
auto screenGeometry = this->window->screen()->geometry(); auto screenGeometry = this->window->screen()->geometry();
auto horizontal = side == 0 || side == 1; auto horizontal = side == 0 || side == 1;
switch (side) {
case 0: exclusiveZone += screenGeometry.left(); break;
case 1: exclusiveZone += rootGeometry.right() - screenGeometry.right(); break;
case 2: exclusiveZone += screenGeometry.top(); break;
case 3: exclusiveZone += rootGeometry.bottom() - screenGeometry.bottom(); break;
default: break;
}
auto data = std::array<quint32, 12>(); auto data = std::array<quint32, 12>();
data[side] = exclusiveZone; data[side] = exclusiveZone;
auto start = horizontal ? screenGeometry.top() + this->window->y() auto start = horizontal ? this->window->y() : this->window->x();
: screenGeometry.left() + this->window->x();
data[4 + side * 2] = start; data[4 + side * 2] = start;
data[5 + side * 2] = start + (horizontal ? this->window->height() : this->window->width()); data[5 + side * 2] = start + (horizontal ? this->window->height() : this->window->width());

View file

@ -81,6 +81,7 @@ private slots:
void xInit(); void xInit();
void updatePanelStack(); void updatePanelStack();
void updateDimensionsSlot(); void updateDimensionsSlot();
void onScreenVirtualGeometryChanged();
private: private:
void connectScreen(); void connectScreen();
@ -97,6 +98,8 @@ private:
Margins mMargins; Margins mMargins;
qint32 mExclusiveZone = 0; qint32 mExclusiveZone = 0;
ExclusionMode::Enum mExclusionMode = ExclusionMode::Auto; ExclusionMode::Enum mExclusionMode = ExclusionMode::Auto;
QRect lastScreenVirtualGeometry;
XPanelEventFilter eventFilter; XPanelEventFilter eventFilter;
friend class XPanelStack; friend class XPanelStack;