#pragma once #include #include #include #include #include #include #include #include #include "../core/qmlscreen.hpp" #include "screenprojection.hpp" #include "windowset.hpp" namespace qs::wm { class WindowManager: public QObject { Q_OBJECT; public: static void setProvider(std::function provider); static WindowManager* instance(); Q_INVOKABLE ScreenProjection* screenProjection(QuickshellScreenInfo* screen); [[nodiscard]] QBindable> bindableWindowsets() const { return &this->bWindowsets; } [[nodiscard]] QBindable> bindableWindowsetProjections() const { return &this->bWindowsetProjections; } signals: void windowsetsChanged(); void windowsetProjectionsChanged(); public: Q_OBJECT_BINDABLE_PROPERTY( WindowManager, QList, bWindowsets, &WindowManager::windowsetsChanged ); Q_OBJECT_BINDABLE_PROPERTY( WindowManager, QList, bWindowsetProjections, &WindowManager::windowsetProjectionsChanged ); private: static std::function provider; QHash mScreenProjections; }; ///! Window management interfaces exposed by the window manager. class WindowManagerQml: public QObject { Q_OBJECT; QML_NAMED_ELEMENT(WindowManager); QML_SINGLETON; // clang-format off /// All windowsets tracked by the WM across all projections. Q_PROPERTY(QList windowsets READ default BINDABLE bindableWindowsets); /// All windowset projections tracked by the WM. Does not include /// internal projections from @@screenProjection(). Q_PROPERTY(QList windowsetProjections READ default BINDABLE bindableWindowsetProjections); // clang-format on public: /// Returns an internal WindowsetProjection that covers a single screen and contains all /// windowsets on that screen, regardless of the WM-specified projection. Depending on /// how the WM lays out its actual projections, multiple ScreenProjections may contain /// the same Windowsets. Q_INVOKABLE static ScreenProjection* screenProjection(QuickshellScreenInfo* screen) { return WindowManager::instance()->screenProjection(screen); } [[nodiscard]] static QBindable> bindableWindowsets() { return WindowManager::instance()->bindableWindowsets(); } [[nodiscard]] static QBindable> bindableWindowsetProjections() { return WindowManager::instance()->bindableWindowsetProjections(); } }; } // namespace qs::wm