Introduces a dedicated layer-shell `WindowChromeSurface` that renders macOS-style traffic-light controls over the focused Sway window titlebar, replacing the old top-bar window controls. Adds theme tokens and a reusable `TrafficLightButton` component, updates shell QML/CMake wiring, and adjusts Sway titlebar padding/title format so window titles do not overlap the overlay. Window tracking was extended with focused-window geometry/deco/fullscreen properties plus backend refresh support so the chrome follows window movement and state changes in near real time.
65 lines
2.1 KiB
C++
65 lines
2.1 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 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;
|
|
};
|