From b672118f9238a48a18efd741cbcda387c5552238 Mon Sep 17 00:00:00 2001 From: trianta <56975502+Trimutex@users.noreply.github.com> Date: Sun, 25 Aug 2024 09:37:03 -0500 Subject: [PATCH] xwayland: deactivate xwayland focus if wayland is focused (#7458) * xwayland: deactivate xwayland focus if wayland is focused * xwayland: deactivate last xwayland surface after focusing wayland --- src/managers/XWaylandManager.cpp | 5 ++++- src/xwayland/XWM.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index f329dbe1..2f0632e0 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -43,8 +43,11 @@ void CHyprXWaylandManager::activateSurface(SP pSurface, bool w->m_pXWaylandSurface->restackToTop(); } w->m_pXWaylandSurface->activate(activate); - } else + } else { w->m_pXDGSurface->toplevel->setActive(activate); + if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastWindow->m_bIsX11) + activateSurface(g_pCompositor->m_pLastFocus.lock(), false); + } } } diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index f6b6864c..a409b440 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -897,7 +897,7 @@ void CXWM::activateSurface(SP surf, bool activate) { if ((surf == focusedSurface && activate) || (surf && surf->overrideRedirect)) return; - if (!surf) { + if (!surf || (!activate && g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsX11)) { setActiveWindow((uint32_t)XCB_WINDOW_NONE); focusWindow(nullptr); } else {