forked from quickshell/quickshell
		
	all/window: use global screeninfo pool for screen getter
This commit is contained in:
		
							parent
							
								
									9cbd5abd96
								
							
						
					
					
						commit
						3026d3400a
					
				
					 4 changed files with 17 additions and 8 deletions
				
			
		| 
						 | 
					@ -13,6 +13,7 @@
 | 
				
			||||||
#include <qwindow.h>
 | 
					#include <qwindow.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "generation.hpp"
 | 
					#include "generation.hpp"
 | 
				
			||||||
 | 
					#include "qmlglobal.hpp"
 | 
				
			||||||
#include "qmlscreen.hpp"
 | 
					#include "qmlscreen.hpp"
 | 
				
			||||||
#include "region.hpp"
 | 
					#include "region.hpp"
 | 
				
			||||||
#include "reload.hpp"
 | 
					#include "reload.hpp"
 | 
				
			||||||
| 
						 | 
					@ -231,6 +232,8 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto* qscreen = screen == nullptr ? nullptr : screen->screen;
 | 
						auto* qscreen = screen == nullptr ? nullptr : screen->screen;
 | 
				
			||||||
 | 
						if (qscreen == this->mScreen) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (qscreen != nullptr) {
 | 
						if (qscreen != nullptr) {
 | 
				
			||||||
		QObject::connect(qscreen, &QObject::destroyed, this, &ProxyWindowBase::onScreenDestroyed);
 | 
							QObject::connect(qscreen, &QObject::destroyed, this, &ProxyWindowBase::onScreenDestroyed);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -257,10 +260,7 @@ QuickshellScreenInfo* ProxyWindowBase::screen() const {
 | 
				
			||||||
		qscreen = this->window->screen();
 | 
							qscreen = this->window->screen();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return new QuickshellScreenInfo(
 | 
						return QuickshellTracked::instance()->screenInfo(qscreen);
 | 
				
			||||||
	    const_cast<ProxyWindowBase*>(this), // NOLINT
 | 
					 | 
				
			||||||
	    qscreen
 | 
					 | 
				
			||||||
	);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QColor ProxyWindowBase::color() const {
 | 
					QColor ProxyWindowBase::color() const {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@
 | 
				
			||||||
#include <qqmlcontext.h>
 | 
					#include <qqmlcontext.h>
 | 
				
			||||||
#include <qqmlengine.h>
 | 
					#include <qqmlengine.h>
 | 
				
			||||||
#include <qqmllist.h>
 | 
					#include <qqmllist.h>
 | 
				
			||||||
 | 
					#include <qscreen.h>
 | 
				
			||||||
#include <qtenvironmentvariables.h>
 | 
					#include <qtenvironmentvariables.h>
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
| 
						 | 
					@ -73,6 +74,14 @@ QuickshellTracked::QuickshellTracked() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QuickshellScreenInfo* QuickshellTracked::screenInfo(QScreen* screen) const {
 | 
				
			||||||
 | 
						for (auto* info: this->screens) {
 | 
				
			||||||
 | 
							if (info->screen == screen) return info;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nullptr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QuickshellTracked* QuickshellTracked::instance() {
 | 
					QuickshellTracked* QuickshellTracked::instance() {
 | 
				
			||||||
	static QuickshellTracked* instance = nullptr; // NOLINT
 | 
						static QuickshellTracked* instance = nullptr; // NOLINT
 | 
				
			||||||
	if (instance == nullptr) {
 | 
						if (instance == nullptr) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
#include <qqmlengine.h>
 | 
					#include <qqmlengine.h>
 | 
				
			||||||
#include <qqmlintegration.h>
 | 
					#include <qqmlintegration.h>
 | 
				
			||||||
#include <qqmllist.h>
 | 
					#include <qqmllist.h>
 | 
				
			||||||
 | 
					#include <qscreen.h>
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
#include <qvariant.h>
 | 
					#include <qvariant.h>
 | 
				
			||||||
| 
						 | 
					@ -60,6 +61,7 @@ public:
 | 
				
			||||||
	QuickshellTracked();
 | 
						QuickshellTracked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QVector<QuickshellScreenInfo*> screens;
 | 
						QVector<QuickshellScreenInfo*> screens;
 | 
				
			||||||
 | 
						QuickshellScreenInfo* screenInfo(QScreen* screen) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static QuickshellTracked* instance();
 | 
						static QuickshellTracked* instance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,7 @@
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../core/qmlglobal.hpp"
 | 
				
			||||||
#include "../core/qmlscreen.hpp"
 | 
					#include "../core/qmlscreen.hpp"
 | 
				
			||||||
#include "../core/reload.hpp"
 | 
					#include "../core/reload.hpp"
 | 
				
			||||||
#include "session_lock/session_lock.hpp"
 | 
					#include "session_lock/session_lock.hpp"
 | 
				
			||||||
| 
						 | 
					@ -243,10 +244,7 @@ QuickshellScreenInfo* WlSessionLockSurface::screen() const {
 | 
				
			||||||
		qscreen = this->window->screen();
 | 
							qscreen = this->window->screen();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return new QuickshellScreenInfo(
 | 
						return QuickshellTracked::instance()->screenInfo(qscreen);
 | 
				
			||||||
	    const_cast<WlSessionLockSurface*>(this), // NOLINT
 | 
					 | 
				
			||||||
	    qscreen
 | 
					 | 
				
			||||||
	);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WlSessionLockSurface::setScreen(QScreen* qscreen) {
 | 
					void WlSessionLockSurface::setScreen(QScreen* qscreen) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue