Cleanup WM_CLOSE_WINDOW atom handling

predefine needed atoms so we dont have to check if or when they are
made available
This commit is contained in:
Oskari Alaranta 2026-02-22 22:06:48 +02:00
parent 710b896a84
commit 4886e71452
2 changed files with 11 additions and 19 deletions

View File

@ -823,22 +823,8 @@ static void send_exposure_recursive(Client& client_info, WINDOW wid)
static void on_window_close_event(Client& client_info, WINDOW wid) static void on_window_close_event(Client& client_info, WINDOW wid)
{ {
static CARD32 WM_PROTOCOLS = None; static CARD32 WM_PROTOCOLS = g_atoms_name_to_id["WM_PROTOCOLS"_sv];
static CARD32 WM_DELETE_WINDOW = None; static CARD32 WM_DELETE_WINDOW = g_atoms_name_to_id["WM_DELETE_WINDOW"_sv];
if (WM_PROTOCOLS == None)
{
auto it = g_atoms_name_to_id.find("WM_PROTOCOLS"_sv);
if (it != g_atoms_name_to_id.end())
WM_PROTOCOLS = it->value;
}
if (WM_DELETE_WINDOW == None)
{
auto it = g_atoms_name_to_id.find("WM_DELETE_WINDOW"_sv);
if (it != g_atoms_name_to_id.end())
WM_DELETE_WINDOW = it->value;
}
auto& object = *g_objects[wid]; auto& object = *g_objects[wid];
ASSERT(object.type == Object::Type::Window); ASSERT(object.type == Object::Type::Window);
@ -847,9 +833,6 @@ static void on_window_close_event(Client& client_info, WINDOW wid)
const bool supports_wm_delete_winow = const bool supports_wm_delete_winow =
[&window] [&window]
{ {
if (WM_PROTOCOLS == None || WM_DELETE_WINDOW == None)
return false;
auto wm_protocols_it = window.properties.find(WM_PROTOCOLS); auto wm_protocols_it = window.properties.find(WM_PROTOCOLS);
if (wm_protocols_it == window.properties.end()) if (wm_protocols_it == window.properties.end())
return false; return false;

View File

@ -253,6 +253,15 @@ int main()
APPEND_ATOM(XA_WM_TRANSIENT_FOR); APPEND_ATOM(XA_WM_TRANSIENT_FOR);
#undef APPEND_ATOM #undef APPEND_ATOM
#define APPEND_ATOM_CUSTOM(name) do { \
const CARD32 atom = g_atom_value++; \
MUST(g_atoms_id_to_name.insert(atom, #name##_sv)); \
MUST(g_atoms_name_to_id.insert(#name##_sv, atom)); \
} while (0)
APPEND_ATOM_CUSTOM(WM_PROTOCOLS);
APPEND_ATOM_CUSTOM(WM_DELETE_WINDOW);
#undef APPEND_ATOM_CUSTOM
MUST(initialize_keymap()); MUST(initialize_keymap());
printf("xbanan started\n"); printf("xbanan started\n");