From 904f9b6aee6a4524fba554f76b32747f85f0609d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 19 Oct 2024 16:09:39 +0100 Subject: [PATCH] foreign-toplevel: don't send updates to X11 OR windows --- src/protocols/ForeignToplevel.cpp | 29 ++++++++++++++++++++++++----- src/protocols/ForeignToplevel.hpp | 1 + 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/protocols/ForeignToplevel.cpp b/src/protocols/ForeignToplevel.cpp index 1f8cbcbe..38bb5e69 100644 --- a/src/protocols/ForeignToplevel.cpp +++ b/src/protocols/ForeignToplevel.cpp @@ -31,8 +31,8 @@ CForeignToplevelList::CForeignToplevelList(SP resourc }); for (auto const& w : g_pCompositor->m_vWindows) { - if (!w->m_bIsMapped || w->m_bFadingOut) - continue; + if (!PROTO::foreignToplevel->windowValidForForeign(w)) + return; onMap(w); } @@ -112,20 +112,35 @@ bool CForeignToplevelList::good() { CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) { + auto window = std::any_cast(data); + + if (!windowValidForForeign(window)) + return; + for (auto const& m : m_vManagers) { - m->onMap(std::any_cast(data)); + m->onMap(window); } }); static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) { + auto window = std::any_cast(data); + + if (!windowValidForForeign(window)) + return; + for (auto const& m : m_vManagers) { - m->onUnmap(std::any_cast(data)); + m->onUnmap(window); } }); static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) { + auto window = std::any_cast(data); + + if (!windowValidForForeign(window)) + return; + for (auto const& m : m_vManagers) { - m->onTitle(std::any_cast(data)); + m->onTitle(window); } }); } @@ -148,3 +163,7 @@ void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mg void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) { std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; }); } + +bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) { + return validMapped(pWindow) && !pWindow->isX11OverrideRedirect(); +} diff --git a/src/protocols/ForeignToplevel.hpp b/src/protocols/ForeignToplevel.hpp index d95db41f..076bfd7c 100644 --- a/src/protocols/ForeignToplevel.hpp +++ b/src/protocols/ForeignToplevel.hpp @@ -50,6 +50,7 @@ class CForeignToplevelProtocol : public IWaylandProtocol { private: void onManagerResourceDestroy(CForeignToplevelList* mgr); void destroyHandle(CForeignToplevelHandle* handle); + bool windowValidForForeign(PHLWINDOW pWindow); // std::vector> m_vManagers;