diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 7c170d13..2d7c1826 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -186,12 +186,23 @@ void CCompositor::focusWindow(CWindow* pWindow) { if (m_sWLRSeat->keyboard_state.focused_surface == PWINDOWSURFACE) return; // Don't focus when already focused on this. + // Unfocus last window + if (m_pLastFocus && windowValidMapped(m_pLastFocus)) + g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(m_pLastFocus), false); + if (m_sWLRSeat->keyboard_state.focused_surface){ + const auto XDGSURFACE = wlr_xdg_surface_from_wlr_surface(m_sWLRSeat->keyboard_state.focused_surface); + if (XDGSURFACE) + wlr_xdg_toplevel_set_activated(XDGSURFACE->toplevel, false); + + const auto XWLSURFACE = wlr_xwayland_surface_from_wlr_surface(m_sWLRSeat->keyboard_state.focused_surface); + if (XWLSURFACE) + wlr_xwayland_surface_activate(XWLSURFACE, false); + } + const auto KEYBOARD = wlr_seat_get_keyboard(m_sWLRSeat); wlr_seat_keyboard_notify_enter(m_sWLRSeat, PWINDOWSURFACE, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers); g_pXWaylandManager->activateSurface(PWINDOWSURFACE, true); - if (m_pLastFocus && windowValidMapped(m_pLastFocus)) - g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(m_pLastFocus), false); m_pLastFocus = pWindow; diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index 1b438ba9..93318e58 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -22,7 +22,7 @@ void CInputManager::onMouseMoved(wlr_event_pointer_motion* e) { void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) { wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, e->device, e->x, e->y); - m_vMouseCoords = Vector2D(e->x, e->y); + m_vMouseCoords = Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y); m_vWLRMouseCoords = m_vMouseCoords; mouseMoveUnified(e->time_msec); @@ -45,7 +45,7 @@ void CInputManager::mouseMoveUnified(uint32_t time) { g_pCompositor->focusWindow(PWINDOW); - Vector2D surfaceLocal = m_vMouseCoords - PWINDOW->m_vPosition; + Vector2D surfaceLocal = m_vWLRMouseCoords - 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); diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 5a0a38aa..1c28ec35 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -76,9 +76,9 @@ void CHyprXWaylandManager::setWindowStyleTiled(CWindow* pWindow, uint32_t edgez) wlr_xdg_toplevel_set_tiled(pWindow->m_uSurface.xdg->toplevel, edgez); } -wlr_surface* CHyprXWaylandManager::surfaceAt(CWindow* pWindow, const Vector2D& client, Vector2D& server) { - if (pWindow->m_bIsX11) - return wlr_surface_surface_at(pWindow->m_uSurface.xwayland->surface, client.x, client.y, &server.x, &server.y); +wlr_surface* CHyprXWaylandManager::surfaceAt(CWindow* pWindow, const Vector2D& client, Vector2D& surface) { + if (pWindow->m_bIsX11) + return wlr_surface_surface_at(pWindow->m_uSurface.xwayland->surface, client.x, client.y, &surface.x, &surface.y); - return wlr_xdg_surface_surface_at(pWindow->m_uSurface.xdg, client.x, client.y, &server.x, &server.y); + return wlr_xdg_surface_surface_at(pWindow->m_uSurface.xdg, client.x, client.y, &surface.x, &surface.y); } \ No newline at end of file