Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_backend.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | |||||
189 | 189 | | |||
190 | void DrmBackend::reactivate() | 190 | void DrmBackend::reactivate() | ||
191 | { | 191 | { | ||
192 | if (m_active) { | 192 | if (m_active) { | ||
193 | return; | 193 | return; | ||
194 | } | 194 | } | ||
195 | m_active = true; | 195 | m_active = true; | ||
196 | if (!usesSoftwareCursor()) { | 196 | if (!usesSoftwareCursor()) { | ||
197 | const QPoint cp = Cursor::pos() - softwareCursorHotspot(); | 197 | Cursor* cursor = Cursors::self()->mouse(); | ||
198 | const QPoint cp = cursor->pos() - cursor->hotspot(); | ||||
198 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 199 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
199 | DrmOutput *o = *it; | 200 | DrmOutput *o = *it; | ||
200 | // only relevant in atomic mode | 201 | // only relevant in atomic mode | ||
201 | o->m_modesetRequested = true; | 202 | o->m_modesetRequested = true; | ||
202 | o->m_crtc->blank(); | 203 | o->m_crtc->blank(); | ||
203 | o->showCursor(); | 204 | o->showCursor(); | ||
204 | o->moveCursor(cp); | 205 | o->moveCursor(cursor, cp); | ||
205 | } | 206 | } | ||
206 | } | 207 | } | ||
207 | // restart compositor | 208 | // restart compositor | ||
208 | m_pageFlipsPending = 0; | 209 | m_pageFlipsPending = 0; | ||
209 | if (Compositor *compositor = Compositor::self()) { | 210 | if (Compositor *compositor = Compositor::self()) { | ||
210 | compositor->bufferSwapComplete(); | 211 | compositor->bufferSwapComplete(); | ||
211 | compositor->addRepaintFull(); | 212 | compositor->addRepaintFull(); | ||
212 | } | 213 | } | ||
▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Line(s) | 617 | #endif | |||
642 | } | 643 | } | ||
643 | if (drmGetCap(m_fd, DRM_CAP_CURSOR_HEIGHT, &capability) == 0) { | 644 | if (drmGetCap(m_fd, DRM_CAP_CURSOR_HEIGHT, &capability) == 0) { | ||
644 | cursorSize.setHeight(capability); | 645 | cursorSize.setHeight(capability); | ||
645 | } else { | 646 | } else { | ||
646 | cursorSize.setHeight(64); | 647 | cursorSize.setHeight(64); | ||
647 | } | 648 | } | ||
648 | m_cursorSize = cursorSize; | 649 | m_cursorSize = cursorSize; | ||
649 | // now we have screens and can set cursors, so start tracking | 650 | // now we have screens and can set cursors, so start tracking | ||
650 | connect(this, &DrmBackend::cursorChanged, this, &DrmBackend::updateCursor); | 651 | connect(Cursors::self(), &Cursors::currentCursorChanged, this, &DrmBackend::updateCursor); | ||
651 | connect(Cursor::self(), &Cursor::posChanged, this, &DrmBackend::moveCursor); | 652 | connect(Cursors::self(), &Cursors::positionChanged, this, &DrmBackend::moveCursor); | ||
652 | } | 653 | } | ||
653 | 654 | | |||
654 | void DrmBackend::setCursor() | 655 | void DrmBackend::setCursor() | ||
655 | { | 656 | { | ||
656 | if (m_cursorEnabled) { | 657 | if (m_cursorEnabled) { | ||
657 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 658 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
658 | if (!(*it)->showCursor()) { | 659 | if (!(*it)->showCursor()) { | ||
659 | setSoftWareCursor(true); | 660 | setSoftWareCursor(true); | ||
660 | } | 661 | } | ||
661 | } | 662 | } | ||
662 | } | 663 | } | ||
663 | markCursorAsRendered(); | 664 | | ||
665 | Cursors::self()->currentCursor()->markAsRendered(); | ||||
664 | } | 666 | } | ||
665 | 667 | | |||
666 | void DrmBackend::updateCursor() | 668 | void DrmBackend::updateCursor() | ||
667 | { | 669 | { | ||
668 | if (usesSoftwareCursor()) { | 670 | if (usesSoftwareCursor()) { | ||
669 | return; | 671 | return; | ||
670 | } | 672 | } | ||
671 | if (isCursorHidden()) { | 673 | if (isCursorHidden()) { | ||
672 | return; | 674 | return; | ||
673 | } | 675 | } | ||
674 | const QImage &cursorImage = softwareCursor(); | 676 | | ||
677 | auto cursor = Cursors::self()->currentCursor(); | ||||
678 | const QImage &cursorImage = cursor->image(); | ||||
675 | if (cursorImage.isNull()) { | 679 | if (cursorImage.isNull()) { | ||
676 | doHideCursor(); | 680 | doHideCursor(); | ||
677 | return; | 681 | return; | ||
678 | } | 682 | } | ||
679 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 683 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
680 | (*it)->updateCursor(); | 684 | (*it)->updateCursor(); | ||
681 | } | 685 | } | ||
682 | 686 | | |||
683 | setCursor(); | 687 | setCursor(); | ||
684 | moveCursor(); | 688 | | ||
689 | moveCursor(cursor, cursor->pos()); | ||||
685 | } | 690 | } | ||
686 | 691 | | |||
687 | void DrmBackend::doShowCursor() | 692 | void DrmBackend::doShowCursor() | ||
688 | { | 693 | { | ||
689 | updateCursor(); | 694 | updateCursor(); | ||
690 | } | 695 | } | ||
691 | 696 | | |||
692 | void DrmBackend::doHideCursor() | 697 | void DrmBackend::doHideCursor() | ||
693 | { | 698 | { | ||
694 | if (!m_cursorEnabled || usesSoftwareCursor()) { | 699 | if (!m_cursorEnabled || usesSoftwareCursor()) { | ||
695 | return; | 700 | return; | ||
696 | } | 701 | } | ||
697 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 702 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
698 | (*it)->hideCursor(); | 703 | (*it)->hideCursor(); | ||
699 | } | 704 | } | ||
700 | } | 705 | } | ||
701 | 706 | | |||
702 | void DrmBackend::moveCursor() | 707 | void DrmBackend::moveCursor(Cursor *cursor, const QPoint &pos) | ||
703 | { | 708 | { | ||
704 | if (!m_cursorEnabled || isCursorHidden() || usesSoftwareCursor()) { | 709 | if (!m_cursorEnabled || isCursorHidden() || usesSoftwareCursor()) { | ||
705 | return; | 710 | return; | ||
706 | } | 711 | } | ||
707 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 712 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
708 | (*it)->moveCursor(Cursor::pos()); | 713 | (*it)->moveCursor(cursor, pos); | ||
709 | } | 714 | } | ||
710 | } | 715 | } | ||
711 | 716 | | |||
712 | Screens *DrmBackend::createScreens(QObject *parent) | 717 | Screens *DrmBackend::createScreens(QObject *parent) | ||
713 | { | 718 | { | ||
714 | return new DrmScreens(this, parent); | 719 | return new DrmScreens(this, parent); | ||
715 | } | 720 | } | ||
716 | 721 | | |||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |