x11/panelwindow: fix multi monitor

Previously attached panels to the virtual desktop geometry instead of
the screen geometry.
This commit is contained in:
outfoxxed 2024-08-15 18:46:06 -07:00
parent 22c397bbb0
commit 815867c178
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 36 additions and 17 deletions

View file

@ -140,6 +140,8 @@ void ProxyWindowBase::completeWindow() {
if (this->mScreen != nullptr && this->window->screen() != this->mScreen) {
if (this->window->isVisible()) this->window->setVisible(false);
this->window->setScreen(this->mScreen);
} else if (this->mScreen == nullptr) {
this->mScreen = this->window->screen();
}
this->setWidth(this->mWidth);
@ -259,7 +261,6 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
}
if (this->window == nullptr) {
this->mScreen = qscreen;
emit this->screenChanged();
} else {
auto reshow = this->isVisibleDirect();
@ -267,6 +268,9 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
if (this->window != nullptr) this->window->setScreen(qscreen);
if (reshow) this->setVisibleDirect(true);
}
if (qscreen) this->mScreen = qscreen;
else this->mScreen = this->window->screen();
}
void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }

View file

@ -88,10 +88,13 @@ void XPanelWindow::connectWindow() {
this->window->installEventFilter(&this->eventFilter);
this->connectScreen();
// clang-format off
QObject::connect(this->window, &QQuickWindow::screenChanged, this, &XPanelWindow::connectScreen);
QObject::connect(this->window, &QQuickWindow::visibleChanged, this, &XPanelWindow::updatePanelStack);
// clang-format on
QObject::connect(
this->window,
&QQuickWindow::visibleChanged,
this,
&XPanelWindow::updatePanelStack
);
// qt overwrites _NET_WM_STATE, so we have to use the qt api
// QXcbWindow::WindowType::Dock in qplatformwindow_p.h
@ -129,6 +132,11 @@ void XPanelWindow::setHeight(qint32 height) {
}
}
void XPanelWindow::setScreen(QuickshellScreenInfo* screen) {
this->ProxyWindowBase::setScreen(screen);
this->connectScreen();
}
Anchors XPanelWindow::anchors() const { return this->mAnchors; }
void XPanelWindow::setAnchors(Anchors anchors) {
@ -210,7 +218,7 @@ void XPanelWindow::connectScreen() {
QObject::disconnect(this->mTrackedScreen, nullptr, this, nullptr);
}
this->mTrackedScreen = this->window->screen();
this->mTrackedScreen = this->mScreen;
if (this->mTrackedScreen != nullptr) {
QObject::connect(
@ -220,12 +228,15 @@ void XPanelWindow::connectScreen() {
&XPanelWindow::updateDimensions
);
}
this->updateDimensions();
}
void XPanelWindow::updateDimensions() {
if (this->window == nullptr || this->window->handle() == nullptr) return;
if (this->window == nullptr || this->window->handle() == nullptr || this->mScreen == nullptr)
return;
auto screenGeometry = this->window->screen()->virtualGeometry();
auto screenGeometry = this->mScreen->geometry();
if (this->mExclusionMode != ExclusionMode::Ignore) {
for (auto* panel: XPanelStack::instance()->panels(this)) {
@ -235,6 +246,8 @@ void XPanelWindow::updateDimensions() {
// we only care about windows in the same layer
if (panel->mAboveWindows != this->mAboveWindows) continue;
if (panel->mScreen != this->mScreen) continue;
int side = -1;
quint32 exclusiveZone = 0;
panel->getExclusion(side, exclusiveZone);

View file

@ -49,6 +49,8 @@ public:
void setWidth(qint32 width) override;
void setHeight(qint32 height) override;
void setScreen(QuickshellScreenInfo* screen) override;
[[nodiscard]] Anchors anchors() const;
void setAnchors(Anchors anchors);
@ -77,11 +79,11 @@ signals:
private slots:
void xInit();
void connectScreen();
void updateDimensions();
void updatePanelStack();
private:
void connectScreen();
void getExclusion(int& side, quint32& exclusiveZone);
void updateStrut();
void updateAboveWindows();