Files
andrew ba7945a1d6 Fix window chrome positioning on Sway
Improves focused-window geometry so chrome placement stays stable across workspaces and floating containers. WindowService now exposes focused workspace X/Y, resolves workspace by name, and publishes those offsets with focused geometry. The Sway backend now tracks the active floating frame through recursion and consistently derives frame/deco/content rects from that frame. QML chrome placement was updated to use workspace-relative coordinates and simpler direct margins (removing interpolation behaviors), with safer title-bar height handling for vertical centering.
2026-08-26 23:10:22 +12:00

46 lines
1.1 KiB
C++

#pragma once
#include "WindowTypes.hpp"
#include <QAbstractListModel>
#include <QVector>
#include <QtQml/qqmlregistration.h>
class WorkspaceModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("Obtained from WindowService")
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
enum Roles {
WorkspaceIdRole = Qt::UserRole + 1,
NameRole,
NumberRole,
FocusedRole,
VisibleRole,
OutputRole,
WindowCountRole
};
Q_ENUM(Roles)
explicit WorkspaceModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
int count() const;
void setWorkspaces(QVector<WorkspaceInfo> workspaces);
const WorkspaceInfo *workspaceAt(int row) const;
const WorkspaceInfo *focusedWorkspace() const;
const WorkspaceInfo *workspaceByName(const QString &name) const;
signals:
void countChanged();
private:
QVector<WorkspaceInfo> m_workspaces;
};