hyprland/ipc: further cleanup + add Hyprland.focusedWorkspace
This commit is contained in:
parent
67b2682604
commit
392f56c40e
5 changed files with 39 additions and 8 deletions
|
@ -50,6 +50,11 @@ HyprlandIpc::HyprlandIpc() {
|
|||
return;
|
||||
}
|
||||
|
||||
this->bFocusedWorkspace.setBinding([this]() -> HyprlandWorkspace* {
|
||||
if (!this->bFocusedMonitor) return nullptr;
|
||||
return this->bFocusedMonitor->bindableActiveWorkspace().value();
|
||||
});
|
||||
|
||||
this->mRequestSocketPath = hyprlandDir + "/.socket.sock";
|
||||
this->mEventSocketPath = hyprlandDir + "/.socket2.sock";
|
||||
|
||||
|
|
|
@ -81,6 +81,10 @@ public:
|
|||
return &this->bFocusedMonitor;
|
||||
}
|
||||
|
||||
[[nodiscard]] QBindable<HyprlandWorkspace*> bindableFocusedWorkspace() const {
|
||||
return &this->bFocusedWorkspace;
|
||||
}
|
||||
|
||||
void setFocusedMonitor(HyprlandMonitor* monitor);
|
||||
|
||||
[[nodiscard]] ObjectModel<HyprlandMonitor>* monitors();
|
||||
|
@ -102,6 +106,7 @@ signals:
|
|||
void rawEvent(HyprlandIpcEvent* event);
|
||||
|
||||
void focusedMonitorChanged();
|
||||
void focusedWorkspaceChanged();
|
||||
|
||||
private slots:
|
||||
void eventSocketError(QLocalSocket::LocalSocketError error) const;
|
||||
|
@ -134,6 +139,13 @@ private:
|
|||
bFocusedMonitor,
|
||||
&HyprlandIpc::focusedMonitorChanged
|
||||
);
|
||||
|
||||
Q_OBJECT_BINDABLE_PROPERTY(
|
||||
HyprlandIpc,
|
||||
HyprlandWorkspace*,
|
||||
bFocusedWorkspace,
|
||||
&HyprlandIpc::focusedWorkspaceChanged
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace qs::hyprland::ipc
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "qml.hpp"
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qproperty.h>
|
||||
|
||||
#include "../../../core/model.hpp"
|
||||
#include "../../../core/qmlscreen.hpp"
|
||||
|
@ -13,6 +14,14 @@ HyprlandIpcQml::HyprlandIpcQml() {
|
|||
auto* instance = HyprlandIpc::instance();
|
||||
|
||||
QObject::connect(instance, &HyprlandIpc::rawEvent, this, &HyprlandIpcQml::rawEvent);
|
||||
|
||||
QObject::connect(
|
||||
instance,
|
||||
&HyprlandIpc::focusedMonitorChanged,
|
||||
this,
|
||||
&HyprlandIpcQml::focusedMonitorChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
instance,
|
||||
&HyprlandIpc::focusedMonitorChanged,
|
||||
|
@ -30,15 +39,16 @@ HyprlandMonitor* HyprlandIpcQml::monitorFor(QuickshellScreenInfo* screen) {
|
|||
}
|
||||
|
||||
void HyprlandIpcQml::refreshMonitors() { HyprlandIpc::instance()->refreshMonitors(false); }
|
||||
|
||||
void HyprlandIpcQml::refreshWorkspaces() { HyprlandIpc::instance()->refreshWorkspaces(false); }
|
||||
|
||||
QString HyprlandIpcQml::requestSocketPath() { return HyprlandIpc::instance()->requestSocketPath(); }
|
||||
|
||||
QString HyprlandIpcQml::eventSocketPath() { return HyprlandIpc::instance()->eventSocketPath(); }
|
||||
|
||||
HyprlandMonitor* HyprlandIpcQml::focusedMonitor() {
|
||||
return HyprlandIpc::instance()->bindableFocusedMonitor().value();
|
||||
QBindable<HyprlandMonitor*> HyprlandIpcQml::bindableFocusedMonitor() {
|
||||
return HyprlandIpc::instance()->bindableFocusedMonitor();
|
||||
}
|
||||
|
||||
QBindable<HyprlandWorkspace*> HyprlandIpcQml::bindableFocusedWorkspace() {
|
||||
return HyprlandIpc::instance()->bindableFocusedWorkspace();
|
||||
}
|
||||
|
||||
ObjectModel<HyprlandMonitor>* HyprlandIpcQml::monitors() {
|
||||
|
|
|
@ -21,7 +21,9 @@ class HyprlandIpcQml: public QObject {
|
|||
/// Path to the event socket (.socket2.sock)
|
||||
Q_PROPERTY(QString eventSocketPath READ eventSocketPath CONSTANT);
|
||||
/// The currently focused hyprland monitor. May be null.
|
||||
Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* focusedMonitor READ focusedMonitor NOTIFY focusedMonitorChanged);
|
||||
Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* focusedMonitor READ default NOTIFY focusedMonitorChanged BINDABLE bindableFocusedMonitor);
|
||||
/// The currently focused hyprland workspace. May be null.
|
||||
Q_PROPERTY(qs::hyprland::ipc::HyprlandWorkspace* focusedWorkspace READ default NOTIFY focusedWorkspaceChanged BINDABLE bindableFocusedWorkspace);
|
||||
/// All hyprland monitors.
|
||||
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandMonitor>*);
|
||||
Q_PROPERTY(UntypedObjectModel* monitors READ monitors CONSTANT);
|
||||
|
@ -55,7 +57,8 @@ public:
|
|||
|
||||
[[nodiscard]] static QString requestSocketPath();
|
||||
[[nodiscard]] static QString eventSocketPath();
|
||||
[[nodiscard]] static HyprlandMonitor* focusedMonitor();
|
||||
[[nodiscard]] static QBindable<HyprlandMonitor*> bindableFocusedMonitor();
|
||||
[[nodiscard]] static QBindable<HyprlandWorkspace*> bindableFocusedWorkspace();
|
||||
[[nodiscard]] static ObjectModel<HyprlandMonitor>* monitors();
|
||||
[[nodiscard]] static ObjectModel<HyprlandWorkspace>* workspaces();
|
||||
|
||||
|
@ -66,6 +69,7 @@ signals:
|
|||
void rawEvent(qs::hyprland::ipc::HyprlandIpcEvent* event);
|
||||
|
||||
void focusedMonitorChanged();
|
||||
void focusedWorkspaceChanged();
|
||||
};
|
||||
|
||||
} // namespace qs::hyprland::ipc
|
||||
|
|
|
@ -22,7 +22,7 @@ HyprlandWorkspace::HyprlandWorkspace(HyprlandIpc* ipc): QObject(ipc), ipc(ipc) {
|
|||
});
|
||||
|
||||
this->bFocused.setBinding([this]() {
|
||||
return this->bActive.value() && this->bMonitor->bindableFocused().value();
|
||||
return this->ipc->bindableFocusedWorkspace().value() == this;
|
||||
});
|
||||
|
||||
Qt::endPropertyUpdateGroup();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue