mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 20:11:58 +00:00
Renamed Cocoa window object member.
This commit is contained in:
parent
a12b395442
commit
d40a3d1617
@ -72,7 +72,7 @@ typedef struct _GLFWcontextNSGL
|
|||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
typedef struct _GLFWwindowNS
|
typedef struct _GLFWwindowNS
|
||||||
{
|
{
|
||||||
id window;
|
id object;
|
||||||
id delegate;
|
id delegate;
|
||||||
unsigned int modifierFlags;
|
unsigned int modifierFlags;
|
||||||
double fracScrollX;
|
double fracScrollX;
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
[window->NSGL.context update];
|
[window->NSGL.context update];
|
||||||
|
|
||||||
NSRect contentRect =
|
NSRect contentRect =
|
||||||
[window->NS.window contentRectForFrameRect:[window->NS.window frame]];
|
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
|
||||||
|
|
||||||
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@
|
|||||||
[window->NSGL.context update];
|
[window->NSGL.context update];
|
||||||
|
|
||||||
NSRect contentRect =
|
NSRect contentRect =
|
||||||
[window->NS.window contentRectForFrameRect:[window->NS.window frame]];
|
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
|
||||||
|
|
||||||
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
|
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
|
||||||
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;
|
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;
|
||||||
@ -360,7 +360,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
NSPoint p = [event locationInWindow];
|
NSPoint p = [event locationInWindow];
|
||||||
|
|
||||||
// Cocoa coordinate system has origin at lower left
|
// Cocoa coordinate system has origin at lower left
|
||||||
p.y = [[window->NS.window contentView] bounds].size.height - p.y;
|
p.y = [[window->NS.object contentView] bounds].size.height - p.y;
|
||||||
|
|
||||||
_glfwInputCursorMotion(window, p.x, p.y);
|
_glfwInputCursorMotion(window, p.x, p.y);
|
||||||
}
|
}
|
||||||
@ -674,25 +674,25 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
styleMask = NSBorderlessWindowMask;
|
styleMask = NSBorderlessWindowMask;
|
||||||
|
|
||||||
window->NS.window = [[NSWindow alloc]
|
window->NS.object = [[NSWindow alloc]
|
||||||
initWithContentRect:NSMakeRect(0, 0, window->width, window->height)
|
initWithContentRect:NSMakeRect(0, 0, window->width, window->height)
|
||||||
styleMask:styleMask
|
styleMask:styleMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO];
|
defer:NO];
|
||||||
|
|
||||||
if (window->NS.window == nil)
|
if (window->NS.object == nil)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa/NSOpenGL: Failed to create window");
|
"Cocoa/NSOpenGL: Failed to create window");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
[window->NS.window setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
[window->NS.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||||
[window->NS.window setContentView:[[GLFWContentView alloc]
|
[window->NS.object setContentView:[[GLFWContentView alloc]
|
||||||
initWithGlfwWindow:window]];
|
initWithGlfwWindow:window]];
|
||||||
[window->NS.window setDelegate:window->NS.delegate];
|
[window->NS.object setDelegate:window->NS.delegate];
|
||||||
[window->NS.window setAcceptsMouseMovedEvents:YES];
|
[window->NS.object setAcceptsMouseMovedEvents:YES];
|
||||||
[window->NS.window center];
|
[window->NS.object center];
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
@ -906,8 +906,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
if (!createContext(window, wndconfig, fbconfig))
|
if (!createContext(window, wndconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
[window->NS.window makeKeyAndOrderFront:nil];
|
[window->NS.object makeKeyAndOrderFront:nil];
|
||||||
[window->NSGL.context setView:[window->NS.window contentView]];
|
[window->NSGL.context setView:[window->NS.object contentView]];
|
||||||
|
|
||||||
if (wndconfig->mode == GLFW_FULLSCREEN)
|
if (wndconfig->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
@ -921,7 +921,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[window->NS.window contentView] enterFullScreenMode:[NSScreen mainScreen]
|
[[window->NS.object contentView] enterFullScreenMode:[NSScreen mainScreen]
|
||||||
withOptions:nil];
|
withOptions:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -943,11 +943,11 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
[window->NS.window orderOut:nil];
|
[window->NS.object orderOut:nil];
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
[[window->NS.window contentView] exitFullScreenModeWithOptions:nil];
|
[[window->NS.object contentView] exitFullScreenModeWithOptions:nil];
|
||||||
|
|
||||||
_glfwRestoreVideoMode();
|
_glfwRestoreVideoMode();
|
||||||
}
|
}
|
||||||
@ -959,12 +959,12 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
|||||||
[window->NSGL.context release];
|
[window->NSGL.context release];
|
||||||
window->NSGL.context = nil;
|
window->NSGL.context = nil;
|
||||||
|
|
||||||
[window->NS.window setDelegate:nil];
|
[window->NS.object setDelegate:nil];
|
||||||
[window->NS.delegate release];
|
[window->NS.delegate release];
|
||||||
window->NS.delegate = nil;
|
window->NS.delegate = nil;
|
||||||
|
|
||||||
[window->NS.window close];
|
[window->NS.object close];
|
||||||
window->NS.window = nil;
|
window->NS.object = nil;
|
||||||
|
|
||||||
// TODO: Probably more cleanup
|
// TODO: Probably more cleanup
|
||||||
}
|
}
|
||||||
@ -976,7 +976,7 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
||||||
{
|
{
|
||||||
[window->NS.window setTitle:[NSString stringWithUTF8String:title]];
|
[window->NS.object setTitle:[NSString stringWithUTF8String:title]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -986,7 +986,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
[window->NS.window setContentSize:NSMakeSize(width, height)];
|
[window->NS.object setContentSize:NSMakeSize(width, height)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -997,16 +997,16 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||||
{
|
{
|
||||||
NSRect contentRect =
|
NSRect contentRect =
|
||||||
[window->NS.window contentRectForFrameRect:[window->NS.window frame]];
|
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
|
||||||
|
|
||||||
// We assume here that the client code wants to position the window within the
|
// We assume here that the client code wants to position the window within the
|
||||||
// screen the window currently occupies
|
// screen the window currently occupies
|
||||||
NSRect screenRect = [[window->NS.window screen] visibleFrame];
|
NSRect screenRect = [[window->NS.object screen] visibleFrame];
|
||||||
contentRect.origin = NSMakePoint(screenRect.origin.x + x,
|
contentRect.origin = NSMakePoint(screenRect.origin.x + x,
|
||||||
screenRect.origin.y + screenRect.size.height -
|
screenRect.origin.y + screenRect.size.height -
|
||||||
y - contentRect.size.height);
|
y - contentRect.size.height);
|
||||||
|
|
||||||
[window->NS.window setFrame:[window->NS.window frameRectForContentRect:contentRect]
|
[window->NS.object setFrame:[window->NS.object frameRectForContentRect:contentRect]
|
||||||
display:YES];
|
display:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,7 +1017,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
|||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
[window->NS.window miniaturize:nil];
|
[window->NS.object miniaturize:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1027,7 +1027,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
[window->NS.window deminiaturize:nil];
|
[window->NS.object deminiaturize:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1168,7 +1168,7 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
|
|||||||
// "global coordinates" are upside down from CG's...
|
// "global coordinates" are upside down from CG's...
|
||||||
|
|
||||||
NSPoint localPoint = NSMakePoint(x, y);
|
NSPoint localPoint = NSMakePoint(x, y);
|
||||||
NSPoint globalPoint = [window->NS.window convertBaseToScreen:localPoint];
|
NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint];
|
||||||
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
|
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
|
||||||
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;
|
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;
|
||||||
CGPoint targetPoint = CGPointMake(globalPoint.x - mainScreenOrigin.x,
|
CGPoint targetPoint = CGPointMake(globalPoint.x - mainScreenOrigin.x,
|
||||||
|
Loading…
Reference in New Issue
Block a user