-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathoutputlifecyclemanager.h
More file actions
63 lines (52 loc) · 2 KB
/
Copy pathoutputlifecyclemanager.h
File metadata and controls
63 lines (52 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) 2025-2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#pragma once
#include <QList>
#include <QString>
#include <QObject>
#include <memory>
class Output;
class OutputConfigState;
class SurfaceWrapper;
class RootSurfaceContainer;
class OutputLifecycleManager : public QObject {
Q_OBJECT
public:
enum class Mode
{
Extension, // Independent displays
Copy // Mirrored displays
};
explicit OutputLifecycleManager(RootSurfaceContainer *rootContainer,
OutputConfigState *configState,
QObject *parent = nullptr);
~OutputLifecycleManager() = default;
void onScreenAdded(Output *output);
void onScreenRemoved(Output *output, const QList<SurfaceWrapper *> &surfaces,
const QList<SurfaceWrapper *> &allWorkspacesSurfaces);
void onScreenDisabled(Output *output, const QList<SurfaceWrapper *> &surfaces,
const QList<SurfaceWrapper *> &allWorkspacesSurfaces);
void onScreenEnabled(Output *output);
void setMode(Mode mode) {
m_mode = mode;
}
Mode getMode() const {
return m_mode;
}
bool takeCopyModeRestoreIntent() {
bool result = m_copyModeRestoreIntent;
m_copyModeRestoreIntent = false;
return result;
}
private:
RootSurfaceContainer *m_rootContainer = nullptr;
OutputConfigState *m_configState = nullptr;
Mode m_mode = Mode::Extension;
bool m_copyModeRestoreIntent = false;
Output *findFirstAvailableOutput(Output *excludeOutput);
void markScreenAsPrimaryIntent(Output *output);
void restoreScreenAsPrimary(Output *output);
void switchPrimaryOutput(Output *from, Output *to, const QList<SurfaceWrapper *> &surfaces);
void recordSurfaceBindings(const QList<SurfaceWrapper *> &surfaces, Output *sourceOutput);
void restoreSurfaceBindings(Output *targetOutput);
};