mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Track initial color scheme preference read on Linux
This commit is contained in:
@@ -955,7 +955,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
GLFWColorScheme new_appearance = glfwGetCurrentSystemColorTheme();
|
||||
if (new_appearance != appearance) {
|
||||
appearance = new_appearance;
|
||||
_glfwInputColorScheme(appearance);
|
||||
_glfwInputColorScheme(appearance, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5
glfw/glfw3.h
vendored
5
glfw/glfw3.h
vendored
@@ -1429,16 +1429,17 @@ typedef void (* GLFWapplicationclosefun)(int);
|
||||
*
|
||||
* This is the function pointer type for system color theme changes.
|
||||
* @code
|
||||
* void function_name(int theme_type)
|
||||
* void function_name(GLFWColorScheme theme_type, bool is_initial_value)
|
||||
* @endcode
|
||||
*
|
||||
* @param[in] theme_type 0 for unknown, 1 for dark and 2 for light
|
||||
* @param[in] is_initial_value true if this is the initial read of the color theme on systems where it is asynchronous such as Linux
|
||||
*
|
||||
* @sa @ref glfwSetSystemColorThemeChangeCallback
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
typedef void (* GLFWsystemcolorthemechangefun)(GLFWColorScheme);
|
||||
typedef void (* GLFWsystemcolorthemechangefun)(GLFWColorScheme, bool);
|
||||
|
||||
|
||||
/*! @brief The function pointer type for window content refresh callbacks.
|
||||
|
||||
4
glfw/input.c
vendored
4
glfw/input.c
vendored
@@ -448,9 +448,9 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
||||
js->hats[hat] = value;
|
||||
}
|
||||
|
||||
void _glfwInputColorScheme(GLFWColorScheme value) {
|
||||
void _glfwInputColorScheme(GLFWColorScheme value, bool is_initial_value) {
|
||||
_glfwPlatformInputColorScheme(value);
|
||||
if (_glfw.callbacks.system_color_theme_change) _glfw.callbacks.system_color_theme_change(value);
|
||||
if (_glfw.callbacks.system_color_theme_change) _glfw.callbacks.system_color_theme_change(value, is_initial_value);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
2
glfw/internal.h
vendored
2
glfw/internal.h
vendored
@@ -814,7 +814,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
||||
void _glfwInputCursorEnter(_GLFWwindow* window, bool entered);
|
||||
int _glfwInputDrop(_GLFWwindow* window, const char *mime, const char *text, size_t sz);
|
||||
void _glfwInputColorScheme(GLFWColorScheme);
|
||||
void _glfwInputColorScheme(GLFWColorScheme, bool);
|
||||
void _glfwPlatformInputColorScheme(GLFWColorScheme);
|
||||
void _glfwInputJoystick(_GLFWjoystick* js, int event);
|
||||
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
|
||||
|
||||
3
glfw/linux_desktop_settings.c
vendored
3
glfw/linux_desktop_settings.c
vendored
@@ -43,6 +43,7 @@ process_fdo_setting(const char *key, DBusMessageIter *value) {
|
||||
dbus_message_iter_get_basic(value, &val);
|
||||
if (val > 2) val = 0;
|
||||
appearance = val;
|
||||
_glfwInputColorScheme(appearance, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,7 +162,7 @@ on_color_scheme_change(DBusMessage *message) {
|
||||
if (val > 2) val = 0;
|
||||
if (val != appearance) {
|
||||
appearance = val;
|
||||
_glfwInputColorScheme(appearance);
|
||||
_glfwInputColorScheme(appearance, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3058,7 +3058,7 @@ class Boss:
|
||||
if w is not None:
|
||||
output = debug_config(get_options(), self.mappings.global_shortcuts)
|
||||
set_clipboard_string(re.sub(r'\x1b.+?m', '', output))
|
||||
output += '\n\x1b[35mThis debug output has been copied to the clipboard\x1b[m'
|
||||
output += '\n\x1b[35mThis debug output has been copied to the clipboard\x1b[m' # ]]]
|
||||
self.display_scrollback(w, output, title=_('Current kitty options'), report_cursor=False)
|
||||
|
||||
@ac('misc', 'Discard this event completely ignoring it')
|
||||
@@ -3069,8 +3069,11 @@ class Boss:
|
||||
def sanitize_url_for_dispay_to_user(self, url: str) -> str:
|
||||
return sanitize_url_for_dispay_to_user(url)
|
||||
|
||||
def on_system_color_scheme_change(self, appearance: Literal['light', 'dark', 'no_preference']) -> None:
|
||||
log_error('system color theme changed:', appearance)
|
||||
def on_system_color_scheme_change(self, appearance: Literal['light', 'dark', 'no_preference'], is_initial_value: bool) -> None:
|
||||
if is_initial_value:
|
||||
pass
|
||||
else:
|
||||
log_error('system color theme changed:', appearance)
|
||||
|
||||
@ac('win', '''
|
||||
Toggle to the tab matching the specified expression
|
||||
|
||||
5
kitty/glfw-wrapper.h
generated
5
kitty/glfw-wrapper.h
generated
@@ -1167,16 +1167,17 @@ typedef void (* GLFWapplicationclosefun)(int);
|
||||
*
|
||||
* This is the function pointer type for system color theme changes.
|
||||
* @code
|
||||
* void function_name(int theme_type)
|
||||
* void function_name(GLFWColorScheme theme_type, bool is_initial_value)
|
||||
* @endcode
|
||||
*
|
||||
* @param[in] theme_type 0 for unknown, 1 for dark and 2 for light
|
||||
* @param[in] is_initial_value true if this is the initial read of the color theme on systems where it is asynchronous such as Linux
|
||||
*
|
||||
* @sa @ref glfwSetSystemColorThemeChangeCallback
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
typedef void (* GLFWsystemcolorthemechangefun)(GLFWColorScheme);
|
||||
typedef void (* GLFWsystemcolorthemechangefun)(GLFWColorScheme, bool);
|
||||
|
||||
|
||||
/*! @brief The function pointer type for window content refresh callbacks.
|
||||
|
||||
@@ -47,15 +47,15 @@ get_platform_dependent_config_values(void *glfw_window) {
|
||||
}
|
||||
|
||||
static void
|
||||
on_system_color_scheme_change(GLFWColorScheme appearance) {
|
||||
on_system_color_scheme_change(GLFWColorScheme appearance, bool is_initial_value) {
|
||||
const char *which = NULL;
|
||||
switch (appearance) {
|
||||
case GLFW_COLOR_SCHEME_NO_PREFERENCE: which = "no_preference"; break;
|
||||
case GLFW_COLOR_SCHEME_DARK: which = "dark"; break;
|
||||
case GLFW_COLOR_SCHEME_LIGHT: which = "light"; break;
|
||||
}
|
||||
debug("system color-scheme changed to: %s\n", which);
|
||||
call_boss(on_system_color_scheme_change, "s", which);
|
||||
debug("system color-scheme changed to: %s is_initial_value: %d\n", which, is_initial_value);
|
||||
call_boss(on_system_color_scheme_change, "sO", which, is_initial_value ? Py_True : Py_False);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user