forked from quickshell/quickshell
sway: add urgent and focused dispatchers to workspaces flake: add sway toggle WIP sway: add monitor status sway: handle multiple ipc events in one line sway: reuse socket connection for dispatches & better command type handling WIP sway: add associated monitor to a workspace i3/sway: update to allow for i3 compatibility i3/sway: manage setting the focused monitors i3/sway: fix multi monitor crash i3/sway: fix linting errors i3/sway: update nix package flag naming to i3 i3/sway: add documentation, fix module.md and impl monitorFor i3/sway: handle more workspace ipc events i3/sway: fix review i3/sway: fix crash due to newline breaking up an IPC message i3/sway: handle broken messages by forwarding to the next magic sequence i3/sway: break loop when buffer is empty i3/sway: fix monitor focus & focused monitor signal not being emitted i3/sway: use datastreams instead of qbytearrays for socket reading i3/sway: fix lint issues i3/sway: drop second socket connection, remove dispatch return value, recreate IPC connection on fatal error i3/sway: handle run_command responses i3/sway: remove reconnection on unknown event i3/sway: fix formatting, lint & avoid writing to socket if connection is not open
73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "connection.hpp"
|
|
|
|
namespace qs::i3::ipc {
|
|
|
|
///! I3/Sway workspaces
|
|
class I3Workspace: public QObject {
|
|
Q_OBJECT;
|
|
|
|
/// The ID of this workspace, it is unique for i3/Sway launch
|
|
Q_PROPERTY(qint32 id READ id NOTIFY idChanged);
|
|
|
|
/// The name of this workspace
|
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged);
|
|
|
|
/// The number of this workspace
|
|
Q_PROPERTY(qint32 num READ num NOTIFY numChanged);
|
|
|
|
/// If a window in this workspace has an urgent notification
|
|
Q_PROPERTY(bool urgent READ urgent NOTIFY urgentChanged);
|
|
|
|
/// If this workspace is the one currently in focus
|
|
Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged);
|
|
|
|
/// The monitor this workspace is being displayed on
|
|
Q_PROPERTY(qs::i3::ipc::I3Monitor* monitor READ monitor NOTIFY monitorChanged);
|
|
|
|
/// Last JSON returned for this workspace, as a JavaScript object.
|
|
///
|
|
/// This updates every time we receive a `workspace` event from i3/Sway
|
|
Q_PROPERTY(QVariantMap lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged);
|
|
|
|
QML_ELEMENT;
|
|
QML_UNCREATABLE("I3Workspaces must be retrieved from the I3 object.");
|
|
|
|
public:
|
|
I3Workspace(qs::i3::ipc::I3Ipc* ipc): QObject(ipc), ipc(ipc) {}
|
|
|
|
[[nodiscard]] qint32 id() const;
|
|
[[nodiscard]] QString name() const;
|
|
[[nodiscard]] qint32 num() const;
|
|
[[nodiscard]] bool urgent() const;
|
|
[[nodiscard]] bool focused() const;
|
|
[[nodiscard]] I3Monitor* monitor() const;
|
|
[[nodiscard]] QVariantMap lastIpcObject() const;
|
|
|
|
void updateFromObject(const QVariantMap& obj);
|
|
void setFocus(bool focus);
|
|
|
|
signals:
|
|
void idChanged();
|
|
void nameChanged();
|
|
void urgentChanged();
|
|
void focusedChanged();
|
|
void numChanged();
|
|
void monitorChanged();
|
|
void lastIpcObjectChanged();
|
|
|
|
private:
|
|
I3Ipc* ipc;
|
|
|
|
qint32 mId = -1;
|
|
QString mName;
|
|
qint32 mNum = -1;
|
|
bool mFocused = false;
|
|
bool mUrgent = false;
|
|
|
|
QVariantMap mLastIpcObject;
|
|
I3Monitor* mMonitor = nullptr;
|
|
QString mMonitorName;
|
|
};
|
|
} // namespace qs::i3::ipc
|