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.
83 lines
2.9 KiB
C++
83 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include "WindowBackend.hpp"
|
|
#include "WindowModel.hpp"
|
|
#include "WorkspaceModel.hpp"
|
|
|
|
#include <QJSEngine>
|
|
#include <QObject>
|
|
#include <QQmlEngine>
|
|
#include <QVector>
|
|
#include <QtQml/qqmlregistration.h>
|
|
|
|
class ApplicationService;
|
|
|
|
class WindowService : public QObject
|
|
{
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
QML_SINGLETON
|
|
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
|
|
Q_PROPERTY(WindowModel *model READ model CONSTANT)
|
|
Q_PROPERTY(WorkspaceModel *workspaceModel READ workspaceModel CONSTANT)
|
|
Q_PROPERTY(int windowCount READ windowCount NOTIFY windowCountChanged)
|
|
Q_PROPERTY(QString focusedWindowId READ focusedWindowId NOTIFY focusChanged)
|
|
Q_PROPERTY(QString focusedWindowTitle READ focusedWindowTitle NOTIFY focusChanged)
|
|
Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusChanged)
|
|
Q_PROPERTY(QString focusedApplicationName READ focusedApplicationName NOTIFY focusChanged)
|
|
|
|
public:
|
|
enum SnapEdge {
|
|
SnapLeft = WindowBackend::SnapLeft,
|
|
SnapRight = WindowBackend::SnapRight,
|
|
SnapMaximize = WindowBackend::SnapMaximize
|
|
};
|
|
Q_ENUM(SnapEdge)
|
|
|
|
explicit WindowService(QObject *parent = nullptr);
|
|
static WindowService *create(QQmlEngine *engine, QJSEngine *scriptEngine);
|
|
|
|
bool connected() const;
|
|
WindowModel *model() const;
|
|
WorkspaceModel *workspaceModel() const;
|
|
int windowCount() const;
|
|
|
|
QString focusedWindowId() const;
|
|
QString focusedWindowTitle() const;
|
|
QString focusedApplicationId() const;
|
|
QString focusedApplicationName() const;
|
|
|
|
Q_INVOKABLE bool focusWindow(const QString &windowId);
|
|
Q_INVOKABLE bool closeWindow(const QString &windowId);
|
|
Q_INVOKABLE bool maximizeWindow(const QString &windowId);
|
|
Q_INVOKABLE bool restoreWindow(const QString &windowId);
|
|
Q_INVOKABLE bool minimizeWindow(const QString &windowId);
|
|
Q_INVOKABLE bool setWindowFloating(const QString &windowId, bool floating);
|
|
Q_INVOKABLE bool moveWindow(const QString &windowId, int x, int y);
|
|
Q_INVOKABLE bool resizeWindow(const QString &windowId, int width, int height);
|
|
Q_INVOKABLE bool snapWindow(const QString &windowId, SnapEdge edge);
|
|
Q_INVOKABLE bool switchWorkspace(const QString &workspaceId);
|
|
|
|
signals:
|
|
void connectedChanged();
|
|
void windowCountChanged();
|
|
void focusChanged();
|
|
|
|
private:
|
|
void syncFromBackend();
|
|
void resolveNames(QVector<WindowInfo> &windows) const;
|
|
void bindApplicationService();
|
|
static qint64 parseWindowId(const QString &windowId);
|
|
static QString humanizeIdentifier(const QString &appId, const QString &windowClass);
|
|
static QString titleCaseIdentifier(QString id);
|
|
|
|
WindowBackend *m_backend = nullptr;
|
|
WindowModel *m_model = nullptr;
|
|
WorkspaceModel *m_workspaces = nullptr;
|
|
ApplicationService *m_applications = nullptr;
|
|
QString m_focusedWindowId;
|
|
QString m_focusedWindowTitle;
|
|
QString m_focusedApplicationId;
|
|
QString m_focusedApplicationName;
|
|
};
|