Changeset View
Changeset View
Standalone View
Standalone View
pointer_input.cpp
Show First 20 Lines • Show All 536 Lines • ▼ Show 20 Line(s) | 528 | [this] { | |||
---|---|---|---|---|---|
537 | auto seat = waylandServer()->seat(); | 537 | auto seat = waylandServer()->seat(); | ||
538 | if (m_window.data()->surface() != seat->focusedPointerSurface()) { | 538 | if (m_window.data()->surface() != seat->focusedPointerSurface()) { | ||
539 | return; | 539 | return; | ||
540 | } | 540 | } | ||
541 | seat->setFocusedPointerSurfaceTransformation(m_window.data()->inputTransformation()); | 541 | seat->setFocusedPointerSurfaceTransformation(m_window.data()->inputTransformation()); | ||
542 | } | 542 | } | ||
543 | ); | 543 | ); | ||
544 | m_constraintsConnection = connect(m_window->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged, | 544 | m_constraintsConnection = connect(m_window->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged, | ||
545 | this, &PointerInputRedirection::enablePointerConstraints); | 545 | this, &PointerInputRedirection::updatePointerConstraints); | ||
546 | // check whether a pointer confinement/lock fires | 546 | // check whether a pointer confinement/lock fires | ||
547 | m_blockConstraint = false; | 547 | m_blockConstraint = false; | ||
548 | enablePointerConstraints(); | 548 | updatePointerConstraints(); | ||
549 | } else { | 549 | } else { | ||
550 | m_window.clear(); | 550 | m_window.clear(); | ||
551 | warpXcbOnSurfaceLeft(nullptr); | 551 | warpXcbOnSurfaceLeft(nullptr); | ||
552 | seat->setFocusedPointerSurface(nullptr); | 552 | seat->setFocusedPointerSurface(nullptr); | ||
553 | t = nullptr; | 553 | t = nullptr; | ||
554 | } | 554 | } | ||
555 | } | 555 | } | ||
556 | 556 | | |||
Show All 36 Lines | |||||
593 | static QRegion getConstraintRegion(Toplevel *t, T *constraint) | 593 | static QRegion getConstraintRegion(Toplevel *t, T *constraint) | ||
594 | { | 594 | { | ||
595 | const QRegion windowShape = t->inputShape(); | 595 | const QRegion windowShape = t->inputShape(); | ||
596 | const QRegion windowRegion = windowShape.isEmpty() ? QRegion(0, 0, t->clientSize().width(), t->clientSize().height()) : windowShape; | 596 | const QRegion windowRegion = windowShape.isEmpty() ? QRegion(0, 0, t->clientSize().width(), t->clientSize().height()) : windowShape; | ||
597 | const QRegion intersected = constraint->region().isEmpty() ? windowRegion : windowRegion.intersected(constraint->region()); | 597 | const QRegion intersected = constraint->region().isEmpty() ? windowRegion : windowRegion.intersected(constraint->region()); | ||
598 | return intersected.translated(t->pos() + t->clientPos()); | 598 | return intersected.translated(t->pos() + t->clientPos()); | ||
599 | } | 599 | } | ||
600 | 600 | | |||
601 | void PointerInputRedirection::enablePointerConstraints() | 601 | void PointerInputRedirection::updatePointerConstraints() | ||
602 | { | 602 | { | ||
603 | if (m_window.isNull()) { | 603 | if (m_window.isNull()) { | ||
604 | return; | 604 | return; | ||
605 | } | 605 | } | ||
606 | const auto s = m_window->surface(); | 606 | const auto s = m_window->surface(); | ||
607 | if (!s) { | 607 | if (!s) { | ||
608 | return; | 608 | return; | ||
609 | } | 609 | } | ||
Show All 38 Lines | 628 | m_confinedPointerRegionConnection = connect(cf.data(), &KWayland::Server::ConfinedPointerInterface::regionChanged, this, | |||
648 | } | 648 | } | ||
649 | ); | 649 | ); | ||
650 | OSD::show(i18nc("notification about mouse pointer confined", | 650 | OSD::show(i18nc("notification about mouse pointer confined", | ||
651 | "Pointer motion confined to the current window.\nTo release pointer hold Escape for 3 seconds."), | 651 | "Pointer motion confined to the current window.\nTo release pointer hold Escape for 3 seconds."), | ||
652 | QStringLiteral("preferences-desktop-mouse"), 5000); | 652 | QStringLiteral("preferences-desktop-mouse"), 5000); | ||
653 | return; | 653 | return; | ||
654 | } | 654 | } | ||
655 | } else { | 655 | } else { | ||
656 | m_confined = false; | ||||
656 | disconnectConfinedPointerRegionConnection(); | 657 | disconnectConfinedPointerRegionConnection(); | ||
657 | } | 658 | } | ||
658 | const auto lock = s->lockedPointer(); | 659 | const auto lock = s->lockedPointer(); | ||
659 | if (lock) { | 660 | if (lock) { | ||
660 | if (lock->isLocked()) { | 661 | if (lock->isLocked()) { | ||
661 | return; | 662 | return; | ||
662 | } | 663 | } | ||
663 | const QRegion r = getConstraintRegion(m_window.data(), lock.data()); | 664 | const QRegion r = getConstraintRegion(m_window.data(), lock.data()); | ||
664 | if (r.contains(m_pos.toPoint())) { | 665 | if (r.contains(m_pos.toPoint())) { | ||
665 | lock->setLocked(true); | 666 | lock->setLocked(true); | ||
666 | m_locked = true; | 667 | m_locked = true; | ||
667 | OSD::show(i18nc("notification about mouse pointer locked", | 668 | OSD::show(i18nc("notification about mouse pointer locked", | ||
668 | "Pointer locked to current position.\nTo end pointer lock hold Escape for 3 seconds."), | 669 | "Pointer locked to current position.\nTo end pointer lock hold Escape for 3 seconds."), | ||
669 | QStringLiteral("preferences-desktop-mouse"), 5000); | 670 | QStringLiteral("preferences-desktop-mouse"), 5000); | ||
670 | // TODO: connect to region change - is it needed at all? If the pointer is locked it's always in the region | 671 | // TODO: connect to region change - is it needed at all? If the pointer is locked it's always in the region | ||
671 | } | 672 | } | ||
673 | } else { | ||||
674 | m_locked = false; | ||||
672 | } | 675 | } | ||
673 | } | 676 | } | ||
674 | 677 | | |||
675 | void PointerInputRedirection::warpXcbOnSurfaceLeft(KWayland::Server::SurfaceInterface *newSurface) | 678 | void PointerInputRedirection::warpXcbOnSurfaceLeft(KWayland::Server::SurfaceInterface *newSurface) | ||
676 | { | 679 | { | ||
677 | auto xc = waylandServer()->xWaylandConnection(); | 680 | auto xc = waylandServer()->xWaylandConnection(); | ||
678 | if (!xc) { | 681 | if (!xc) { | ||
679 | // No XWayland, no point in warping the x cursor | 682 | // No XWayland, no point in warping the x cursor | ||
▲ Show 20 Lines • Show All 634 Lines • Show Last 20 Lines |