| 77 | } |
| 78 | |
| 79 | void PointerInputRedirection::init() |
| 80 | { |
| 81 | Q_ASSERT(!inited()); |
| 82 | |
| 83 | m_cursor = new CursorImage(this); |
| 84 | setInited(true); |
| 85 | InputDeviceHandler::init(); |
| 86 | |
| 87 | if (!input()->hasPointer()) { |
| 88 | Cursors::self()->hideCursor(); |
| 89 | } |
| 90 | connect(input(), &InputRedirection::hasPointerChanged, this, []() { |
| 91 | if (input()->hasPointer()) { |
| 92 | Cursors::self()->showCursor(); |
| 93 | } else { |
| 94 | Cursors::self()->hideCursor(); |
| 95 | } |
| 96 | }); |
| 97 | |
| 98 | connect(m_cursor, &CursorImage::changed, Cursors::self()->mouse(), [this] { |
| 99 | Cursors::self()->mouse()->setSource(m_cursor->source()); |
| 100 | m_cursor->updateCursorOutputs(m_pos); |
| 101 | }); |
| 102 | Q_EMIT m_cursor->changed(); |
| 103 | |
| 104 | connect(workspace(), &Workspace::outputsChanged, this, &PointerInputRedirection::updateAfterScreenChange); |
| 105 | #if KWIN_BUILD_SCREENLOCKER |
| 106 | if (kwinApp()->supportsLockScreen()) { |
| 107 | connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, [this]() { |
| 108 | update(); |
| 109 | }); |
| 110 | } |
| 111 | #endif |
| 112 | connect(workspace(), &QObject::destroyed, this, [this] { |
| 113 | setInited(false); |
| 114 | }); |
| 115 | // connect the move resize of all window |
| 116 | auto setupMoveResizeConnection = [this](Window *window) { |
| 117 | connect(window, &Window::interactiveMoveResizeStarted, this, &PointerInputRedirection::updateOnStartMoveResize); |
| 118 | connect(window, &Window::interactiveMoveResizeFinished, this, &PointerInputRedirection::update); |
| 119 | }; |
| 120 | const auto clients = workspace()->windows(); |
| 121 | std::for_each(clients.begin(), clients.end(), setupMoveResizeConnection); |
| 122 | connect(workspace(), &Workspace::windowAdded, this, setupMoveResizeConnection); |
| 123 | |
| 124 | // warp the cursor to center of screen containing the workspace center |
| 125 | if (const Output *output = workspace()->outputAt(workspace()->geometry().center())) { |
| 126 | warp(output->geometry().center()); |
| 127 | } |
| 128 | updateAfterScreenChange(); |
| 129 | } |
| 130 | |
| 131 | void PointerInputRedirection::updateOnStartMoveResize() |
| 132 | { |
nothing calls this directly
no test coverage detected