forked from quickshell/quickshell
		
	core/window: fix screen assignments being completely broken
This commit is contained in:
		
							parent
							
								
									b73eff0e47
								
							
						
					
					
						commit
						c6791cf1f2
					
				
					 3 changed files with 26 additions and 27 deletions
				
			
		| 
						 | 
					@ -90,8 +90,8 @@ void WlrLayershell::setHeight(qint32 height) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WlrLayershell::setScreen(QuickshellScreenInfo* screen) {
 | 
					void WlrLayershell::setScreen(QuickshellScreenInfo* screen) {
 | 
				
			||||||
	this->ProxyWindowBase::setScreen(screen);
 | 
					 | 
				
			||||||
	this->ext->setUseWindowScreen(screen != nullptr);
 | 
						this->ext->setUseWindowScreen(screen != nullptr);
 | 
				
			||||||
 | 
						this->ProxyWindowBase::setScreen(screen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NOLINTBEGIN
 | 
					// NOLINTBEGIN
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@
 | 
				
			||||||
#include <private/qquickwindow_p.h>
 | 
					#include <private/qquickwindow_p.h>
 | 
				
			||||||
#include <qcoreevent.h>
 | 
					#include <qcoreevent.h>
 | 
				
			||||||
#include <qevent.h>
 | 
					#include <qevent.h>
 | 
				
			||||||
 | 
					#include <qguiapplication.h>
 | 
				
			||||||
#include <qnamespace.h>
 | 
					#include <qnamespace.h>
 | 
				
			||||||
#include <qobject.h>
 | 
					#include <qobject.h>
 | 
				
			||||||
#include <qqmlcontext.h>
 | 
					#include <qqmlcontext.h>
 | 
				
			||||||
| 
						 | 
					@ -200,9 +201,6 @@ 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();
 | 
					 | 
				
			||||||
		QObject::connect(this->mScreen, &QObject::destroyed, this, &ProxyWindowBase::onScreenDestroyed);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->setWidth(this->mWidth);
 | 
						this->setWidth(this->mWidth);
 | 
				
			||||||
| 
						 | 
					@ -327,39 +325,39 @@ void ProxyWindowBase::setHeight(qint32 height) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
 | 
					void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
 | 
				
			||||||
	auto* qscreen = screen == nullptr ? nullptr : screen->screen;
 | 
						auto* qscreen = screen == nullptr ? nullptr : screen->screen;
 | 
				
			||||||
	if (qscreen == this->mScreen) return;
 | 
						auto newMScreen = this->mScreen != qscreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->mScreen != nullptr) {
 | 
						if (this->mScreen && newMScreen) {
 | 
				
			||||||
		QObject::disconnect(this->mScreen, nullptr, this, nullptr);
 | 
							QObject::disconnect(this->mScreen, nullptr, this, nullptr);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (this->qscreen() != qscreen) {
 | 
				
			||||||
 | 
							this->mScreen = qscreen;
 | 
				
			||||||
		if (this->window == nullptr) {
 | 
							if (this->window == nullptr) {
 | 
				
			||||||
			emit this->screenChanged();
 | 
								emit this->screenChanged();
 | 
				
			||||||
	} else {
 | 
							} else if (qscreen) {
 | 
				
			||||||
			auto reshow = this->isVisibleDirect();
 | 
								auto reshow = this->isVisibleDirect();
 | 
				
			||||||
			if (reshow) this->setVisibleDirect(false);
 | 
								if (reshow) this->setVisibleDirect(false);
 | 
				
			||||||
			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;
 | 
						if (qscreen && newMScreen) {
 | 
				
			||||||
	else this->mScreen = this->window->screen();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		QObject::connect(this->mScreen, &QObject::destroyed, this, &ProxyWindowBase::onScreenDestroyed);
 | 
							QObject::connect(this->mScreen, &QObject::destroyed, this, &ProxyWindowBase::onScreenDestroyed);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }
 | 
					void ProxyWindowBase::onScreenDestroyed() { this->mScreen = nullptr; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QScreen* ProxyWindowBase::qscreen() const {
 | 
				
			||||||
 | 
						if (this->window) return this->window->screen();
 | 
				
			||||||
 | 
						if (this->mScreen) return this->mScreen;
 | 
				
			||||||
 | 
						return QGuiApplication::primaryScreen();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QuickshellScreenInfo* ProxyWindowBase::screen() const {
 | 
					QuickshellScreenInfo* ProxyWindowBase::screen() const {
 | 
				
			||||||
	QScreen* qscreen = nullptr;
 | 
						return QuickshellTracked::instance()->screenInfo(this->qscreen());
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (this->window == nullptr) {
 | 
					 | 
				
			||||||
		if (this->mScreen != nullptr) qscreen = this->mScreen;
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		qscreen = this->window->screen();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return QuickshellTracked::instance()->screenInfo(qscreen);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QColor ProxyWindowBase::color() const { return this->mColor; }
 | 
					QColor ProxyWindowBase::color() const { return this->mColor; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,8 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] qreal devicePixelRatio() const;
 | 
						[[nodiscard]] qreal devicePixelRatio() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] virtual QuickshellScreenInfo* screen() const;
 | 
						[[nodiscard]] QScreen* qscreen() const;
 | 
				
			||||||
 | 
						[[nodiscard]] QuickshellScreenInfo* screen() const;
 | 
				
			||||||
	virtual void setScreen(QuickshellScreenInfo* screen);
 | 
						virtual void setScreen(QuickshellScreenInfo* screen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] QColor color() const;
 | 
						[[nodiscard]] QColor color() const;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue