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:
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QLocalSocket>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
|
||||
class SwayIpcClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum MessageType : quint32 {
|
||||
RunCommand = 0,
|
||||
GetWorkspaces = 1,
|
||||
Subscribe = 2,
|
||||
GetOutputs = 3,
|
||||
GetTree = 4,
|
||||
GetMarks = 5,
|
||||
GetVersion = 7
|
||||
};
|
||||
|
||||
enum EventType : quint32 {
|
||||
WorkspaceEvent = 0x80000000u,
|
||||
OutputEvent = 0x80000001u,
|
||||
WindowEvent = 0x80000003u,
|
||||
BindingEvent = 0x80000005u,
|
||||
ShutdownEvent = 0x80000006u
|
||||
};
|
||||
|
||||
explicit SwayIpcClient(QObject *parent = nullptr);
|
||||
~SwayIpcClient() override;
|
||||
|
||||
bool connectToSway();
|
||||
void disconnectFromSway();
|
||||
bool isConnected() const;
|
||||
|
||||
QJsonDocument request(quint32 type, const QByteArray &payload = {});
|
||||
bool subscribe(const QStringList &events);
|
||||
|
||||
static QString socketPath();
|
||||
|
||||
signals:
|
||||
void connectedChanged();
|
||||
void disconnected();
|
||||
void eventReceived(quint32 type, const QJsonDocument &payload);
|
||||
|
||||
private:
|
||||
struct Message {
|
||||
quint32 type = 0;
|
||||
QByteArray payload;
|
||||
};
|
||||
|
||||
bool writeMessage(QLocalSocket *socket, quint32 type, const QByteArray &payload);
|
||||
bool readMessage(QLocalSocket *socket, Message *message, int timeoutMs);
|
||||
void appendIncoming(QLocalSocket *socket, QByteArray *buffer);
|
||||
bool takeMessage(QByteArray *buffer, Message *message);
|
||||
void processEventSocket();
|
||||
void flushPendingEvents();
|
||||
void handleCommandDisconnected();
|
||||
void handleEventDisconnected();
|
||||
|
||||
QLocalSocket *m_command = nullptr;
|
||||
QLocalSocket *m_event = nullptr;
|
||||
QByteArray m_eventBuffer;
|
||||
QVector<Message> m_pendingEvents;
|
||||
int m_inRequest = 0;
|
||||
bool m_connected = false;
|
||||
};
|
||||
Reference in New Issue
Block a user