Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
LayoutComputeService.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include "phosphorzones_export.h"
8#include <QHash>
9#include <QObject>
10#include <QPointer>
11#include <memory>
12
13class QThread;
14
15namespace PhosphorZones {
16
17class Layout;
18class LayoutRegistry;
19class LayoutWorker;
20
21class PHOSPHORZONES_EXPORT LayoutComputeService : public QObject
22{
23 Q_OBJECT
24
25public:
26 explicit LayoutComputeService(QObject* parent = nullptr);
28
30
33 bool requestRecalculate(Layout* layout, const QString& screenId, const QRectF& screenGeometry,
34 qreal screenScale = 0.0);
35 uint64_t currentGeneration(const QString& screenId) const;
36
40 static void recalculateSync(Layout* layout, const QRectF& screenGeometry, qreal screenScale = 0.0);
41
42Q_SIGNALS:
43 void requestCompute(const PhosphorZones::LayoutSnapshot& snapshot, uint64_t generation);
44 void geometriesComputedForGeneration(const QString& screenId, const QUuid& layoutId, PhosphorZones::Layout* layout,
45 uint64_t generation);
46
47private:
48 static LayoutSnapshot buildSnapshot(Layout* layout, const QString& screenId, const QRectF& screenGeometry,
49 qreal screenScale);
50 void applyResult(const LayoutComputeResult& result);
51 void onLayoutRemoved(const QUuid& layoutId);
52 void publishResult(const QString& screenId, const QUuid& layoutId, Layout* layout, uint64_t generation);
53
54 QHash<QUuid, QPointer<Layout>> m_trackedLayouts;
59 QHash<QString, uint64_t> m_screenGeneration;
60 QPointer<LayoutRegistry> m_layoutManager;
61 QThread* m_thread = nullptr;
65 std::unique_ptr<LayoutWorker> m_worker;
68 QHash<QString, int> m_inFlight;
69};
70
71} // namespace PhosphorZones
static void recalculateSync(Layout *layout, const QRectF &screenGeometry, qreal screenScale=0.0)
Recalculate layout in place, on the calling (GUI) thread.
void setLayoutManager(LayoutRegistry *manager)
LayoutComputeService(QObject *parent=nullptr)
bool requestRecalculate(Layout *layout, const QString &screenId, const QRectF &screenGeometry, qreal screenScale=0.0)
screenScale is the output's logical scale, an input for a layout whose fixed geometry counts device p...
void geometriesComputedForGeneration(const QString &screenId, const QUuid &layoutId, PhosphorZones::Layout *layout, uint64_t generation)
uint64_t currentGeneration(const QString &screenId) const
void requestCompute(const PhosphorZones::LayoutSnapshot &snapshot, uint64_t generation)
Manual zone-layout registry + per-context assignment store.
Definition LayoutRegistry.h:87
Definition LayoutWorker.h:13
Represents a collection of zones that form a layout.
Definition Layout.h:42
Definition IWindowTrackingService.h:24
Definition LayoutComputeTypes.h:53
Definition LayoutComputeTypes.h:27