forked from quickshell/quickshell
		
	x11/panelwindow: fix multi monitor
Previously attached panels to the virtual desktop geometry instead of the screen geometry.
This commit is contained in:
		
							parent
							
								
									22c397bbb0
								
							
						
					
					
						commit
						815867c178
					
				
					 3 changed files with 36 additions and 17 deletions
				
			
		| 
						 | 
					@ -140,6 +140,8 @@ void ProxyWindowBase::completeWindow() {
 | 
				
			||||||
	if (this->mScreen != nullptr && this->window->screen() != this->mScreen) {
 | 
						if (this->mScreen != nullptr && this->window->screen() != this->mScreen) {
 | 
				
			||||||
		if (this->window->isVisible()) this->window->setVisible(false);
 | 
							if (this->window->isVisible()) this->window->setVisible(false);
 | 
				
			||||||
		this->window->setScreen(this->mScreen);
 | 
							this->window->setScreen(this->mScreen);
 | 
				
			||||||
 | 
						} else if (this->mScreen == nullptr) {
 | 
				
			||||||
 | 
							this->mScreen = this->window->screen();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->setWidth(this->mWidth);
 | 
						this->setWidth(this->mWidth);
 | 
				
			||||||
| 
						 | 
					@ -259,7 +261,6 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->window == nullptr) {
 | 
						if (this->window == nullptr) {
 | 
				
			||||||
		this->mScreen = qscreen;
 | 
					 | 
				
			||||||
		emit this->screenChanged();
 | 
							emit this->screenChanged();
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		auto reshow = this->isVisibleDirect();
 | 
							auto reshow = this->isVisibleDirect();
 | 
				
			||||||
| 
						 | 
					@ -267,6 +268,9 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
 | 
				
			||||||
		if (this->window != nullptr) this->window->setScreen(qscreen);
 | 
							if (this->window != nullptr) this->window->setScreen(qscreen);
 | 
				
			||||||
		if (reshow) this->setVisibleDirect(true);
 | 
							if (reshow) this->setVisibleDirect(true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (qscreen) this->mScreen = qscreen;
 | 
				
			||||||
 | 
						else this->mScreen = this->window->screen();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }
 | 
					void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,10 +88,13 @@ void XPanelWindow::connectWindow() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->window->installEventFilter(&this->eventFilter);
 | 
						this->window->installEventFilter(&this->eventFilter);
 | 
				
			||||||
	this->connectScreen();
 | 
						this->connectScreen();
 | 
				
			||||||
	// clang-format off
 | 
					
 | 
				
			||||||
	QObject::connect(this->window, &QQuickWindow::screenChanged, this, &XPanelWindow::connectScreen);
 | 
						QObject::connect(
 | 
				
			||||||
	QObject::connect(this->window, &QQuickWindow::visibleChanged, this, &XPanelWindow::updatePanelStack);
 | 
						    this->window,
 | 
				
			||||||
	// clang-format on
 | 
						    &QQuickWindow::visibleChanged,
 | 
				
			||||||
 | 
						    this,
 | 
				
			||||||
 | 
						    &XPanelWindow::updatePanelStack
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// qt overwrites _NET_WM_STATE, so we have to use the qt api
 | 
						// qt overwrites _NET_WM_STATE, so we have to use the qt api
 | 
				
			||||||
	// QXcbWindow::WindowType::Dock in qplatformwindow_p.h
 | 
						// 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; }
 | 
					Anchors XPanelWindow::anchors() const { return this->mAnchors; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void XPanelWindow::setAnchors(Anchors anchors) {
 | 
					void XPanelWindow::setAnchors(Anchors anchors) {
 | 
				
			||||||
| 
						 | 
					@ -194,14 +202,14 @@ void XPanelWindow::xInit() {
 | 
				
			||||||
	// Stick to every workspace
 | 
						// Stick to every workspace
 | 
				
			||||||
	auto desktop = 0xffffffff;
 | 
						auto desktop = 0xffffffff;
 | 
				
			||||||
	xcb_change_property(
 | 
						xcb_change_property(
 | 
				
			||||||
			conn,
 | 
						    conn,
 | 
				
			||||||
			XCB_PROP_MODE_REPLACE,
 | 
						    XCB_PROP_MODE_REPLACE,
 | 
				
			||||||
			this->window->winId(),
 | 
						    this->window->winId(),
 | 
				
			||||||
			XAtom::_NET_WM_DESKTOP.atom(),
 | 
						    XAtom::_NET_WM_DESKTOP.atom(),
 | 
				
			||||||
			XCB_ATOM_CARDINAL,
 | 
						    XCB_ATOM_CARDINAL,
 | 
				
			||||||
			32,
 | 
						    32,
 | 
				
			||||||
			1,
 | 
						    1,
 | 
				
			||||||
			&desktop
 | 
						    &desktop
 | 
				
			||||||
	);
 | 
						);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -210,7 +218,7 @@ void XPanelWindow::connectScreen() {
 | 
				
			||||||
		QObject::disconnect(this->mTrackedScreen, nullptr, this, nullptr);
 | 
							QObject::disconnect(this->mTrackedScreen, nullptr, this, nullptr);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->mTrackedScreen = this->window->screen();
 | 
						this->mTrackedScreen = this->mScreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->mTrackedScreen != nullptr) {
 | 
						if (this->mTrackedScreen != nullptr) {
 | 
				
			||||||
		QObject::connect(
 | 
							QObject::connect(
 | 
				
			||||||
| 
						 | 
					@ -220,12 +228,15 @@ void XPanelWindow::connectScreen() {
 | 
				
			||||||
		    &XPanelWindow::updateDimensions
 | 
							    &XPanelWindow::updateDimensions
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this->updateDimensions();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void XPanelWindow::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) {
 | 
						if (this->mExclusionMode != ExclusionMode::Ignore) {
 | 
				
			||||||
		for (auto* panel: XPanelStack::instance()->panels(this)) {
 | 
							for (auto* panel: XPanelStack::instance()->panels(this)) {
 | 
				
			||||||
| 
						 | 
					@ -235,6 +246,8 @@ void XPanelWindow::updateDimensions() {
 | 
				
			||||||
			// we only care about windows in the same layer
 | 
								// we only care about windows in the same layer
 | 
				
			||||||
			if (panel->mAboveWindows != this->mAboveWindows) continue;
 | 
								if (panel->mAboveWindows != this->mAboveWindows) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (panel->mScreen != this->mScreen) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			int side = -1;
 | 
								int side = -1;
 | 
				
			||||||
			quint32 exclusiveZone = 0;
 | 
								quint32 exclusiveZone = 0;
 | 
				
			||||||
			panel->getExclusion(side, exclusiveZone);
 | 
								panel->getExclusion(side, exclusiveZone);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,8 @@ public:
 | 
				
			||||||
	void setWidth(qint32 width) override;
 | 
						void setWidth(qint32 width) override;
 | 
				
			||||||
	void setHeight(qint32 height) override;
 | 
						void setHeight(qint32 height) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void setScreen(QuickshellScreenInfo* screen) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] Anchors anchors() const;
 | 
						[[nodiscard]] Anchors anchors() const;
 | 
				
			||||||
	void setAnchors(Anchors anchors);
 | 
						void setAnchors(Anchors anchors);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,11 +79,11 @@ signals:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
	void xInit();
 | 
						void xInit();
 | 
				
			||||||
	void connectScreen();
 | 
					 | 
				
			||||||
	void updateDimensions();
 | 
						void updateDimensions();
 | 
				
			||||||
	void updatePanelStack();
 | 
						void updatePanelStack();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
						void connectScreen();
 | 
				
			||||||
	void getExclusion(int& side, quint32& exclusiveZone);
 | 
						void getExclusion(int& side, quint32& exclusiveZone);
 | 
				
			||||||
	void updateStrut();
 | 
						void updateStrut();
 | 
				
			||||||
	void updateAboveWindows();
 | 
						void updateAboveWindows();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue