Add Nebula.Windows with Sway IPC backend

Introduces a new `core/windows` module (`Nebula.Windows`) with `WindowService`, window/workspace models, and a Sway IPC backend for live window tracking and control (focus, close, move/resize, snap, maximize/restore, minimize, workspace switch). The desktop shell now links this module, uses compositor focus for top-bar active app text, and adds an Open Windows section in the launcher with focus/close actions.

Also updates application metadata handling to parse `StartupWMClass` and map window `app_id`/class to friendly names and icons, and revises Sway config/docs for the new floating-first Desktop 0.2 behavior with temporary compositor-provided decorations.
This commit is contained in:
2026-08-26 18:20:56 +12:00
parent 8c07c10050
commit 2f59d3c115
29 changed files with 2177 additions and 35 deletions
@@ -0,0 +1,63 @@
#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;
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;
};