From 7e523e4d5e526bdf5ab86a8f4fe37efeef356707 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Feb 2023 18:50:47 +0000 Subject: [PATCH] minor fixes to X11 configure/or handling --- src/Compositor.cpp | 13 +++++++++---- src/Window.hpp | 1 + src/events/Events.hpp | 1 + src/events/Windows.cpp | 28 +++++++++++++++++----------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 9346dd9c..52e2f6ad 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -498,10 +498,6 @@ CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) { void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) { if (windowExists(pWindow) && !pWindow->m_bFadingOut) { - if (pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) { - std::erase_if(m_dUnmanagedX11Windows, [&](std::unique_ptr& el) { return el.get() == pWindow; }); - } - // if X11, also check its children // and delete any needed if (pWindow->m_bIsX11) { @@ -519,6 +515,10 @@ void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) { } } + if (pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) { + std::erase_if(m_dUnmanagedX11Windows, [&](std::unique_ptr& el) { return el.get() == pWindow; }); + } + std::erase_if(m_vWindows, [&](std::unique_ptr& el) { return el.get() == pWindow; }); } } @@ -529,6 +529,11 @@ bool CCompositor::windowExists(CWindow* pWindow) { return true; } + for (auto& u : m_dUnmanagedX11Windows) { + if (u.get() == pWindow) + return true; + } + return false; } diff --git a/src/Window.hpp b/src/Window.hpp index 65ac78f5..577b7432 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -155,6 +155,7 @@ class CWindow { DYNLISTENER(toplevelClose); DYNLISTENER(toplevelActivate); DYNLISTENER(toplevelFullscreen); + DYNLISTENER(setOverrideRedirect); // DYNLISTENER(newSubsurfaceWindow); union { diff --git a/src/events/Events.hpp b/src/events/Events.hpp index 69b40d69..ae441fbb 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -58,6 +58,7 @@ namespace Events { DYNLISTENFUNC(requestResize); DYNLISTENFUNC(requestMinimize); DYNLISTENFUNC(requestMaximize); + DYNLISTENFUNC(setOverrideRedirect); // Window subsurfaces // LISTENER(newSubsurfaceWindow); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 58273d96..2405a309 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -446,7 +446,6 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late"); - PWINDOW->hyprListener_configureX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_configure, &Events::listener_configureX11, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_minimize, &Events::listener_requestMinimize, PWINDOW, "Xwayland Window Late"); @@ -596,7 +595,6 @@ void Events::listener_unmapWindow(void* owner, void* data) { Debug::log(LOG, "Unregistered late callbacks XWL"); PWINDOW->hyprListener_fullscreenWindow.removeCallback(); PWINDOW->hyprListener_activateX11.removeCallback(); - PWINDOW->hyprListener_configureX11.removeCallback(); PWINDOW->hyprListener_setTitleWindow.removeCallback(); PWINDOW->hyprListener_setGeometryX11U.removeCallback(); PWINDOW->hyprListener_requestMaximize.removeCallback(); @@ -889,12 +887,15 @@ 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; + CWindow* PWINDOW = (CWindow*)owner; const auto E = (wlr_xwayland_surface_configure_event*)data; + + if (!PWINDOW->m_uSurface.xwayland->mapped || !PWINDOW->m_bMappedX11) { + wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height); + return; + } + g_pHyprRenderer->damageWindow(PWINDOW); if (!PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen) { @@ -904,11 +905,6 @@ void Events::listener_configureX11(void* owner, void* data) { return; } - if (!PWINDOW->m_uSurface.xwayland->mapped || !PWINDOW->m_bMappedX11) { - wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height); - return; - } - if (E->width > 1 && E->height > 1) PWINDOW->setHidden(false); else @@ -974,6 +970,14 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) { } } +void Events::listener_setOverrideRedirect(void* owner, void* data) { + const auto PWINDOW = (CWindow*)owner; + + if (!PWINDOW->m_bIsMapped && PWINDOW->m_uSurface.xwayland->mapped) { + Events::listener_mapWindow(PWINDOW, nullptr); + } +} + void Events::listener_surfaceXWayland(wl_listener* listener, void* data) { const auto XWSURFACE = (wlr_xwayland_surface*)data; @@ -993,6 +997,8 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) { PNEWWINDOW->hyprListener_mapWindow.initCallback(&XWSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XWSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XWSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XWayland Window"); + PNEWWINDOW->hyprListener_setOverrideRedirect.initCallback(&XWSURFACE->events.set_override_redirect, &Events::listener_setOverrideRedirect, PNEWWINDOW, "XWayland Window"); + PNEWWINDOW->hyprListener_configureX11.initCallback(&XWSURFACE->events.request_configure, &Events::listener_configureX11, PNEWWINDOW, "XWayland Window"); } void Events::listener_newXDGSurface(wl_listener* listener, void* data) {