#pragma once #include "SwayIpcClient.hpp" #include "WindowBackend.hpp" #include #include #include #include #include #include class SwayWindowBackend : public WindowBackend { Q_OBJECT public: explicit SwayWindowBackend(QObject *parent = nullptr); bool isConnected() const override; QVector windows() const override; QVector workspaces() const override; qint64 focusedWindowId() const override; bool focusWindow(qint64 windowId) override; bool closeWindow(qint64 windowId) override; bool maximizeWindow(qint64 windowId) override; bool restoreWindow(qint64 windowId) override; bool minimizeWindow(qint64 windowId) override; bool setWindowFloating(qint64 windowId, bool floating) override; bool moveWindow(qint64 windowId, int x, int y) override; bool resizeWindow(qint64 windowId, int width, int height) override; bool snapWindow(qint64 windowId, SnapEdge edge) override; bool switchWorkspace(const QString &workspaceId) override; private: void tryConnect(); void refresh(); void handleEvent(quint32 type, const QJsonDocument &payload); void handleNewWindow(qint64 windowId); bool run(const QString &command); bool saveGeometry(qint64 windowId); const WindowInfo *findWindow(qint64 windowId) const; static bool isShellChrome(const QJsonObject &node); static void collect(const QJsonObject &node, const QString &workspace, const QString &output, bool onScratchpad, QVector *windows, QVector *workspaces); SwayIpcClient *m_ipc = nullptr; QTimer *m_retryTimer = nullptr; QVector m_windows; QVector m_workspaces; QHash m_savedGeometry; QSet m_maximized; QSet m_minimized; qint64 m_focusedWindowId = 0; int m_connectAttempts = 0; int m_cascadeIndex = 0; bool m_refreshQueued = false; };