diff --git a/src/protocols/ForeignToplevelWlr.cpp b/src/protocols/ForeignToplevelWlr.cpp index 291969db..1163a5e7 100644 --- a/src/protocols/ForeignToplevelWlr.cpp +++ b/src/protocols/ForeignToplevelWlr.cpp @@ -180,7 +180,7 @@ CForeignToplevelWlrManager::CForeignToplevelWlrManager(SPm_vWindows) { - if (!w->m_bIsMapped || w->m_bFadingOut) + if (!PROTO::foreignToplevelWlr->windowValidForForeign(w)) continue; onMap(w); @@ -313,6 +313,10 @@ bool CForeignToplevelWlrManager::good() { CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(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) { const auto PWINDOW = std::any_cast(data); + + if (!windowValidForForeign(PWINDOW)) + return; + for (auto const& m : m_vManagers) { m->onMap(PWINDOW); } @@ -320,6 +324,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) { const auto PWINDOW = std::any_cast(data); + + if (!windowValidForForeign(PWINDOW)) + return; + for (auto const& m : m_vManagers) { m->onUnmap(PWINDOW); } @@ -327,6 +335,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) { const auto PWINDOW = std::any_cast(data); + + if (!windowValidForForeign(PWINDOW)) + return; + for (auto const& m : m_vManagers) { m->onTitle(PWINDOW); } @@ -334,6 +346,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa static auto P3 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) { const auto PWINDOW = std::any_cast(data); + + if (!windowValidForForeign(PWINDOW)) + return; + for (auto const& m : m_vManagers) { m->onNewFocus(PWINDOW); } @@ -348,6 +364,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa static auto P5 = g_pHookSystem->hookDynamic("fullscreen", [this](void* self, SCallbackInfo& info, std::any data) { const auto PWINDOW = std::any_cast(data); + + if (!windowValidForForeign(PWINDOW)) + return; + for (auto const& m : m_vManagers) { m->onFullscreen(PWINDOW); } @@ -383,3 +403,7 @@ PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res return nullptr; } + +bool CForeignToplevelWlrProtocol::windowValidForForeign(PHLWINDOW pWindow) { + return validMapped(pWindow) && !pWindow->isX11OverrideRedirect(); +} diff --git a/src/protocols/ForeignToplevelWlr.hpp b/src/protocols/ForeignToplevelWlr.hpp index 99f63b47..e726707d 100644 --- a/src/protocols/ForeignToplevelWlr.hpp +++ b/src/protocols/ForeignToplevelWlr.hpp @@ -63,6 +63,7 @@ class CForeignToplevelWlrProtocol : public IWaylandProtocol { private: void onManagerResourceDestroy(CForeignToplevelWlrManager* mgr); void destroyHandle(CForeignToplevelHandleWlr* handle); + bool windowValidForForeign(PHLWINDOW pWindow); // std::vector> m_vManagers;