Fix remaining build errors for Cocoa.

This commit is contained in:
ws909 2023-01-26 08:50:42 +01:00
parent bbd5bcb7fd
commit b5363d87d2
2 changed files with 51 additions and 47 deletions

View File

@ -35,19 +35,6 @@
// Needed for _NSGetProgname
#include <crt_externs.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
NSAppearanceName const NSAppearanceNameVibrantLight = @"NSAppearanceNameVibrantLight";
NSAppearanceName const NSAppearanceNameVibrantDark = @"NSAppearanceNameVibrantDark";
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
NSAppearanceName const NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
NSAppearanceName const NSAppearanceNameAccessibilityHighContrastAqua = @"NSAppearanceNameAccessibilityAqua";
NSAppearanceName const NSAppearanceNameAccessibilityHighContrastDarkAqua = @"NSAppearanceNameAccessibilityDarkAqua";
NSAppearanceName const NSAppearanceNameAccessibilityHighContrastVibrantLight = @"NSAppearanceNameAccessibilityVibrantLight";
NSAppearanceName const NSAppearanceNameAccessibilityHighContrastVibrantDark = @"NSAppearanceNameAccessibilityVibrantDark";
#endif
// Change to our application bundle's resources directory, if present
//
static void changeToResourcesDirectory(void)
@ -211,43 +198,60 @@ void nsAppearanceToGLFWTheme(NSAppearance* appearance, GLFWtheme* theme)
if ([name isEqualToString:NSAppearanceNameAqua])
{
theme->baseTheme = GLFW_BASE_THEME_LIGHT;
return;
}
else if ([name isEqualToString:NSAppearanceNameDarkAqua])
{
theme->baseTheme = GLFW_BASE_THEME_DARK;
}
else if ([name isEqualToString:NSAppearanceNameVibrantLight])
if (@available(macOS 10.10, *)) {
if ([name isEqualToString:NSAppearanceNameVibrantLight])
{
theme->baseTheme = GLFW_BASE_THEME_LIGHT;
theme->flags |= GLFW_THEME_FLAG_VIBRANT;
return;
}
else if ([name isEqualToString:NSAppearanceNameVibrantDark])
if ([name isEqualToString:NSAppearanceNameVibrantDark])
{
theme->baseTheme = GLFW_BASE_THEME_DARK;
theme->flags |= GLFW_THEME_FLAG_VIBRANT;
return;
}
}
if (@available(macOS 10.14, *))
{
if ([name isEqualToString:NSAppearanceNameDarkAqua])
{
theme->baseTheme = GLFW_BASE_THEME_DARK;
return;
}
if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastAqua])
{
theme->baseTheme = GLFW_BASE_THEME_LIGHT;
theme->flags |= GLFW_THEME_FLAG_HIGH_CONTRAST;
return;
}
else if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastDarkAqua])
if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastDarkAqua])
{
theme->baseTheme = GLFW_BASE_THEME_DARK;
theme->flags |= GLFW_THEME_FLAG_HIGH_CONTRAST;
return;
}
else if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastVibrantLight])
if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastVibrantLight])
{
theme->baseTheme = GLFW_BASE_THEME_LIGHT;
theme->flags |= GLFW_THEME_FLAG_VIBRANT | GLFW_THEME_FLAG_HIGH_CONTRAST;
return;
}
else if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastVibrantDark])
if ([name isEqualToString:NSAppearanceNameAccessibilityHighContrastVibrantDark])
{
theme->baseTheme = GLFW_BASE_THEME_DARK;
theme->flags |= GLFW_THEME_FLAG_VIBRANT | GLFW_THEME_FLAG_HIGH_CONTRAST;
return;
}
}
theme->baseTheme = GLFW_BASE_THEME_LIGHT;
}
// Create key code translation tables
//
static void createKeyTables(void)

View File

@ -1880,7 +1880,7 @@ void _glfwSetThemeCocoa(_GLFWwindow* window, GLFWtheme* theme)
{
if (!theme || theme->baseTheme == GLFW_BASE_THEME_DEFAULT)
{
[window->ns.object setAppearance:nil];
[(NSWindow*)window->ns.object setAppearance:nil];
return;
}
@ -1923,7 +1923,7 @@ void _glfwSetThemeCocoa(_GLFWwindow* window, GLFWtheme* theme)
}
NSAppearance* appearance = [NSAppearance appearanceNamed:name];
[window->ns.object setAppearance:appearance];
[(NSWindow*)window->ns.object setAppearance:appearance];
}
GLFWtheme* _glfwGetThemeCocoa(_GLFWwindow* window)