Changeset View
Standalone View
plugins/platforms/drm/drm_backend.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 84 | if (m_gbmDevice) { | |||
---|---|---|---|---|---|
85 | gbm_device_destroy(m_gbmDevice); | 85 | gbm_device_destroy(m_gbmDevice); | ||
86 | } | 86 | } | ||
87 | #endif | 87 | #endif | ||
88 | if (m_fd >= 0) { | 88 | if (m_fd >= 0) { | ||
89 | // wait for pageflips | 89 | // wait for pageflips | ||
90 | while (m_pageFlipsPending != 0) { | 90 | while (m_pageFlipsPending != 0) { | ||
91 | QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); | 91 | QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); | ||
92 | } | 92 | } | ||
93 | // we need to first remove all outputs | ||||
93 | qDeleteAll(m_outputs); | 94 | qDeleteAll(m_outputs); | ||
95 | m_outputs.clear(); | ||||
96 | | ||||
94 | qDeleteAll(m_planes); | 97 | qDeleteAll(m_planes); | ||
95 | qDeleteAll(m_crtcs); | 98 | qDeleteAll(m_crtcs); | ||
96 | qDeleteAll(m_connectors); | 99 | qDeleteAll(m_connectors); | ||
97 | close(m_fd); | 100 | close(m_fd); | ||
98 | } | 101 | } | ||
99 | } | 102 | } | ||
100 | 103 | | |||
101 | void DrmBackend::init() | 104 | void DrmBackend::init() | ||
Show All 23 Lines | 123 | { | |||
125 | m_dpmsFilter.reset(new DpmsInputEventFilter(this)); | 128 | m_dpmsFilter.reset(new DpmsInputEventFilter(this)); | ||
126 | input()->prependInputEventFilter(m_dpmsFilter.data()); | 129 | input()->prependInputEventFilter(m_dpmsFilter.data()); | ||
127 | } | 130 | } | ||
128 | 131 | | |||
129 | void DrmBackend::turnOutputsOn() | 132 | void DrmBackend::turnOutputsOn() | ||
130 | { | 133 | { | ||
131 | m_dpmsFilter.reset(); | 134 | m_dpmsFilter.reset(); | ||
132 | for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { | 135 | for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { | ||
133 | (*it)->setDpms(DrmOutput::DpmsMode::On); | 136 | auto *o = static_cast<DrmOutput*>(*it); | ||
137 | o->setDpms(DrmOutput::DpmsMode::On); | ||||
graesslin: static_cast? That sounds wrong. I doubt you need it. Just do:
```
auto o = *it;
``` | |||||
134 | } | 138 | } | ||
135 | } | 139 | } | ||
136 | 140 | | |||
137 | void DrmBackend::checkOutputsAreOn() | 141 | void DrmBackend::checkOutputsAreOn() | ||
138 | { | 142 | { | ||
139 | if (m_dpmsFilter.isNull()) { | 143 | if (m_dpmsFilter.isNull()) { | ||
140 | // already disabled, all outputs are on | 144 | // already disabled, all outputs are on | ||
141 | return; | 145 | return; | ||
142 | } | 146 | } | ||
143 | for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { | 147 | for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { | ||
144 | if (!(*it)->isDpmsEnabled()) { | 148 | auto *o = static_cast<DrmOutput*>(*it); | ||
149 | if (!o->isDpmsEnabled()) { | ||||
graesslin: same here, static_cast looks wrong | |||||
145 | // dpms still disabled, need to keep the filter | 150 | // dpms still disabled, need to keep the filter | ||
146 | return; | 151 | return; | ||
147 | } | 152 | } | ||
148 | } | 153 | } | ||
149 | // all outputs are on, disable the filter | 154 | // all outputs are on, disable the filter | ||
150 | m_dpmsFilter.reset(); | 155 | m_dpmsFilter.reset(); | ||
151 | } | 156 | } | ||
152 | 157 | | |||
Show All 12 Lines | |||||
165 | { | 170 | { | ||
166 | if (m_active) { | 171 | if (m_active) { | ||
167 | return; | 172 | return; | ||
168 | } | 173 | } | ||
169 | m_active = true; | 174 | m_active = true; | ||
170 | if (!usesSoftwareCursor()) { | 175 | if (!usesSoftwareCursor()) { | ||
171 | const QPoint cp = Cursor::pos() - softwareCursorHotspot(); | 176 | const QPoint cp = Cursor::pos() - softwareCursorHotspot(); | ||
172 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 177 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
173 | DrmOutput *o = *it; | 178 | auto *o = static_cast<DrmOutput*>(*it); | ||
zzag: You could use `auto`. ;-) | |||||
graesslin: here as well the static cast looks like not needed | |||||
174 | // only relevant in atomic mode | 179 | // only relevant in atomic mode | ||
175 | o->m_modesetRequested = true; | 180 | o->m_modesetRequested = true; | ||
176 | o->pageFlipped(); // TODO: Do we really need this? | 181 | o->pageFlipped(); // TODO: Do we really need this? | ||
177 | o->m_crtc->blank(); | 182 | o->m_crtc->blank(); | ||
178 | o->showCursor(); | 183 | o->showCursor(); | ||
179 | o->moveCursor(cp); | 184 | o->moveCursor(cp); | ||
180 | } | 185 | } | ||
181 | } | 186 | } | ||
Show All 11 Lines | 197 | if (!m_active) { | |||
193 | return; | 198 | return; | ||
194 | } | 199 | } | ||
195 | // block compositor | 200 | // block compositor | ||
196 | if (m_pageFlipsPending == 0 && Compositor::self()) { | 201 | if (m_pageFlipsPending == 0 && Compositor::self()) { | ||
197 | Compositor::self()->aboutToSwapBuffers(); | 202 | Compositor::self()->aboutToSwapBuffers(); | ||
198 | } | 203 | } | ||
199 | // hide cursor and disable | 204 | // hide cursor and disable | ||
200 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 205 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
201 | DrmOutput *o = *it; | 206 | auto *o = static_cast<DrmOutput*>(*it); | ||
graesslin: and here as well | |||||
202 | o->hideCursor(); | 207 | o->hideCursor(); | ||
203 | } | 208 | } | ||
204 | m_active = false; | 209 | m_active = false; | ||
205 | } | 210 | } | ||
206 | 211 | | |||
207 | void DrmBackend::pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) | 212 | void DrmBackend::pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) | ||
208 | { | 213 | { | ||
209 | Q_UNUSED(fd) | 214 | Q_UNUSED(fd) | ||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | 370 | { | |||
368 | } | 373 | } | ||
369 | 374 | | |||
370 | ScopedDrmPointer<_drmModeRes, &drmModeFreeResources> resources(drmModeGetResources(m_fd)); | 375 | ScopedDrmPointer<_drmModeRes, &drmModeFreeResources> resources(drmModeGetResources(m_fd)); | ||
371 | if (!resources) { | 376 | if (!resources) { | ||
372 | qCWarning(KWIN_DRM) << "drmModeGetResources failed"; | 377 | qCWarning(KWIN_DRM) << "drmModeGetResources failed"; | ||
373 | return; | 378 | return; | ||
374 | } | 379 | } | ||
375 | 380 | | |||
376 | QVector<DrmOutput*> connectedOutputs; | 381 | QVector<Output*> connectedOutputs; | ||
I don't understand why you changed from QVector<DrmOutput*> to QVector<Output*>. The list still gets filled with DrmOutput and afterwards you make your life hard by having to static_cast back to DrmOutput. graesslin: I don't understand why you changed from QVector<DrmOutput*> to QVector<Output*>. The list still… | |||||
377 | QVector<DrmConnector*> pendingConnectors; | 382 | QVector<DrmConnector*> pendingConnectors; | ||
378 | 383 | | |||
379 | // split up connected connectors in already or not yet assigned ones | 384 | // split up connected connectors in already or not yet assigned ones | ||
380 | for (DrmConnector *con : qAsConst(m_connectors)) { | 385 | for (DrmConnector *con : qAsConst(m_connectors)) { | ||
381 | if (!con->isConnected()) { | 386 | if (!con->isConnected()) { | ||
382 | continue; | 387 | continue; | ||
383 | } | 388 | } | ||
384 | 389 | | |||
385 | if (DrmOutput *o = findOutput(con->id())) { | 390 | if (DrmOutput *o = findOutput(con->id())) { | ||
386 | connectedOutputs << o; | 391 | connectedOutputs << o; | ||
387 | } else { | 392 | } else { | ||
388 | pendingConnectors << con; | 393 | pendingConnectors << con; | ||
389 | } | 394 | } | ||
390 | } | 395 | } | ||
391 | 396 | | |||
392 | // check for outputs which got removed | 397 | // check for outputs which got removed | ||
393 | auto it = m_outputs.begin(); | 398 | auto it = m_outputs.begin(); | ||
394 | while (it != m_outputs.end()) { | 399 | while (it != m_outputs.end()) { | ||
395 | if (connectedOutputs.contains(*it)) { | 400 | Output *o = *it; | ||
401 | if (connectedOutputs.contains(o)) { | ||||
396 | it++; | 402 | it++; | ||
397 | continue; | 403 | continue; | ||
398 | } | 404 | } | ||
399 | DrmOutput *removed = *it; | | |||
400 | it = m_outputs.erase(it); | 405 | it = m_outputs.erase(it); | ||
401 | m_enabledOutputs.removeOne(removed); | 406 | m_enabledOutputs.removeOne(o); | ||
402 | emit outputRemoved(removed); | 407 | emit outputRemoved(static_cast<DrmOutput*>(o)); | ||
Please no static_casts. Either change the signature of outputRemoved signal or do a safe cast like qobject_cast or dynamic_cast. Static_cast is evil :-) graesslin: Please no static_casts. Either change the signature of outputRemoved signal or do a safe cast… | |||||
403 | delete removed; | 408 | delete o; | ||
404 | } | 409 | } | ||
405 | 410 | | |||
406 | // now check new connections | 411 | // now check new connections | ||
407 | for (DrmConnector *con : qAsConst(pendingConnectors)) { | 412 | for (DrmConnector *con : qAsConst(pendingConnectors)) { | ||
408 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> connector(drmModeGetConnector(m_fd, con->id())); | 413 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> connector(drmModeGetConnector(m_fd, con->id())); | ||
409 | if (!connector) { | 414 | if (!connector) { | ||
410 | continue; | 415 | continue; | ||
411 | } | 416 | } | ||
Show All 10 Lines | 423 | for (auto encId : qAsConst(encoders)) { | |||
422 | } | 427 | } | ||
423 | for (DrmCrtc *crtc : qAsConst(m_crtcs)) { | 428 | for (DrmCrtc *crtc : qAsConst(m_crtcs)) { | ||
424 | if (!(encoder->possible_crtcs & (1 << crtc->resIndex()))) { | 429 | if (!(encoder->possible_crtcs & (1 << crtc->resIndex()))) { | ||
425 | continue; | 430 | continue; | ||
426 | } | 431 | } | ||
427 | 432 | | |||
428 | // check if crtc isn't used yet -- currently we don't allow multiple outputs on one crtc (cloned mode) | 433 | // check if crtc isn't used yet -- currently we don't allow multiple outputs on one crtc (cloned mode) | ||
429 | auto it = std::find_if(connectedOutputs.constBegin(), connectedOutputs.constEnd(), | 434 | auto it = std::find_if(connectedOutputs.constBegin(), connectedOutputs.constEnd(), | ||
430 | [crtc] (DrmOutput *o) { | 435 | [crtc] (Output *o) { | ||
431 | return o->m_crtc == crtc; | 436 | return static_cast<DrmOutput*>(o)->m_crtc == crtc; | ||
If connectedOutputs would still be QVector<DrmOutput*> you would not need the cast here. graesslin: If connectedOutputs would still be QVector<DrmOutput*> you would not need the cast here. | |||||
432 | } | 437 | } | ||
433 | ); | 438 | ); | ||
434 | if (it != connectedOutputs.constEnd()) { | 439 | if (it != connectedOutputs.constEnd()) { | ||
435 | continue; | 440 | continue; | ||
436 | } | 441 | } | ||
437 | 442 | | |||
438 | // we found a suitable encoder+crtc | 443 | // we found a suitable encoder+crtc | ||
439 | // TODO: we could avoid these lib drm calls if we store all struct data in DrmCrtc and DrmConnector in the beginning | 444 | // TODO: we could avoid these lib drm calls if we store all struct data in DrmCrtc and DrmConnector in the beginning | ||
Show All 31 Lines | |||||
471 | outputDone = true; | 476 | outputDone = true; | ||
472 | break; | 477 | break; | ||
473 | } | 478 | } | ||
474 | if (outputDone) { | 479 | if (outputDone) { | ||
475 | break; | 480 | break; | ||
476 | } | 481 | } | ||
477 | } | 482 | } | ||
478 | } | 483 | } | ||
479 | std::sort(connectedOutputs.begin(), connectedOutputs.end(), [] (DrmOutput *a, DrmOutput *b) { return a->m_conn->id() < b->m_conn->id(); }); | 484 | std::sort(connectedOutputs.begin(), connectedOutputs.end(), [] (Output *a, Output *b) { | ||
485 | return static_cast<DrmOutput*>(a)->m_conn->id() < static_cast<DrmOutput*>(b)->m_conn->id(); | ||||
486 | }); | ||||
480 | m_outputs = connectedOutputs; | 487 | m_outputs = connectedOutputs; | ||
same here. The change would not be needed if the signature were not changed. graesslin: same here. The change would not be needed if the signature were not changed. | |||||
481 | m_enabledOutputs = connectedOutputs; | 488 | m_enabledOutputs = connectedOutputs; | ||
482 | readOutputsConfiguration(); | 489 | readOutputsConfiguration(); | ||
483 | if (!m_outputs.isEmpty()) { | 490 | if (!m_outputs.isEmpty()) { | ||
484 | emit screensQueried(); | 491 | emit screensQueried(); | ||
485 | } | 492 | } | ||
486 | } | 493 | } | ||
487 | 494 | | |||
488 | void DrmBackend::readOutputsConfiguration() | 495 | void DrmBackend::readOutputsConfiguration() | ||
489 | { | 496 | { | ||
490 | if (m_outputs.isEmpty()) { | 497 | if (m_outputs.isEmpty()) { | ||
491 | return; | 498 | return; | ||
492 | } | 499 | } | ||
493 | const QByteArray uuid = generateOutputConfigurationUuid(); | 500 | const QByteArray uuid = generateOutputConfigurationUuid(); | ||
494 | const auto outputGroup = kwinApp()->config()->group("DrmOutputs"); | 501 | const auto outputGroup = kwinApp()->config()->group("DrmOutputs"); | ||
495 | const auto configGroup = outputGroup.group(uuid); | 502 | const auto configGroup = outputGroup.group(uuid); | ||
496 | // default position goes from left to right | 503 | // default position goes from left to right | ||
497 | QPoint pos(0, 0); | 504 | QPoint pos(0, 0); | ||
498 | for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) { | 505 | for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) { | ||
499 | qCDebug(KWIN_DRM) << "Reading output configuration for [" << uuid << "] ["<< (*it)->uuid() << "]"; | 506 | auto *o = static_cast<DrmOutput*>(*it); | ||
500 | const auto outputConfig = configGroup.group((*it)->uuid()); | 507 | qCDebug(KWIN_DRM) << "Reading output configuration for [" << uuid << "] ["<< o->uuid() << "]"; | ||
501 | (*it)->setGlobalPos(outputConfig.readEntry<QPoint>("Position", pos)); | 508 | const auto outputConfig = configGroup.group(o->uuid()); | ||
509 | o->setGlobalPos(outputConfig.readEntry<QPoint>("Position", pos)); | ||||
Please don't hide pointer under auto. Make it explicit, e.g. auto *o = qobject_cast<DrmOutput*>(*it); That will improve readability a little bit. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html zzag: Please don't hide pointer under `auto`. Make it explicit, e.g.
```lang=cpp
auto *o =… | |||||
graesslin: please a safe cast like qobject_cast or dynamic_cast | |||||
502 | // TODO: add mode | 510 | // TODO: add mode | ||
503 | (*it)->setScale(outputConfig.readEntry("Scale", 1.0)); | 511 | o->setScale(outputConfig.readEntry("Scale", 1.0)); | ||
504 | pos.setX(pos.x() + (*it)->geometry().width()); | 512 | pos.setX(pos.x() + o->geometry().width()); | ||
505 | } | 513 | } | ||
506 | } | 514 | } | ||
507 | 515 | | |||
508 | QByteArray DrmBackend::generateOutputConfigurationUuid() const | 516 | QByteArray DrmBackend::generateOutputConfigurationUuid() const | ||
509 | { | 517 | { | ||
510 | auto it = m_outputs.constBegin(); | 518 | auto it = m_outputs.constBegin(); | ||
511 | if (m_outputs.size() == 1) { | 519 | if (m_outputs.size() == 1) { | ||
512 | // special case: one output | 520 | // special case: one output | ||
513 | return (*it)->uuid(); | 521 | return static_cast<DrmOutput*>(*it)->uuid(); | ||
graesslin: same here | |||||
514 | } | 522 | } | ||
515 | QCryptographicHash hash(QCryptographicHash::Md5); | 523 | QCryptographicHash hash(QCryptographicHash::Md5); | ||
516 | for (; it != m_outputs.constEnd(); ++it) { | 524 | for (; it != m_outputs.constEnd(); ++it) { | ||
517 | hash.addData((*it)->uuid()); | 525 | auto *o = static_cast<DrmOutput*>(*it); | ||
526 | hash.addData(o->uuid()); | ||||
graesslin: and here | |||||
518 | } | 527 | } | ||
519 | return hash.result().toHex().left(10); | 528 | return hash.result().toHex().left(10); | ||
520 | } | 529 | } | ||
521 | 530 | | |||
522 | void DrmBackend::configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) | 531 | void DrmBackend::configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) | ||
523 | { | 532 | { | ||
524 | const auto changes = config->changes(); | 533 | const auto changes = config->changes(); | ||
525 | bool countChanged = false; | 534 | bool countChanged = false; | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
569 | // KCoreAddons needs kwayland's 2b3f9509ac1 to not crash | 578 | // KCoreAddons needs kwayland's 2b3f9509ac1 to not crash | ||
570 | if (KCoreAddons::version() >= QT_VERSION_CHECK(5, 39, 0)) { | 579 | if (KCoreAddons::version() >= QT_VERSION_CHECK(5, 39, 0)) { | ||
571 | config->setApplied(); | 580 | config->setApplied(); | ||
572 | } | 581 | } | ||
573 | } | 582 | } | ||
574 | 583 | | |||
575 | DrmOutput *DrmBackend::findOutput(quint32 connector) | 584 | DrmOutput *DrmBackend::findOutput(quint32 connector) | ||
576 | { | 585 | { | ||
577 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (DrmOutput *o) { | 586 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (Output *o) { | ||
578 | return o->m_conn->id() == connector; | 587 | return static_cast<DrmOutput*>(o)->m_conn->id() == connector; | ||
579 | }); | 588 | }); | ||
580 | if (it != m_outputs.constEnd()) { | 589 | if (it != m_outputs.constEnd()) { | ||
581 | return *it; | 590 | return static_cast<DrmOutput*>(*it); | ||
582 | } | 591 | } | ||
583 | return nullptr; | 592 | return nullptr; | ||
584 | } | 593 | } | ||
585 | 594 | | |||
586 | DrmOutput *DrmBackend::findOutput(const QByteArray &uuid) | 595 | DrmOutput *DrmBackend::findOutput(const QByteArray &uuid) | ||
587 | { | 596 | { | ||
588 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [uuid] (DrmOutput *o) { | 597 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [uuid] (Output *o) { | ||
589 | return o->m_uuid == uuid; | 598 | return static_cast<DrmOutput*>(o)->m_uuid == uuid; | ||
590 | }); | 599 | }); | ||
591 | if (it != m_outputs.constEnd()) { | 600 | if (it != m_outputs.constEnd()) { | ||
592 | return *it; | 601 | return static_cast<DrmOutput*>(*it); | ||
593 | } | 602 | } | ||
594 | return nullptr; | 603 | return nullptr; | ||
595 | } | 604 | } | ||
596 | 605 | | |||
597 | void DrmBackend::present(DrmBuffer *buffer, DrmOutput *output) | 606 | void DrmBackend::present(DrmBuffer *buffer, DrmOutput *output) | ||
598 | { | 607 | { | ||
599 | if (!buffer || buffer->bufferId() == 0) { | 608 | if (!buffer || buffer->bufferId() == 0) { | ||
600 | if (m_deleteBufferAfterPageFlip) { | 609 | if (m_deleteBufferAfterPageFlip) { | ||
Show All 17 Lines | 626 | { | |||
618 | m_cursorEnabled = waylandServer()->seat()->hasPointer(); | 627 | m_cursorEnabled = waylandServer()->seat()->hasPointer(); | ||
619 | connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::hasPointerChanged, this, | 628 | connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::hasPointerChanged, this, | ||
620 | [this] { | 629 | [this] { | ||
621 | m_cursorEnabled = waylandServer()->seat()->hasPointer(); | 630 | m_cursorEnabled = waylandServer()->seat()->hasPointer(); | ||
622 | if (usesSoftwareCursor()) { | 631 | if (usesSoftwareCursor()) { | ||
623 | return; | 632 | return; | ||
624 | } | 633 | } | ||
625 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 634 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
635 | auto *o = static_cast<DrmOutput*>(*it); | ||||
626 | if (m_cursorEnabled) { | 636 | if (m_cursorEnabled) { | ||
627 | if (!(*it)->showCursor()) { | 637 | if (!o->showCursor()) { | ||
628 | setSoftWareCursor(true); | 638 | setSoftWareCursor(true); | ||
629 | } | 639 | } | ||
630 | } else { | 640 | } else { | ||
631 | (*it)->hideCursor(); | 641 | o->hideCursor(); | ||
632 | } | 642 | } | ||
633 | } | 643 | } | ||
634 | } | 644 | } | ||
635 | ); | 645 | ); | ||
636 | uint64_t capability = 0; | 646 | uint64_t capability = 0; | ||
637 | QSize cursorSize; | 647 | QSize cursorSize; | ||
638 | if (drmGetCap(m_fd, DRM_CAP_CURSOR_WIDTH, &capability) == 0) { | 648 | if (drmGetCap(m_fd, DRM_CAP_CURSOR_WIDTH, &capability) == 0) { | ||
639 | cursorSize.setWidth(capability); | 649 | cursorSize.setWidth(capability); | ||
Show All 10 Lines | |||||
650 | connect(this, &DrmBackend::cursorChanged, this, &DrmBackend::updateCursor); | 660 | connect(this, &DrmBackend::cursorChanged, this, &DrmBackend::updateCursor); | ||
651 | connect(Cursor::self(), &Cursor::posChanged, this, &DrmBackend::moveCursor); | 661 | connect(Cursor::self(), &Cursor::posChanged, this, &DrmBackend::moveCursor); | ||
652 | } | 662 | } | ||
653 | 663 | | |||
654 | void DrmBackend::setCursor() | 664 | void DrmBackend::setCursor() | ||
655 | { | 665 | { | ||
656 | if (m_cursorEnabled) { | 666 | if (m_cursorEnabled) { | ||
657 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 667 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
658 | if (!(*it)->showCursor()) { | 668 | auto *o = static_cast<DrmOutput*>(*it); | ||
669 | if (!o->showCursor()) { | ||||
659 | setSoftWareCursor(true); | 670 | setSoftWareCursor(true); | ||
660 | } | 671 | } | ||
661 | } | 672 | } | ||
662 | } | 673 | } | ||
663 | markCursorAsRendered(); | 674 | markCursorAsRendered(); | ||
664 | } | 675 | } | ||
665 | 676 | | |||
666 | void DrmBackend::updateCursor() | 677 | void DrmBackend::updateCursor() | ||
667 | { | 678 | { | ||
668 | if (usesSoftwareCursor()) { | 679 | if (usesSoftwareCursor()) { | ||
669 | return; | 680 | return; | ||
670 | } | 681 | } | ||
671 | if (isCursorHidden()) { | 682 | if (isCursorHidden()) { | ||
672 | return; | 683 | return; | ||
673 | } | 684 | } | ||
674 | const QImage &cursorImage = softwareCursor(); | 685 | const QImage &cursorImage = softwareCursor(); | ||
675 | if (cursorImage.isNull()) { | 686 | if (cursorImage.isNull()) { | ||
676 | doHideCursor(); | 687 | doHideCursor(); | ||
677 | return; | 688 | return; | ||
678 | } | 689 | } | ||
679 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 690 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
680 | (*it)->updateCursor(); | 691 | auto *o = static_cast<DrmOutput*>(*it); | ||
692 | o->updateCursor(); | ||||
681 | } | 693 | } | ||
682 | 694 | | |||
683 | setCursor(); | 695 | setCursor(); | ||
684 | moveCursor(); | 696 | moveCursor(); | ||
685 | } | 697 | } | ||
686 | 698 | | |||
687 | void DrmBackend::doShowCursor() | 699 | void DrmBackend::doShowCursor() | ||
688 | { | 700 | { | ||
689 | updateCursor(); | 701 | updateCursor(); | ||
690 | } | 702 | } | ||
691 | 703 | | |||
692 | void DrmBackend::doHideCursor() | 704 | void DrmBackend::doHideCursor() | ||
693 | { | 705 | { | ||
694 | if (!m_cursorEnabled) { | 706 | if (!m_cursorEnabled) { | ||
695 | return; | 707 | return; | ||
696 | } | 708 | } | ||
697 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 709 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
698 | (*it)->hideCursor(); | 710 | auto *o = static_cast<DrmOutput*>(*it); | ||
711 | o->hideCursor(); | ||||
699 | } | 712 | } | ||
700 | } | 713 | } | ||
701 | 714 | | |||
702 | void DrmBackend::moveCursor() | 715 | void DrmBackend::moveCursor() | ||
703 | { | 716 | { | ||
704 | if (!m_cursorEnabled || isCursorHidden()) { | 717 | if (!m_cursorEnabled || isCursorHidden()) { | ||
705 | return; | 718 | return; | ||
706 | } | 719 | } | ||
707 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 720 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
708 | (*it)->moveCursor(Cursor::pos()); | 721 | auto *o = static_cast<DrmOutput*>(*it); | ||
722 | o->moveCursor(Cursor::pos()); | ||||
709 | } | 723 | } | ||
710 | } | 724 | } | ||
711 | 725 | | |||
712 | Screens *DrmBackend::createScreens(QObject *parent) | 726 | Screens *DrmBackend::createScreens(QObject *parent) | ||
713 | { | 727 | { | ||
714 | return new DrmScreens(this, parent); | 728 | return new DrmScreens(this, parent); | ||
715 | } | 729 | } | ||
716 | 730 | | |||
Show All 29 Lines | |||||
746 | 760 | | |||
747 | void DrmBackend::outputDpmsChanged() | 761 | void DrmBackend::outputDpmsChanged() | ||
748 | { | 762 | { | ||
749 | if (m_enabledOutputs.isEmpty()) { | 763 | if (m_enabledOutputs.isEmpty()) { | ||
750 | return; | 764 | return; | ||
751 | } | 765 | } | ||
752 | bool enabled = false; | 766 | bool enabled = false; | ||
753 | for (auto it = m_enabledOutputs.constBegin(); it != m_enabledOutputs.constEnd(); ++it) { | 767 | for (auto it = m_enabledOutputs.constBegin(); it != m_enabledOutputs.constEnd(); ++it) { | ||
754 | enabled = enabled || (*it)->isDpmsEnabled(); | 768 | auto *o = static_cast<DrmOutput*>(*it); | ||
769 | enabled = enabled || o->isDpmsEnabled(); | ||||
755 | } | 770 | } | ||
756 | setOutputsEnabled(enabled); | 771 | setOutputsEnabled(enabled); | ||
757 | } | 772 | } | ||
758 | 773 | | |||
759 | QVector<CompositingType> DrmBackend::supportedCompositors() const | 774 | QVector<CompositingType> DrmBackend::supportedCompositors() const | ||
760 | { | 775 | { | ||
761 | #if HAVE_GBM | 776 | #if HAVE_GBM | ||
762 | return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing}; | 777 | return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing}; | ||
763 | #else | 778 | #else | ||
764 | return QVector<CompositingType>{QPainterCompositing}; | 779 | return QVector<CompositingType>{QPainterCompositing}; | ||
765 | #endif | 780 | #endif | ||
766 | } | 781 | } | ||
767 | 782 | | |||
768 | int DrmBackend::gammaRampSize(int screen) const | 783 | int DrmBackend::gammaRampSize(int screen) const | ||
769 | { | 784 | { | ||
770 | if (m_outputs.size() <= screen) { | 785 | if (m_outputs.size() <= screen) { | ||
771 | return 0; | 786 | return 0; | ||
772 | } | 787 | } | ||
773 | return m_outputs.at(screen)->m_crtc->getGammaRampSize(); | 788 | auto *o = static_cast<DrmOutput*>(m_outputs.at(screen)); | ||
789 | return o->m_crtc->getGammaRampSize(); | ||||
774 | } | 790 | } | ||
775 | 791 | | |||
776 | bool DrmBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) | 792 | bool DrmBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) | ||
777 | { | 793 | { | ||
778 | if (m_outputs.size() <= screen) { | 794 | if (m_outputs.size() <= screen) { | ||
779 | return false; | 795 | return false; | ||
780 | } | 796 | } | ||
781 | return m_outputs.at(screen)->m_crtc->setGammaRamp(gamma); | 797 | auto *o = static_cast<DrmOutput*>(m_outputs.at(screen)); | ||
798 | return o->m_crtc->setGammaRamp(gamma); | ||||
782 | } | 799 | } | ||
783 | 800 | | |||
784 | QString DrmBackend::supportInformation() const | 801 | QString DrmBackend::supportInformation() const | ||
785 | { | 802 | { | ||
786 | QString supportInfo; | 803 | QString supportInfo; | ||
787 | QDebug s(&supportInfo); | 804 | QDebug s(&supportInfo); | ||
788 | s.nospace(); | 805 | s.nospace(); | ||
789 | s << "Name: " << "DRM" << endl; | 806 | s << "Name: " << "DRM" << endl; | ||
790 | s << "Active: " << m_active << endl; | 807 | s << "Active: " << m_active << endl; | ||
791 | s << "Atomic Mode Setting: " << m_atomicModeSetting << endl; | 808 | s << "Atomic Mode Setting: " << m_atomicModeSetting << endl; | ||
792 | return supportInfo; | 809 | return supportInfo; | ||
793 | } | 810 | } | ||
794 | 811 | | |||
795 | } | 812 | } |
static_cast? That sounds wrong. I doubt you need it. Just do: