Changeset View
Changeset View
Standalone View
Standalone View
src/server/outputdevice_interface.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 36 | public: | |||
---|---|---|---|---|---|
68 | QString model = QStringLiteral("none"); | 68 | QString model = QStringLiteral("none"); | ||
69 | qreal scale = 1.0; | 69 | qreal scale = 1.0; | ||
70 | QString serialNumber; | 70 | QString serialNumber; | ||
71 | QString eisaId; | 71 | QString eisaId; | ||
72 | SubPixel subPixel = SubPixel::Unknown; | 72 | SubPixel subPixel = SubPixel::Unknown; | ||
73 | Transform transform = Transform::Normal; | 73 | Transform transform = Transform::Normal; | ||
74 | ColorCurves colorCurves; | 74 | ColorCurves colorCurves; | ||
75 | QList<Mode> modes; | 75 | QList<Mode> modes; | ||
76 | Mode currentMode; | ||||
76 | QList<ResourceData> resources; | 77 | QList<ResourceData> resources; | ||
77 | 78 | | |||
78 | QByteArray edid; | 79 | QByteArray edid; | ||
79 | Enablement enabled = Enablement::Enabled; | 80 | Enablement enabled = Enablement::Enabled; | ||
80 | QByteArray uuid; | 81 | QByteArray uuid; | ||
81 | 82 | | |||
82 | static OutputDeviceInterface *get(wl_resource *native); | 83 | static OutputDeviceInterface *get(wl_resource *native); | ||
83 | 84 | | |||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 135 | { | |||
135 | Q_D(); | 136 | Q_D(); | ||
136 | connect(this, &OutputDeviceInterface::currentModeChanged, this, | 137 | connect(this, &OutputDeviceInterface::currentModeChanged, this, | ||
137 | [this, d] { | 138 | [this, d] { | ||
138 | auto currentModeIt = std::find_if(d->modes.constBegin(), d->modes.constEnd(), [](const Mode &mode) { return mode.flags.testFlag(ModeFlag::Current); }); | 139 | auto currentModeIt = std::find_if(d->modes.constBegin(), d->modes.constEnd(), [](const Mode &mode) { return mode.flags.testFlag(ModeFlag::Current); }); | ||
139 | if (currentModeIt == d->modes.constEnd()) { | 140 | if (currentModeIt == d->modes.constEnd()) { | ||
140 | return; | 141 | return; | ||
141 | } | 142 | } | ||
142 | for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) { | 143 | for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) { | ||
143 | d->sendMode((*it).resource, *currentModeIt); | 144 | d->sendMode((*it).resource, *currentModeIt); | ||
davidedmundson: we can also just use currentMode directly here and remove the loop above | |||||
romangg: Thanks. Will put it into a second diff. | |||||
See D23535 romangg: See D23535 | |||||
144 | d->sendDone(*it); | 145 | d->sendDone(*it); | ||
145 | } | 146 | } | ||
146 | wl_display_flush_clients(*(d->display)); | 147 | wl_display_flush_clients(*(d->display)); | ||
147 | } | 148 | } | ||
148 | ); | 149 | ); | ||
149 | connect(this, &OutputDeviceInterface::subPixelChanged, this, [this, d] { d->updateGeometry(); }); | 150 | connect(this, &OutputDeviceInterface::subPixelChanged, this, [this, d] { d->updateGeometry(); }); | ||
150 | connect(this, &OutputDeviceInterface::transformChanged, this, [this, d] { d->updateGeometry(); }); | 151 | connect(this, &OutputDeviceInterface::transformChanged, this, [this, d] { d->updateGeometry(); }); | ||
151 | connect(this, &OutputDeviceInterface::globalPositionChanged, this, [this, d] { d->updateGeometry(); }); | 152 | connect(this, &OutputDeviceInterface::globalPositionChanged, this, [this, d] { d->updateGeometry(); }); | ||
152 | connect(this, &OutputDeviceInterface::modelChanged, this, [this, d] { d->updateGeometry(); }); | 153 | connect(this, &OutputDeviceInterface::modelChanged, this, [this, d] { d->updateGeometry(); }); | ||
153 | connect(this, &OutputDeviceInterface::manufacturerChanged, this, [this, d] { d->updateGeometry(); }); | 154 | connect(this, &OutputDeviceInterface::manufacturerChanged, this, [this, d] { d->updateGeometry(); }); | ||
154 | connect(this, &OutputDeviceInterface::scaleFChanged, this, [this, d] { d->updateScale(); }); | 155 | connect(this, &OutputDeviceInterface::scaleFChanged, this, [this, d] { d->updateScale(); }); | ||
155 | connect(this, &OutputDeviceInterface::scaleChanged, this, [this, d] { d->updateScale(); }); | 156 | connect(this, &OutputDeviceInterface::scaleChanged, this, [this, d] { d->updateScale(); }); | ||
156 | connect(this, &OutputDeviceInterface::colorCurvesChanged, this, [this, d] { d->updateColorCurves(); }); | 157 | connect(this, &OutputDeviceInterface::colorCurvesChanged, this, [this, d] { d->updateColorCurves(); }); | ||
157 | } | 158 | } | ||
158 | 159 | | |||
159 | OutputDeviceInterface::~OutputDeviceInterface() = default; | 160 | OutputDeviceInterface::~OutputDeviceInterface() = default; | ||
160 | 161 | | |||
161 | QSize OutputDeviceInterface::pixelSize() const | 162 | QSize OutputDeviceInterface::pixelSize() const | ||
162 | { | 163 | { | ||
163 | Q_D(); | 164 | Q_D(); | ||
164 | auto it = std::find_if(d->modes.begin(), d->modes.end(), | 165 | | ||
165 | [](const Mode &mode) { | 166 | if (d->currentMode.id == -1) { | ||
166 | return mode.flags.testFlag(ModeFlag::Current); | | |||
167 | } | | |||
168 | ); | | |||
169 | if (it == d->modes.end()) { | | |||
170 | return QSize(); | 167 | return QSize(); | ||
171 | } | 168 | } | ||
172 | return (*it).size; | 169 | return d->currentMode.size; | ||
173 | } | 170 | } | ||
174 | 171 | | |||
175 | OutputDeviceInterface *OutputDeviceInterface::get(wl_resource* native) | 172 | OutputDeviceInterface *OutputDeviceInterface::get(wl_resource* native) | ||
176 | { | 173 | { | ||
177 | return Private::get(native); | 174 | return Private::get(native); | ||
178 | } | 175 | } | ||
179 | 176 | | |||
180 | int OutputDeviceInterface::refreshRate() const | 177 | int OutputDeviceInterface::refreshRate() const | ||
181 | { | 178 | { | ||
182 | Q_D(); | 179 | Q_D(); | ||
183 | auto it = std::find_if(d->modes.begin(), d->modes.end(), | 180 | | ||
184 | [](const Mode &mode) { | 181 | if (d->currentMode.id == -1) { | ||
185 | return mode.flags.testFlag(ModeFlag::Current); | | |||
186 | } | | |||
187 | ); | | |||
188 | if (it == d->modes.end()) { | | |||
189 | return 60000; | 182 | return 60000; | ||
190 | } | 183 | } | ||
191 | return (*it).refreshRate; | 184 | return d->currentMode.refreshRate; | ||
192 | } | 185 | } | ||
193 | 186 | | |||
194 | void OutputDeviceInterface::addMode(Mode &mode) | 187 | void OutputDeviceInterface::addMode(Mode &mode) | ||
195 | { | 188 | { | ||
196 | Q_ASSERT(!isValid()); | 189 | Q_ASSERT(!isValid()); | ||
197 | Q_D(); | 190 | Q_D(); | ||
198 | 191 | | |||
199 | 192 | | |||
Show All 25 Lines | |||||
225 | 218 | | |||
226 | auto existingModeIt = std::find_if(d->modes.begin(), d->modes.end(), | 219 | auto existingModeIt = std::find_if(d->modes.begin(), d->modes.end(), | ||
227 | [mode](const Mode &mode_it) { | 220 | [mode](const Mode &mode_it) { | ||
228 | return mode.size == mode_it.size && | 221 | return mode.size == mode_it.size && | ||
229 | mode.refreshRate == mode_it.refreshRate && | 222 | mode.refreshRate == mode_it.refreshRate && | ||
230 | mode.id == mode_it.id; | 223 | mode.id == mode_it.id; | ||
231 | } | 224 | } | ||
232 | ); | 225 | ); | ||
233 | auto emitChanges = [this,mode] { | 226 | auto emitChanges = [this, d, mode] { | ||
234 | emit modesChanged(); | 227 | emit modesChanged(); | ||
235 | if (mode.flags.testFlag(ModeFlag::Current)) { | 228 | if (mode.flags.testFlag(ModeFlag::Current)) { | ||
229 | d->currentMode = mode; | ||||
236 | emit refreshRateChanged(mode.refreshRate); | 230 | emit refreshRateChanged(mode.refreshRate); | ||
237 | emit pixelSizeChanged(mode.size); | 231 | emit pixelSizeChanged(mode.size); | ||
238 | emit currentModeChanged(); | 232 | emit currentModeChanged(); | ||
239 | } | 233 | } | ||
240 | }; | 234 | }; | ||
241 | if (existingModeIt != d->modes.end()) { | 235 | if (existingModeIt != d->modes.end()) { | ||
242 | if ((*existingModeIt).flags == mode.flags) { | 236 | if ((*existingModeIt).flags == mode.flags) { | ||
243 | // nothing to do | 237 | // nothing to do | ||
Show All 34 Lines | 260 | { | |||
278 | auto existingModeIt = std::find_if(d->modes.begin(), d->modes.end(), | 272 | auto existingModeIt = std::find_if(d->modes.begin(), d->modes.end(), | ||
279 | [modeId](const Mode &mode) { | 273 | [modeId](const Mode &mode) { | ||
280 | return mode.id == modeId; | 274 | return mode.id == modeId; | ||
281 | } | 275 | } | ||
282 | ); | 276 | ); | ||
283 | 277 | | |||
284 | Q_ASSERT(existingModeIt != d->modes.end()); | 278 | Q_ASSERT(existingModeIt != d->modes.end()); | ||
285 | (*existingModeIt).flags |= ModeFlag::Current; | 279 | (*existingModeIt).flags |= ModeFlag::Current; | ||
280 | d->currentMode = *existingModeIt; | ||||
286 | emit modesChanged(); | 281 | emit modesChanged(); | ||
287 | emit refreshRateChanged((*existingModeIt).refreshRate); | 282 | emit refreshRateChanged((*existingModeIt).refreshRate); | ||
288 | emit pixelSizeChanged((*existingModeIt).size); | 283 | emit pixelSizeChanged((*existingModeIt).size); | ||
289 | emit currentModeChanged(); | 284 | emit currentModeChanged(); | ||
290 | } | 285 | } | ||
291 | 286 | | |||
292 | int32_t OutputDeviceInterface::Private::toTransform() const | 287 | int32_t OutputDeviceInterface::Private::toTransform() const | ||
293 | { | 288 | { | ||
▲ Show 20 Lines • Show All 456 Lines • Show Last 20 Lines |
we can also just use currentMode directly here and remove the loop above