Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/virtual/virtual_backend.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
63 | #endif | 63 | #endif | ||
64 | if (m_drmFd != -1) { | 64 | if (m_drmFd != -1) { | ||
65 | close(m_drmFd); | 65 | close(m_drmFd); | ||
66 | } | 66 | } | ||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | void VirtualBackend::init() | 69 | void VirtualBackend::init() | ||
70 | { | 70 | { | ||
71 | /* | ||||
72 | * Some tests currently expect one output present at start, | ||||
73 | * others set them explicitly. | ||||
74 | * | ||||
75 | * TODO: rewrite all tests to explicitly set the outputs. | ||||
76 | */ | ||||
77 | if (!m_outputs.size()) { | ||||
78 | auto dummyOutput = VirtualOutput(this); | ||||
79 | dummyOutput.m_geo = QRect(QPoint(0, 0), initialWindowSize()); | ||||
80 | m_outputs = { dummyOutput }; | ||||
81 | } | ||||
82 | | ||||
83 | | ||||
71 | setSoftWareCursor(true); | 84 | setSoftWareCursor(true); | ||
72 | m_size = initialWindowSize(); | | |||
73 | setReady(true); | 85 | setReady(true); | ||
74 | waylandServer()->seat()->setHasPointer(true); | 86 | waylandServer()->seat()->setHasPointer(true); | ||
75 | waylandServer()->seat()->setHasKeyboard(true); | 87 | waylandServer()->seat()->setHasKeyboard(true); | ||
76 | waylandServer()->seat()->setHasTouch(true); | 88 | waylandServer()->seat()->setHasTouch(true); | ||
89 | | ||||
77 | emit screensQueried(); | 90 | emit screensQueried(); | ||
78 | } | 91 | } | ||
79 | 92 | | |||
80 | QString VirtualBackend::screenshotDirPath() const | 93 | QString VirtualBackend::screenshotDirPath() const | ||
81 | { | 94 | { | ||
82 | if (m_screenshotDir.isNull()) { | 95 | if (m_screenshotDir.isNull()) { | ||
83 | return QString(); | 96 | return QString(); | ||
84 | } | 97 | } | ||
Show All 10 Lines | 107 | { | |||
95 | return new VirtualQPainterBackend(this); | 108 | return new VirtualQPainterBackend(this); | ||
96 | } | 109 | } | ||
97 | 110 | | |||
98 | OpenGLBackend *VirtualBackend::createOpenGLBackend() | 111 | OpenGLBackend *VirtualBackend::createOpenGLBackend() | ||
99 | { | 112 | { | ||
100 | return new EglGbmBackend(this); | 113 | return new EglGbmBackend(this); | ||
101 | } | 114 | } | ||
102 | 115 | | |||
116 | void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries) | ||||
117 | { | ||||
118 | Q_ASSERT(geometries.size() == 0 || geometries.size() == count); | ||||
119 | | ||||
120 | bool countChanged = m_outputs.size() != count; | ||||
121 | m_outputs.resize(count); | ||||
122 | | ||||
123 | int sumWidth = 0; | ||||
124 | for (int i = 0; i < count; i++) { | ||||
125 | VirtualOutput& o = m_outputs[i]; | ||||
126 | if (geometries.size()) { | ||||
127 | o.m_geo = geometries.at(i); | ||||
128 | } else if (!o.m_geo.isValid()) { | ||||
129 | o.m_geo = QRect(QPoint(sumWidth, 0), initialWindowSize()); | ||||
130 | sumWidth += o.m_geo.width(); | ||||
131 | } | ||||
132 | } | ||||
133 | | ||||
134 | emit virtualOutputsSet(countChanged); | ||||
135 | } | ||||
136 | | ||||
103 | int VirtualBackend::gammaRampSize(int screen) const { | 137 | int VirtualBackend::gammaRampSize(int screen) const { | ||
104 | return m_gammaSizes[screen]; | 138 | return m_outputs[screen].m_gammaSize; | ||
105 | } | 139 | } | ||
106 | 140 | | |||
107 | bool VirtualBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) { | 141 | bool VirtualBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) { | ||
108 | Q_UNUSED(gamma); | 142 | Q_UNUSED(gamma); | ||
109 | return m_gammaResults[screen]; | 143 | return m_outputs[screen].m_gammaResult; | ||
110 | } | 144 | } | ||
111 | 145 | | |||
112 | } | 146 | } |