From ddcd4fb767afe8490a239ab019012a78d368eb5e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 5 Apr 2022 18:29:58 +0200 Subject: [PATCH] Mostly fixes #5 --- src/Compositor.cpp | 8 ++++++++ src/events/Windows.cpp | 29 +++++++++++++++++++++++++---- src/managers/InputManager.cpp | 6 +++--- src/managers/XWaylandManager.cpp | 10 +++++++--- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 0bf2ffcf..bf36bf89 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -361,6 +361,14 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { return; } + if (m_pLastWindow == pWindow) + return; + + if (windowValidMapped(m_pLastWindow) && m_pLastWindow->m_bIsX11) { + wlr_seat_keyboard_notify_clear_focus(m_sSeat.seat); + wlr_seat_pointer_clear_focus(m_sSeat.seat); + } + const auto PWINDOWSURFACE = pSurface ? pSurface : g_pXWaylandManager->getWindowSurface(pWindow); focusSurface(PWINDOWSURFACE, pWindow); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 6d000231..7b3acd8a 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -126,8 +126,7 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW); - if (!PWINDOW->m_bIsModal) - g_pCompositor->focusWindow(PWINDOW); + g_pCompositor->focusWindow(PWINDOW); PWINDOW->m_pSurfaceTree = SubsurfaceTree::createTreeRoot(g_pXWaylandManager->getWindowSurface(PWINDOW), addViewCoords, PWINDOW); @@ -195,7 +194,10 @@ void Events::listener_unmapWindow(void* owner, void* data) { } void Events::listener_commitWindow(void* owner, void* data) { - // CWindow* PWINDOW = (CWindow*)owner; + CWindow* PWINDOW = (CWindow*)owner; + + if (!g_pCompositor->windowValidMapped(PWINDOW)) + return; // Debug::log(LOG, "Window %x committed", PWINDOW); // SPAM! } @@ -259,10 +261,29 @@ void Events::listener_activateX11(void* owner, void* data) { void Events::listener_configureX11(void* owner, void* data) { CWindow* PWINDOW = (CWindow*)owner; + if (!g_pCompositor->windowValidMapped(PWINDOW)) + return; + const auto E = (wlr_xwayland_surface_configure_event*)data; - // TODO: ignore if tiled? + if (!PWINDOW->m_bIsFloating) { + g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize); + g_pInputManager->refocus(); + return; + } + wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height); + wlr_xwayland_surface_restack(PWINDOW->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE); + PWINDOW->m_vEffectivePosition = Vector2D(E->x, E->y); + PWINDOW->m_vEffectiveSize = Vector2D(E->width, E->height); + PWINDOW->m_vRealPosition = PWINDOW->m_vEffectivePosition; + PWINDOW->m_vRealSize = PWINDOW->m_vRealSize; + PWINDOW->m_vPosition = PWINDOW->m_vPosition; + PWINDOW->m_vSize = PWINDOW->m_vSize; + + wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); + + g_pInputManager->refocus(); } void Events::listener_surfaceXWayland(wl_listener* listener, void* data) { diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index 32f4aca6..56efd695 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -101,14 +101,14 @@ void CInputManager::mouseMoveUnified(uint32_t time) { Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y) - surfacePos; - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); - wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); - if (pFoundWindow) g_pCompositor->focusWindow(pFoundWindow, foundSurface); else g_pCompositor->focusSurface(foundSurface); + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); + g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); } diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 0e419c0f..09ac6a72 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -32,17 +32,21 @@ wlr_surface* CHyprXWaylandManager::getWindowSurface(CWindow* pWindow) { void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) { if (wlr_surface_is_xdg_surface(pSurface)) wlr_xdg_toplevel_set_activated(wlr_xdg_surface_from_wlr_surface(pSurface)->toplevel, activate); - - else if (wlr_surface_is_xwayland_surface(pSurface)) + else if (wlr_surface_is_xwayland_surface(pSurface)) { wlr_xwayland_surface_activate(wlr_xwayland_surface_from_wlr_surface(pSurface), activate); + wlr_xwayland_surface_restack(wlr_xwayland_surface_from_wlr_surface(pSurface), NULL, XCB_STACK_MODE_ABOVE); + } + } void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) { if (pWindow == g_pCompositor->m_pLastWindow) return; - if (pWindow->m_bIsX11) + if (pWindow->m_bIsX11) { wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate); + wlr_xwayland_surface_restack(pWindow->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE); + } else wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate);