1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Cocoa: Move slightly towards modern Objective-C

This commit is contained in:
Camilla Löwy 2019-01-03 19:32:45 +01:00
parent 72c3908e14
commit 9a9568212c
3 changed files with 12 additions and 18 deletions

View File

@ -75,7 +75,7 @@ more information.
## System requirements
GLFW supports Windows XP and later and macOS 10.7 and later. Linux and other
GLFW supports Windows XP and later and macOS 10.8 and later. Linux and other
Unix-like systems running the X Window System are supported even without
a desktop environment or modern extensions, although some features require
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.

View File

@ -374,14 +374,10 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
{
if (!monitor->ns.screen)
{
NSUInteger i;
NSArray* screens = [NSScreen screens];
for (i = 0; i < [screens count]; i++)
for (NSScreen* screen in [NSScreen screens])
{
NSScreen* screen = [screens objectAtIndex:i];
NSNumber* displayID =
[[screen deviceDescription] objectForKey:@"NSScreenNumber"];
[screen deviceDescription][@"NSScreenNumber"];
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
@ -394,7 +390,7 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
}
}
if (i == [screens count])
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find a screen for monitor");

View File

@ -737,7 +737,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
char** paths = calloc(count, sizeof(char*));
for (NSUInteger i = 0; i < count; i++)
paths[i] = _glfw_strdup([[urls objectAtIndex:i] fileSystemRepresentation]);
paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
_glfwInputDrop(window, (int) count, (const char**) paths);
@ -883,7 +883,7 @@ static void createMenuBar(void)
for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
{
id name = [bundleInfo objectForKey:nameKeys[i]];
id name = bundleInfo[nameKeys[i]];
if (name &&
[name isKindOfClass:[NSString class]] &&
![name isEqualToString:@""])
@ -897,7 +897,7 @@ static void createMenuBar(void)
{
char** progname = _NSGetProgname();
if (progname && *progname)
appName = [NSString stringWithUTF8String:*progname];
appName = @(*progname);
else
appName = @"GLFW Application";
}
@ -1084,7 +1084,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
}
if (strlen(wndconfig->ns.frameName))
[window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->ns.frameName]];
[window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
@ -1099,7 +1099,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
[window->ns.object setContentView:window->ns.view];
[window->ns.object makeFirstResponder:window->ns.view];
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
[window->ns.object setTitle:@(wndconfig->title)];
[window->ns.object setDelegate:window->ns.delegate];
[window->ns.object setAcceptsMouseMovedEvents:YES];
[window->ns.object setRestorable:NO];
@ -1190,11 +1190,10 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
{
NSString* string = [NSString stringWithUTF8String:title];
[window->ns.object setTitle:string];
[window->ns.object setTitle:@(title)];
// HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
// if the window lacks NSWindowStyleMaskTitled
[window->ns.object setMiniwindowTitle:string];
[window->ns.object setMiniwindowTitle:@(title)];
}
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
@ -1737,8 +1736,7 @@ void _glfwPlatformSetClipboardString(const char* string)
{
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
[pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
[pasteboard setString:[NSString stringWithUTF8String:string]
forType:NSPasteboardTypeString];
[pasteboard setString:@(string) forType:NSPasteboardTypeString];
}
const char* _glfwPlatformGetClipboardString(void)