forked from quickshell/quickshell
		
	i3/ipc: provide default sorting for workspaces
This commit is contained in:
		
							parent
							
								
									d6a4ebc742
								
							
						
					
					
						commit
						2028766e61
					
				
					 2 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -247,7 +247,7 @@ void I3Ipc::handleGetWorkspacesEvent(I3IpcEvent* event) {
 | 
			
		|||
		workspace->updateFromObject(object);
 | 
			
		||||
 | 
			
		||||
		if (!existed) {
 | 
			
		||||
			this->mWorkspaces.insertObject(workspace);
 | 
			
		||||
			this->mWorkspaces.insertObjectSorted(workspace, &I3Ipc::compareWorkspaces);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		names.push_back(name);
 | 
			
		||||
| 
						 | 
				
			
			@ -379,7 +379,7 @@ void I3Ipc::handleWorkspaceEvent(I3IpcEvent* event) {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		if (!existed) {
 | 
			
		||||
			this->mWorkspaces.insertObject(workspace);
 | 
			
		||||
			this->mWorkspaces.insertObjectSorted(workspace, &I3Ipc::compareWorkspaces);
 | 
			
		||||
			qCInfo(logI3Ipc) << "Added workspace" << workspace->bindableName().value() << "to list";
 | 
			
		||||
		}
 | 
			
		||||
	} else if (change == "focus") {
 | 
			
		||||
| 
						 | 
				
			
			@ -478,6 +478,10 @@ I3Monitor* I3Ipc::findMonitorByName(const QString& name) {
 | 
			
		|||
ObjectModel<I3Monitor>* I3Ipc::monitors() { return &this->mMonitors; }
 | 
			
		||||
ObjectModel<I3Workspace>* I3Ipc::workspaces() { return &this->mWorkspaces; }
 | 
			
		||||
 | 
			
		||||
bool I3Ipc::compareWorkspaces(I3Workspace* a, I3Workspace* b) {
 | 
			
		||||
	return a->bindableNumber().value() > b->bindableNumber().value();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString I3IpcEvent::type() const { return I3IpcEvent::eventToString(this->mCode); }
 | 
			
		||||
QString I3IpcEvent::data() const { return QString::fromUtf8(this->mData.toJson()); }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,6 +109,7 @@ public:
 | 
			
		|||
 | 
			
		||||
	[[nodiscard]] ObjectModel<I3Monitor>* monitors();
 | 
			
		||||
	[[nodiscard]] ObjectModel<I3Workspace>* workspaces();
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
	void connected();
 | 
			
		||||
	void rawEvent(I3IpcEvent* event);
 | 
			
		||||
| 
						 | 
				
			
			@ -132,6 +133,7 @@ private:
 | 
			
		|||
	void handleGetWorkspacesEvent(I3IpcEvent* event);
 | 
			
		||||
	void handleGetOutputsEvent(I3IpcEvent* event);
 | 
			
		||||
	static void handleRunCommand(I3IpcEvent* event);
 | 
			
		||||
	static bool compareWorkspaces(I3Workspace* a, I3Workspace* b);
 | 
			
		||||
 | 
			
		||||
	void reconnectIPC();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue