Add floating traffic-light window chrome

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.
This commit is contained in:
2026-08-26 22:38:33 +12:00
parent 08e67845a5
commit 4321209e92
14 changed files with 452 additions and 92 deletions
+32
View File
@@ -7,6 +7,7 @@
#include <QJSEngine>
#include <QObject>
#include <QQmlEngine>
#include <QTimer>
#include <QVector>
#include <QtQml/qqmlregistration.h>
@@ -27,6 +28,15 @@ class WindowService : public QObject
Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusChanged)
Q_PROPERTY(QString focusedApplicationName READ focusedApplicationName NOTIFY focusChanged)
Q_PROPERTY(bool focusedWindowMaximized READ focusedWindowMaximized NOTIFY focusChanged)
Q_PROPERTY(bool focusedWindowFullscreen READ focusedWindowFullscreen NOTIFY focusChanged)
Q_PROPERTY(int focusedWindowX READ focusedWindowX NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowY READ focusedWindowY NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowWidth READ focusedWindowWidth NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowHeight READ focusedWindowHeight NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowDecoX READ focusedWindowDecoX NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowDecoY READ focusedWindowDecoY NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowDecoWidth READ focusedWindowDecoWidth NOTIFY focusedWindowGeometryChanged)
Q_PROPERTY(int focusedWindowDecoHeight READ focusedWindowDecoHeight NOTIFY focusedWindowGeometryChanged)
public:
enum SnapEdge {
@@ -50,6 +60,15 @@ public:
QString focusedApplicationId() const;
QString focusedApplicationName() const;
bool focusedWindowMaximized() const;
bool focusedWindowFullscreen() const;
int focusedWindowX() const;
int focusedWindowY() const;
int focusedWindowWidth() const;
int focusedWindowHeight() const;
int focusedWindowDecoX() const;
int focusedWindowDecoY() const;
int focusedWindowDecoWidth() const;
int focusedWindowDecoHeight() const;
Q_INVOKABLE bool focusWindow(const QString &windowId);
Q_INVOKABLE bool closeWindow(const QString &windowId);
@@ -69,9 +88,12 @@ signals:
void connectedChanged();
void windowCountChanged();
void focusChanged();
void focusedWindowGeometryChanged();
private:
void syncFromBackend();
void syncFocusedGeometry();
void publishFocusedGeometry(const WindowInfo *focused);
void resolveNames(QVector<WindowInfo> &windows) const;
void bindApplicationService();
static qint64 parseWindowId(const QString &windowId);
@@ -87,4 +109,14 @@ private:
QString m_focusedApplicationId;
QString m_focusedApplicationName;
bool m_focusedWindowMaximized = false;
bool m_focusedWindowFullscreen = false;
int m_focusedWindowX = 0;
int m_focusedWindowY = 0;
int m_focusedWindowWidth = 0;
int m_focusedWindowHeight = 0;
int m_focusedWindowDecoX = 0;
int m_focusedWindowDecoY = 0;
int m_focusedWindowDecoWidth = 0;
int m_focusedWindowDecoHeight = 0;
QTimer *m_geometryTimer = nullptr;
};