Skip to content

Commit 3c7dfcb

Browse files
committed
hyprland/ipc: handle renameworkspace
1 parent b336129 commit 3c7dfcb

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/wayland/hyprland/ipc/connection.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,22 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
352352
auto* monitor = this->findMonitorByName(monitorName, true);
353353

354354
workspace->setMonitor(monitor);
355+
} else if (event->name == "renameworkspace") {
356+
auto args = event->parseView(2);
357+
auto id = args.at(0).toInt();
358+
auto name = QString::fromUtf8(args.at(1));
359+
360+
const auto& mList = this->mWorkspaces.valueList();
361+
362+
auto workspaceIter =
363+
std::ranges::find_if(mList, [id](const HyprlandWorkspace* m) { return m->id() == id; });
364+
365+
if (workspaceIter == mList.end()) return;
366+
367+
qCDebug(logHyprlandIpc) << "Workspace with id" << id << "renamed from"
368+
<< (*workspaceIter)->name() << "to" << name;
369+
370+
(*workspaceIter)->setName(name);
355371
}
356372
}
357373

src/wayland/hyprland/ipc/workspace.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111
namespace qs::hyprland::ipc {
1212

1313
qint32 HyprlandWorkspace::id() const { return this->mId; }
14+
1415
QString HyprlandWorkspace::name() const { return this->mName; }
16+
17+
void HyprlandWorkspace::setName(QString name) {
18+
if (name == this->mName) return;
19+
this->mName = std::move(name);
20+
emit this->nameChanged();
21+
}
22+
1523
QVariantMap HyprlandWorkspace::lastIpcObject() const { return this->mLastIpcObject; }
1624

1725
void HyprlandWorkspace::updateInitial(qint32 id, QString name) {

src/wayland/hyprland/ipc/workspace.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ class HyprlandWorkspace: public QObject {
3232
void updateFromObject(QVariantMap object);
3333

3434
[[nodiscard]] qint32 id() const;
35+
3536
[[nodiscard]] QString name() const;
37+
void setName(QString name);
38+
3639
[[nodiscard]] QVariantMap lastIpcObject() const;
3740

38-
void setMonitor(HyprlandMonitor* monitor);
3941
[[nodiscard]] HyprlandMonitor* monitor() const;
42+
void setMonitor(HyprlandMonitor* monitor);
4043

4144
signals:
4245
void idChanged();

0 commit comments

Comments
 (0)