Improves focused-window geometry so chrome placement stays stable across workspaces and floating containers. WindowService now exposes focused workspace X/Y, resolves workspace by name, and publishes those offsets with focused geometry. The Sway backend now tracks the active floating frame through recursion and consistently derives frame/deco/content rects from that frame. QML chrome placement was updated to use workspace-relative coordinates and simpler direct margins (removing interpolation behaviors), with safer title-bar height handling for vertical centering.
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "SwayIpcClient.hpp"
|
|
#include "WindowBackend.hpp"
|
|
|
|
#include <QHash>
|
|
#include <QJsonObject>
|
|
#include <QRect>
|
|
#include <QSet>
|
|
#include <QTimer>
|
|
#include <QVector>
|
|
|
|
class SwayWindowBackend : public WindowBackend
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SwayWindowBackend(QObject *parent = nullptr);
|
|
|
|
bool isConnected() const override;
|
|
QVector<WindowInfo> windows() const override;
|
|
QVector<WorkspaceInfo> 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;
|
|
bool updateFocusedGeometry() 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 QJsonObject &frame,
|
|
const QString &workspace,
|
|
const QString &output,
|
|
bool onScratchpad,
|
|
QVector<WindowInfo> *windows,
|
|
QVector<WorkspaceInfo> *workspaces);
|
|
|
|
SwayIpcClient *m_ipc = nullptr;
|
|
QTimer *m_retryTimer = nullptr;
|
|
QVector<WindowInfo> m_windows;
|
|
QVector<WorkspaceInfo> m_workspaces;
|
|
QHash<qint64, QRect> m_savedGeometry;
|
|
QSet<qint64> m_maximized;
|
|
QSet<qint64> m_minimized;
|
|
qint64 m_focusedWindowId = 0;
|
|
int m_connectAttempts = 0;
|
|
int m_cascadeIndex = 0;
|
|
bool m_refreshQueued = false;
|
|
};
|