Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/opengl/scene_opengl.cpp
Show First 20 Lines • Show All 590 Lines • ▼ Show 20 Line(s) | |||||
591 | } | 591 | } | ||
592 | 592 | | |||
593 | /** | 593 | /** | ||
594 | * Render cursor texture in case hardware cursor is disabled. | 594 | * Render cursor texture in case hardware cursor is disabled. | ||
595 | * Useful for screen recording apps or backends that can't do planes. | 595 | * Useful for screen recording apps or backends that can't do planes. | ||
596 | **/ | 596 | **/ | ||
597 | void SceneOpenGL2::paintCursor() | 597 | void SceneOpenGL2::paintCursor() | ||
598 | { | 598 | { | ||
599 | // don't paint if we use hardware cursor | 599 | // don't paint if we use hardware cursor or the cursor is hidden | ||
600 | if (!kwinApp()->platform()->usesSoftwareCursor()) { | 600 | if (!kwinApp()->platform()->usesSoftwareCursor() || | ||
601 | kwinApp()->platform()->isCursorHidden() || | ||||
602 | kwinApp()->platform()->softwareCursor().isNull()) { | ||||
601 | return; | 603 | return; | ||
602 | } | 604 | } | ||
603 | 605 | | |||
604 | // lazy init texture cursor only in case we need software rendering | 606 | // lazy init texture cursor only in case we need software rendering | ||
605 | if (!m_cursorTexture) { | 607 | if (!m_cursorTexture) { | ||
606 | auto updateCursorTexture = [this] { | 608 | auto updateCursorTexture = [this] { | ||
607 | // don't paint if no image for cursor is set | 609 | // don't paint if no image for cursor is set | ||
608 | const QImage img = kwinApp()->platform()->softwareCursor(); | 610 | const QImage img = kwinApp()->platform()->softwareCursor(); | ||
609 | if (img.isNull()) { | 611 | if (img.isNull()) { | ||
610 | return; | 612 | return; | ||
611 | } | 613 | } | ||
612 | m_cursorTexture.reset(new GLTexture(img)); | 614 | m_cursorTexture.reset(new GLTexture(img)); | ||
613 | }; | 615 | }; | ||
614 | 616 | | |||
615 | // init now | 617 | // init now | ||
616 | updateCursorTexture(); | 618 | updateCursorTexture(); | ||
617 | 619 | | |||
618 | // handle shape update on case cursor image changed | 620 | // handle shape update on case cursor image changed | ||
619 | connect(Cursor::self(), &Cursor::cursorChanged, this, updateCursorTexture); | 621 | connect(kwinApp()->platform(), &Platform::cursorChanged, this, updateCursorTexture); | ||
620 | } | 622 | } | ||
621 | 623 | | |||
622 | // get cursor position in projection coordinates | 624 | // get cursor position in projection coordinates | ||
623 | const QPoint cursorPos = Cursor::pos() - kwinApp()->platform()->softwareCursorHotspot(); | 625 | const QPoint cursorPos = Cursor::pos() - kwinApp()->platform()->softwareCursorHotspot(); | ||
624 | const QRect cursorRect(0, 0, m_cursorTexture->width(), m_cursorTexture->height()); | 626 | const QRect cursorRect(0, 0, m_cursorTexture->width(), m_cursorTexture->height()); | ||
625 | QMatrix4x4 mvp = m_projectionMatrix; | 627 | QMatrix4x4 mvp = m_projectionMatrix; | ||
626 | mvp.translate(cursorPos.x(), cursorPos.y()); | 628 | mvp.translate(cursorPos.x(), cursorPos.y()); | ||
627 | 629 | | |||
▲ Show 20 Lines • Show All 1942 Lines • Show Last 20 Lines |