Files
Nebula-OS/core/windows/backends/sway/SwayWindowBackend.hpp
T
andrew 4d70014242 Align window chrome with Sway title bars
Adds focused title-bar geometry to the window service and updates the Sway backend to derive frame data more reliably (including parent node fallback and content rect tracking for wrapped/floating views). Window chrome positioning now centers against the actual title bar instead of deco offsets, improving alignment. Also refreshes visual sizing/padding for traffic-light controls and Sway titlebar spacing to match the new chrome metrics.
2026-08-26 22:45:50 +12:00

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 &parent,
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;
};