From 625e4ce264554e32975cb5f9e1d18b22640b56e6 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 18 Mar 2022 23:52:36 +0100 Subject: fixed rendering --- src/managers/InputManager.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/managers/InputManager.cpp') diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index c856f031..1b438ba9 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -15,20 +15,40 @@ void CInputManager::onMouseMoved(wlr_event_pointer_motion* e) { wlr_cursor_move(g_pCompositor->m_sWLRCursor, e->device, delta.floor().x, delta.floor().y); } - - if (e->time_msec) - wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat); - - - g_pCompositor->focusWindow(g_pCompositor->vectorToWindow(getMouseCoordsInternal())); + mouseMoveUnified(e->time_msec); // todo: pointer } void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) { wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, e->device, e->x, e->y); - if (e->time_msec) + m_vMouseCoords = Vector2D(e->x, e->y); + m_vWLRMouseCoords = m_vMouseCoords; + + mouseMoveUnified(e->time_msec); +} + +void CInputManager::mouseMoveUnified(uint32_t time) { + + const auto PWINDOW = g_pCompositor->vectorToWindow(m_vMouseCoords); + + if (!PWINDOW) { + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + + wlr_seat_pointer_clear_focus(g_pCompositor->m_sWLRSeat); + + return; + } + + if (time) wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat); + + g_pCompositor->focusWindow(PWINDOW); + + Vector2D surfaceLocal = m_vMouseCoords - PWINDOW->m_vPosition; + + wlr_seat_pointer_notify_enter(g_pCompositor->m_sWLRSeat, g_pXWaylandManager->getWindowSurface(PWINDOW), surfaceLocal.x, surfaceLocal.y); + wlr_seat_pointer_notify_motion(g_pCompositor->m_sWLRSeat, time, surfaceLocal.x, surfaceLocal.y); } void CInputManager::onMouseButton(wlr_event_pointer_button* e) { -- cgit v1.2.3