mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
hyprland/ipc: expose Hyprland toplevels
This commit is contained in:
parent
c115df8d34
commit
362c8e1b69
11 changed files with 685 additions and 43 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <qtypes.h>
|
||||
|
||||
#include "connection.hpp"
|
||||
#include "hyprland_toplevel.hpp"
|
||||
|
||||
namespace qs::hyprland::ipc {
|
||||
|
||||
|
|
@ -24,8 +25,11 @@ class HyprlandWorkspace: public QObject {
|
|||
/// If this workspace is currently active on a monitor and that monitor is currently
|
||||
/// focused. See also @@active.
|
||||
Q_PROPERTY(bool focused READ default NOTIFY focusedChanged BINDABLE bindableFocused);
|
||||
/// If this workspace has a window that is urgent.
|
||||
/// Becomes always falsed after the workspace is @@focused.
|
||||
Q_PROPERTY(bool urgent READ default NOTIFY urgentChanged BINDABLE bindableUrgent);
|
||||
/// If this workspace currently has a fullscreen client.
|
||||
Q_PROPERTY(bool hasFullscreen READ default NOTIFY focusedChanged BINDABLE bindableHasFullscreen);
|
||||
Q_PROPERTY(bool hasFullscreen READ default NOTIFY hasFullscreenChanged BINDABLE bindableHasFullscreen);
|
||||
/// Last json returned for this workspace, as a javascript object.
|
||||
///
|
||||
/// > [!WARNING] This is *not* updated unless the workspace object is fetched again from
|
||||
|
|
@ -33,6 +37,9 @@ class HyprlandWorkspace: public QObject {
|
|||
/// > property, run @@Hyprland.refreshWorkspaces() and wait for this property to update.
|
||||
Q_PROPERTY(QVariantMap lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged);
|
||||
Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* monitor READ default NOTIFY monitorChanged BINDABLE bindableMonitor);
|
||||
/// List of toplevels on this workspace.
|
||||
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandToplevel*);
|
||||
Q_PROPERTY(UntypedObjectModel* toplevels READ toplevels CONSTANT);
|
||||
// clang-format on
|
||||
QML_ELEMENT;
|
||||
QML_UNCREATABLE("HyprlandWorkspaces must be retrieved from the HyprlandIpc object.");
|
||||
|
|
@ -55,35 +62,46 @@ public:
|
|||
[[nodiscard]] QBindable<QString> bindableName() { return &this->bName; }
|
||||
[[nodiscard]] QBindable<bool> bindableActive() { return &this->bActive; }
|
||||
[[nodiscard]] QBindable<bool> bindableFocused() { return &this->bFocused; }
|
||||
[[nodiscard]] QBindable<bool> bindableUrgent() { return &this->bUrgent; }
|
||||
[[nodiscard]] QBindable<bool> bindableHasFullscreen() { return &this->bHasFullscreen; }
|
||||
[[nodiscard]] QBindable<HyprlandMonitor*> bindableMonitor() { return &this->bMonitor; }
|
||||
[[nodiscard]] ObjectModel<HyprlandToplevel>* toplevels() { return &this->mToplevels; }
|
||||
|
||||
[[nodiscard]] QVariantMap lastIpcObject() const;
|
||||
|
||||
void setMonitor(HyprlandMonitor* monitor);
|
||||
|
||||
void insertToplevel(HyprlandToplevel* toplevel);
|
||||
void removeToplevel(HyprlandToplevel* toplevel);
|
||||
|
||||
signals:
|
||||
void idChanged();
|
||||
void nameChanged();
|
||||
void activeChanged();
|
||||
void focusedChanged();
|
||||
void urgentChanged();
|
||||
void hasFullscreenChanged();
|
||||
void lastIpcObjectChanged();
|
||||
void monitorChanged();
|
||||
|
||||
private slots:
|
||||
void onMonitorDestroyed();
|
||||
void updateUrgent();
|
||||
|
||||
private:
|
||||
HyprlandIpc* ipc;
|
||||
void clearUrgent();
|
||||
|
||||
HyprlandIpc* ipc;
|
||||
QVariantMap mLastIpcObject;
|
||||
|
||||
ObjectModel<HyprlandToplevel> mToplevels {this};
|
||||
|
||||
// clang-format off
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(HyprlandWorkspace, qint32, bId, -1, &HyprlandWorkspace::idChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, QString, bName, &HyprlandWorkspace::nameChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bActive, &HyprlandWorkspace::activeChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bFocused, &HyprlandWorkspace::focusedChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bUrgent, &HyprlandWorkspace::urgentChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bHasFullscreen, &HyprlandWorkspace::hasFullscreenChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, HyprlandMonitor*, bMonitor, &HyprlandWorkspace::monitorChanged);
|
||||
// clang-format on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue