forked from quickshell/quickshell
hyprland/ipc: provide default sorting for workspaces
This commit is contained in:
parent
fa74449139
commit
d6a4ebc742
3 changed files with 12 additions and 4 deletions
|
@ -289,7 +289,7 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
|
||||||
|
|
||||||
if (!existed) {
|
if (!existed) {
|
||||||
this->refreshWorkspaces(false);
|
this->refreshWorkspaces(false);
|
||||||
this->mWorkspaces.insertObject(workspace);
|
this->mWorkspaces.insertObjectSorted(workspace, &HyprlandIpc::compareWorkspaces);
|
||||||
}
|
}
|
||||||
} else if (event->name == "destroyworkspacev2") {
|
} else if (event->name == "destroyworkspacev2") {
|
||||||
auto args = event->parseView(2);
|
auto args = event->parseView(2);
|
||||||
|
@ -413,7 +413,7 @@ HyprlandIpc::findWorkspaceByName(const QString& name, bool createIfMissing, qint
|
||||||
|
|
||||||
auto* workspace = new HyprlandWorkspace(this);
|
auto* workspace = new HyprlandWorkspace(this);
|
||||||
workspace->updateInitial(id, name);
|
workspace->updateInitial(id, name);
|
||||||
this->mWorkspaces.insertObject(workspace);
|
this->mWorkspaces.insertObjectSorted(workspace, &HyprlandIpc::compareWorkspaces);
|
||||||
return workspace;
|
return workspace;
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -464,7 +464,7 @@ void HyprlandIpc::refreshWorkspaces(bool canCreate) {
|
||||||
workspace->updateFromObject(object);
|
workspace->updateFromObject(object);
|
||||||
|
|
||||||
if (!existed) {
|
if (!existed) {
|
||||||
this->mWorkspaces.insertObject(workspace);
|
this->mWorkspaces.insertObjectSorted(workspace, &HyprlandIpc::compareWorkspaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
ids.push_back(id);
|
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
|
} // namespace qs::hyprland::ipc
|
||||||
|
|
|
@ -120,6 +120,8 @@ private:
|
||||||
|
|
||||||
void onEvent(HyprlandIpcEvent* event);
|
void onEvent(HyprlandIpcEvent* event);
|
||||||
|
|
||||||
|
static bool compareWorkspaces(HyprlandWorkspace* a, HyprlandWorkspace* b);
|
||||||
|
|
||||||
QLocalSocket eventSocket;
|
QLocalSocket eventSocket;
|
||||||
QString mRequestSocketPath;
|
QString mRequestSocketPath;
|
||||||
QString mEventSocketPath;
|
QString mEventSocketPath;
|
||||||
|
|
|
@ -27,7 +27,9 @@ class HyprlandIpcQml: public QObject {
|
||||||
/// All hyprland monitors.
|
/// All hyprland monitors.
|
||||||
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandMonitor>*);
|
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandMonitor>*);
|
||||||
Q_PROPERTY(UntypedObjectModel* monitors READ monitors CONSTANT);
|
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>*);
|
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandWorkspace>*);
|
||||||
Q_PROPERTY(UntypedObjectModel* workspaces READ workspaces CONSTANT);
|
Q_PROPERTY(UntypedObjectModel* workspaces READ workspaces CONSTANT);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue