From 0dc88d09bf490c3d10cae6de426a21391a42f21c Mon Sep 17 00:00:00 2001 From: Oskari Alaranta Date: Sat, 30 May 2026 19:11:49 +0300 Subject: [PATCH] Don't create platform window for windows without WM_CLASS gtk and other toolkits create a lot of dummy windows that should not be visible. --- xbanan/Base.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/xbanan/Base.cpp b/xbanan/Base.cpp index fbd19d0..367f4a5 100644 --- a/xbanan/Base.cpp +++ b/xbanan/Base.cpp @@ -374,6 +374,9 @@ void invalidate_window(WINDOW wid, int32_t x, int32_t y, int32_t w, int32_t h) for (;;) { + if (wid == g_root.windowId) + return; + auto& object = *g_objects[wid]; ASSERT(object.type == Object::Type::Window); @@ -506,17 +509,26 @@ transitient_for_done: static BAN::ErrorOr map_window(Client& client_info, WINDOW wid) { + static const CARD32 WM_CLASS = g_atoms_name_to_id["WM_CLASS"_sv]; + auto& object = *g_objects[wid]; ASSERT(object.type == Object::Type::Window); auto& window = object.object.get(); if (window.mapped) return {}; + window.mapped = true; if (window.parent == g_root.windowId) { ASSERT(!window.platform_window); + // NOTE: This is not perfect but seems to work. + // This is used to not display "dummy" event windows + // that should not be visible. + if (!window.properties.contains(WM_CLASS)) + return {}; + auto info = get_plaform_window_info(window); window.platform_window = TRY(g_platform_ops.create_window( info.transient_for, @@ -529,8 +541,6 @@ static BAN::ErrorOr map_window(Client& client_info, WINDOW wid) )); } - window.mapped = true; - for (auto& pixel : window.pixels) pixel = window.background; invalidate_window(wid, 0, 0, window.width, window.height);