mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
hyprland/ipc: provide default sorting for workspaces
This commit is contained in:
3 files changed
+12
-4
No files matched your search
@@ -289,7 +289,7 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
|
||||
|
||||
if (!existed) {
|
||||
this->refreshWorkspaces(false);
|
||||
this->mWorkspaces.insertObject(workspace);
|
||||
this->mWorkspaces.insertObjectSorted(workspace, &HyprlandIpc::compareWorkspaces);
|
||||
}
|
||||
} else if (event->name == "destroyworkspacev2") {
|
||||
auto args = event->parseView(2);
|
||||
@@ -413,7 +413,7 @@ HyprlandIpc::findWorkspaceByName(const QString& name, bool createIfMissing, qint
|
||||
|
||||
auto* workspace = new HyprlandWorkspace(this);
|
||||
workspace->updateInitial(id, name);
|
||||
this->mWorkspaces.insertObject(workspace);
|
||||
this->mWorkspaces.insertObjectSorted(workspace, &HyprlandIpc::compareWorkspaces);
|
||||
return workspace;
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -464,7 +464,7 @@ void HyprlandIpc::refreshWorkspaces(bool canCreate) {
|
||||
workspace->updateFromObject(object);
|
||||
|
||||
if (!existed) {
|
||||
this->mWorkspaces.insertObject(workspace);
|
||||
this->mWorkspaces.insertObjectSorted(workspace, &HyprlandIpc::compareWorkspaces);
|
||||
}
|
||||
|
||||
ids.push_back(id);
|
||||
@@ -596,4 +596,8 @@ void HyprlandIpc::refreshMonitors(bool canCreate) {
|
||||
});
|
||||
}
|
||||
|
||||
bool HyprlandIpc::compareWorkspaces(HyprlandWorkspace* a, HyprlandWorkspace* b) {
|
||||
return a->bindableId().value() > b->bindableId().value();
|
||||
}
|
||||
|
||||
} // namespace qs::hyprland::ipc
|
||||
@@ -120,6 +120,8 @@ private:
|
||||
|
||||
void onEvent(HyprlandIpcEvent* event);
|
||||
|
||||
static bool compareWorkspaces(HyprlandWorkspace* a, HyprlandWorkspace* b);
|
||||
|
||||
QLocalSocket eventSocket;
|
||||
QString mRequestSocketPath;
|
||||
QString mEventSocketPath;
|
||||
|
||||
@@ -27,7 +27,9 @@ class HyprlandIpcQml: public QObject {
|
||||
/// All hyprland monitors.
|
||||
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandMonitor>*);
|
||||
Q_PROPERTY(UntypedObjectModel* monitors READ monitors CONSTANT);
|
||||
/// All hyprland workspaces.
|
||||
/// All hyprland workspaces, sorted by id.
|
||||
///
|
||||
/// > [!NOTE] Named workspaces have a negative id, and will appear before unnamed workspaces.
|
||||
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandWorkspace>*);
|
||||
Q_PROPERTY(UntypedObjectModel* workspaces READ workspaces CONSTANT);
|
||||
// clang-format on
|
||||
|
||||
Reference in new issue
Block a user