Skip to content

Commit

Permalink
hyprland/ipc: handle renameworkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed committed Jan 22, 2025
1 parent b336129 commit 3c7dfcb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/wayland/hyprland/ipc/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
auto* monitor = this->findMonitorByName(monitorName, true);

workspace->setMonitor(monitor);
} else if (event->name == "renameworkspace") {
auto args = event->parseView(2);
auto id = args.at(0).toInt();
auto name = QString::fromUtf8(args.at(1));

const auto& mList = this->mWorkspaces.valueList();

auto workspaceIter =
std::ranges::find_if(mList, [id](const HyprlandWorkspace* m) { return m->id() == id; });

if (workspaceIter == mList.end()) return;

qCDebug(logHyprlandIpc) << "Workspace with id" << id << "renamed from"
<< (*workspaceIter)->name() << "to" << name;

(*workspaceIter)->setName(name);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/wayland/hyprland/ipc/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
namespace qs::hyprland::ipc {

qint32 HyprlandWorkspace::id() const { return this->mId; }

QString HyprlandWorkspace::name() const { return this->mName; }

void HyprlandWorkspace::setName(QString name) {
if (name == this->mName) return;
this->mName = std::move(name);
emit this->nameChanged();
}

QVariantMap HyprlandWorkspace::lastIpcObject() const { return this->mLastIpcObject; }

void HyprlandWorkspace::updateInitial(qint32 id, QString name) {
Expand Down
5 changes: 4 additions & 1 deletion src/wayland/hyprland/ipc/workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class HyprlandWorkspace: public QObject {
void updateFromObject(QVariantMap object);

[[nodiscard]] qint32 id() const;

[[nodiscard]] QString name() const;
void setName(QString name);

[[nodiscard]] QVariantMap lastIpcObject() const;

void setMonitor(HyprlandMonitor* monitor);
[[nodiscard]] HyprlandMonitor* monitor() const;
void setMonitor(HyprlandMonitor* monitor);

signals:
void idChanged();
Expand Down

0 comments on commit 3c7dfcb

Please sign in to comment.