mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
GLFW API to track system color scheme dark/light
Implemented only on macOS and Wayland.
This commit is contained in:
@@ -1010,6 +1010,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
_glfwInputCursorEnter(window, true);
|
||||
}
|
||||
|
||||
- (void)viewDidChangeEffectiveAppearance
|
||||
{
|
||||
static int appearance = 0;
|
||||
if (_glfw.callbacks.system_color_theme_change) {
|
||||
int new_appearance = glfwGetCurrentSystemColorTheme();
|
||||
if (new_appearance != appearance) {
|
||||
appearance = new_appearance;
|
||||
_glfw.callbacks.system_color_theme_change(appearance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidChangeBackingProperties
|
||||
{
|
||||
if (!window) return;
|
||||
@@ -2957,6 +2969,19 @@ GLFWAPI void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun
|
||||
requestRenderFrame((_GLFWwindow*)w, callback);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetCurrentSystemColorTheme(void) {
|
||||
int theme_type = 0;
|
||||
NSAppearance *changedAppearance = NSApp.effectiveAppearance;
|
||||
NSAppearanceName newAppearance = [changedAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
||||
if([newAppearance isEqualToString:NSAppearanceNameDarkAqua]){
|
||||
theme_type = 1;
|
||||
} else {
|
||||
theme_type = 2;
|
||||
}
|
||||
return theme_type;
|
||||
}
|
||||
|
||||
|
||||
GLFWAPI uint32_t
|
||||
glfwGetCocoaKeyEquivalent(uint32_t glfw_key, int glfw_mods, int *cocoa_mods) {
|
||||
*cocoa_mods = 0;
|
||||
|
||||
Reference in New Issue
Block a user