mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Cocoa: Change helper function suffix to Cocoa
This makes it clearer which platform a helper function belongs to.
This commit is contained in:
parent
09f9773e6f
commit
36ea36736d
@ -307,7 +307,7 @@ static void createKeyTables(void)
|
|||||||
|
|
||||||
// Retrieve Unicode data for the current keyboard layout
|
// Retrieve Unicode data for the current keyboard layout
|
||||||
//
|
//
|
||||||
static GLFWbool updateUnicodeDataNS(void)
|
static GLFWbool updateUnicodeData(void)
|
||||||
{
|
{
|
||||||
if (_glfw.ns.inputSource)
|
if (_glfw.ns.inputSource)
|
||||||
{
|
{
|
||||||
@ -377,7 +377,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
|
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
|
||||||
*kPropertyUnicodeKeyLayoutData;
|
*kPropertyUnicodeKeyLayoutData;
|
||||||
|
|
||||||
return updateUnicodeDataNS();
|
return updateUnicodeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface GLFWHelper : NSObject
|
@interface GLFWHelper : NSObject
|
||||||
@ -387,7 +387,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
|
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
|
||||||
{
|
{
|
||||||
updateUnicodeDataNS();
|
updateUnicodeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)doNothing:(id)object
|
- (void)doNothing:(id)object
|
||||||
@ -421,7 +421,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
_glfwPollMonitorsCocoa();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||||
@ -453,7 +453,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < _glfw.monitorCount; i++)
|
for (i = 0; i < _glfw.monitorCount; i++)
|
||||||
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
|
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end // GLFWApplicationDelegate
|
@end // GLFWApplicationDelegate
|
||||||
@ -463,7 +463,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void* _glfwLoadLocalVulkanLoaderNS(void)
|
void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||||
{
|
{
|
||||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||||
if (!bundle)
|
if (!bundle)
|
||||||
@ -547,7 +547,7 @@ int _glfwPlatformInit(void)
|
|||||||
if (!initializeTIS())
|
if (!initializeTIS())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
_glfwPollMonitorsCocoa();
|
||||||
|
|
||||||
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
@ -297,7 +297,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
|||||||
|
|
||||||
// Poll for changes in the set of connected monitors
|
// Poll for changes in the set of connected monitors
|
||||||
//
|
//
|
||||||
void _glfwPollMonitorsNS(void)
|
void _glfwPollMonitorsCocoa(void)
|
||||||
{
|
{
|
||||||
uint32_t displayCount;
|
uint32_t displayCount;
|
||||||
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
||||||
@ -385,7 +385,7 @@ void _glfwPollMonitorsNS(void)
|
|||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//
|
//
|
||||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
GLFWvidmode current;
|
GLFWvidmode current;
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||||
@ -428,7 +428,7 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
|
|
||||||
// Restore the previously saved (original) video mode
|
// Restore the previously saved (original) video mode
|
||||||
//
|
//
|
||||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
|
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
if (monitor->ns.previousMode)
|
if (monitor->ns.previousMode)
|
||||||
{
|
{
|
||||||
@ -504,7 +504,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
|||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = frameRect.origin.x;
|
*xpos = frameRect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
|
*ypos = _glfwTransformYCocoa(frameRect.origin.y + frameRect.size.height - 1);
|
||||||
if (width)
|
if (width)
|
||||||
*width = frameRect.size.width;
|
*width = frameRect.size.width;
|
||||||
if (height)
|
if (height)
|
||||||
|
@ -205,13 +205,13 @@ typedef struct _GLFWcursorNS
|
|||||||
} _GLFWcursorNS;
|
} _GLFWcursorNS;
|
||||||
|
|
||||||
|
|
||||||
void _glfwPollMonitorsNS(void);
|
void _glfwPollMonitorsCocoa(void);
|
||||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
float _glfwTransformYNS(float y);
|
float _glfwTransformYCocoa(float y);
|
||||||
|
|
||||||
void* _glfwLoadLocalVulkanLoaderNS(void);
|
void* _glfwLoadLocalVulkanLoaderCocoa(void);
|
||||||
|
|
||||||
GLFWbool _glfwInitNSGL(void);
|
GLFWbool _glfwInitNSGL(void);
|
||||||
void _glfwTerminateNSGL(void);
|
void _glfwTerminateNSGL(void);
|
||||||
|
@ -129,10 +129,10 @@ static void updateCursorMode(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
static void acquireMonitor(_GLFWwindow* window)
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
_glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
_glfwSetVideoModeCocoa(window->monitor, &window->videoMode);
|
||||||
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||||
const NSRect frame = NSMakeRect(bounds.origin.x,
|
const NSRect frame = NSMakeRect(bounds.origin.x,
|
||||||
_glfwTransformYNS(bounds.origin.y + bounds.size.height - 1),
|
_glfwTransformYCocoa(bounds.origin.y + bounds.size.height - 1),
|
||||||
bounds.size.width,
|
bounds.size.width,
|
||||||
bounds.size.height);
|
bounds.size.height);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ static void releaseMonitor(_GLFWwindow* window)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwInputMonitorWindow(window->monitor, NULL);
|
_glfwInputMonitorWindow(window->monitor, NULL);
|
||||||
_glfwRestoreVideoModeNS(window->monitor);
|
_glfwRestoreVideoModeCocoa(window->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates macOS key modifiers into GLFW ones
|
// Translates macOS key modifiers into GLFW ones
|
||||||
@ -885,7 +885,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
// Transforms a y-coordinate between the CG display and NS screen spaces
|
// Transforms a y-coordinate between the CG display and NS screen spaces
|
||||||
//
|
//
|
||||||
float _glfwTransformYNS(float y)
|
float _glfwTransformYCocoa(float y)
|
||||||
{
|
{
|
||||||
return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
|
return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
|
||||||
}
|
}
|
||||||
@ -1006,7 +1006,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
|||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = contentRect.origin.x;
|
*xpos = contentRect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1);
|
*ypos = _glfwTransformYCocoa(contentRect.origin.y + contentRect.size.height - 1);
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
@ -1016,7 +1016,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
|||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height - 1), 0, 0);
|
const NSRect dummyRect = NSMakeRect(x, _glfwTransformYCocoa(y + contentRect.size.height - 1), 0, 0);
|
||||||
const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
|
const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
|
||||||
[window->ns.object setFrameOrigin:frameRect.origin];
|
[window->ns.object setFrameOrigin:frameRect.origin];
|
||||||
|
|
||||||
@ -1218,7 +1218,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const NSRect contentRect =
|
const NSRect contentRect =
|
||||||
NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height);
|
NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height);
|
||||||
const NSRect frameRect =
|
const NSRect frameRect =
|
||||||
[window->ns.object frameRectForContentRect:contentRect
|
[window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:getStyleMask(window)];
|
styleMask:getStyleMask(window)];
|
||||||
@ -1252,7 +1252,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1),
|
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1),
|
||||||
width, height);
|
width, height);
|
||||||
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:styleMask];
|
styleMask:styleMask];
|
||||||
@ -1516,7 +1516,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
|||||||
const NSPoint globalPoint = globalRect.origin;
|
const NSPoint globalPoint = globalRect.origin;
|
||||||
|
|
||||||
CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
|
CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
|
||||||
_glfwTransformYNS(globalPoint.y)));
|
_glfwTransformYCocoa(globalPoint.y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Calling this right after setting the cursor position prevents macOS
|
// HACK: Calling this right after setting the cursor position prevents macOS
|
||||||
|
Loading…
Reference in New Issue
Block a user