mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-06 19:14:57 +11:00
hyprland/ipc: add hyprland ipc
Only monitors and workspaces are fully tracked for now.
This commit is contained in:
parent
be237b6ab5
commit
d14ca70984
12 changed files with 1171 additions and 0 deletions
59
src/wayland/hyprland/ipc/workspace.hpp
Normal file
59
src/wayland/hyprland/ipc/workspace.hpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#pragma once
|
||||
|
||||
#include <qbytearrayview.h>
|
||||
#include <qjsonobject.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
namespace qs::hyprland::ipc {
|
||||
|
||||
class HyprlandWorkspace: public QObject {
|
||||
Q_OBJECT;
|
||||
Q_PROPERTY(qint32 id READ id NOTIFY idChanged);
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged);
|
||||
/// Last json returned for this workspace, as a javascript object.
|
||||
///
|
||||
/// > [!WARNING] This is *not* updated unless the workspace object is fetched again from
|
||||
/// > Hyprland. If you need a value that is subject to change and does not have a dedicated
|
||||
/// > property, run `HyprlandIpc.refreshWorkspaces()` and wait for this property to update.
|
||||
Q_PROPERTY(QVariantMap lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged);
|
||||
Q_PROPERTY(HyprlandMonitor* monitor READ monitor NOTIFY monitorChanged);
|
||||
QML_ELEMENT;
|
||||
QML_UNCREATABLE("HyprlandWorkspaces must be retrieved from the HyprlandIpc object.");
|
||||
|
||||
public:
|
||||
explicit HyprlandWorkspace(HyprlandIpc* ipc): QObject(ipc), ipc(ipc) {}
|
||||
|
||||
void updateInitial(qint32 id, QString name);
|
||||
void updateFromObject(QVariantMap object);
|
||||
|
||||
[[nodiscard]] qint32 id() const;
|
||||
[[nodiscard]] QString name() const;
|
||||
[[nodiscard]] QVariantMap lastIpcObject() const;
|
||||
|
||||
void setMonitor(HyprlandMonitor* monitor);
|
||||
[[nodiscard]] HyprlandMonitor* monitor() const;
|
||||
|
||||
signals:
|
||||
void idChanged();
|
||||
void nameChanged();
|
||||
void lastIpcObjectChanged();
|
||||
void monitorChanged();
|
||||
|
||||
private slots:
|
||||
void onMonitorDestroyed();
|
||||
|
||||
private:
|
||||
HyprlandIpc* ipc;
|
||||
|
||||
qint32 mId = -1;
|
||||
QString mName;
|
||||
QVariantMap mLastIpcObject;
|
||||
HyprlandMonitor* mMonitor = nullptr;
|
||||
};
|
||||
|
||||
} // namespace qs::hyprland::ipc
|
||||
Loading…
Add table
Add a link
Reference in a new issue