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) {
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue