Files
i3/include/main.h
Michael Stapelberg 5446ea33ef fix switching to/restoring from LC_NUMERIC (#6544)
Before this commit, we used setlocale(LC_NUMERIC, "");,
but that is not correct because it doesn’t nest:
load_layout.c (sets LC_NUMERIC=C) calls con_mark(),
which calls ipc_send_window_event() (sets LC_NUMERIC=C),
which calls setlocale(LC_NUMERIC, ""); when returning,
but now load_layout has LC_NUMERIC set per the environment,
whereas the function expects to remain in LC_NUMERIC=C.

Using newlocale and uselocale just swaps handles,
which is a little cleaner than querying the locale with
strdup(setlocale(LC_NUMERIC, NULL)); and restoring it later.

The test only fails with certain locales, e.g. LC_NUMERIC=de_DE.
I don’t think it’s important to set a locale in our test runner,
(which locales are available is very system-dependent),
as I am personally regularly testing with LC_NUMERIC=de_DE ;)

fixes https://github.com/i3/i3/issues/6391
2025-12-13 08:27:00 +01:00

24 lines
507 B
C

/*
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved tiling window manager
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
* main.c: Initialization, main loop
*
*/
#pragma once
#include <config.h>
#include <locale.h>
extern locale_t numericC;
/**
* Enable or disable the main X11 event handling function.
* This is used by drag_pointer() which has its own, modal event handler, which
* takes precedence over the normal event handler.
*
*/
void main_set_x11_cb(bool enable);