Created
September 3, 2011 20:53
-
-
Save kronos/1191769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 13646bc77c6144d1e5a2d098cd77b0e83e2627fb Mon Sep 17 00:00:00 2001 | |
From: Ivan Samsonov <[email protected]> | |
Date: Sun, 4 Sep 2011 00:50:38 +0400 | |
Subject: [PATCH] Implement getWindowPosition for OS X | |
--- | |
src/SFML/Window/OSX/SFViewController.mm | 10 ++++++++++ | |
src/SFML/Window/OSX/SFWindowController.mm | 10 ++++++++++ | |
src/SFML/Window/OSX/WindowImplCocoa.mm | 3 ++- | |
src/SFML/Window/OSX/WindowImplDelegateProtocol.h | 6 ++++++ | |
4 files changed, 28 insertions(+), 1 deletions(-) | |
diff --git a/src/SFML/Window/OSX/SFViewController.mm b/src/SFML/Window/OSX/SFViewController.mm | |
index 6047fa4..8f55f26 100644 | |
--- a/src/SFML/Window/OSX/SFViewController.mm | |
+++ b/src/SFML/Window/OSX/SFViewController.mm | |
@@ -238,4 +238,14 @@ | |
} | |
+//////////////////////////////////////////////////////// | |
+-(NSPoint)getWindowPosition | |
+{ | |
+ NSRect oglViewRect = [myOGLView frame]; | |
+ NSPoint point = oglViewRect.origin; | |
+ point.y = [myView frame].size.height - point.y - oglViewRect.size.height; | |
+ return point; | |
+} | |
+ | |
+ | |
@end | |
diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm | |
index 4be3b0e..2564007 100644 | |
--- a/src/SFML/Window/OSX/SFWindowController.mm | |
+++ b/src/SFML/Window/OSX/SFWindowController.mm | |
@@ -464,6 +464,16 @@ | |
} | |
+//////////////////////////////////////////////////////// | |
+-(NSPoint)getWindowPosition | |
+{ | |
+ NSRect windowRect = [myWindow frame]; | |
+ NSPoint point = windowRect.origin; | |
+ point.y = [self screenHeight] - point.y - windowRect.size.height - [self titlebarHeight]; | |
+ return point; | |
+} | |
+ | |
+ | |
#pragma mark | |
#pragma mark NSWindowDelegate's methods | |
diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm | |
index b50b1e1..6d63933 100644 | |
--- a/src/SFML/Window/OSX/WindowImplCocoa.mm | |
+++ b/src/SFML/Window/OSX/WindowImplCocoa.mm | |
@@ -353,7 +353,8 @@ void WindowImplCocoa::SetPosition(int x, int y) | |
//////////////////////////////////////////////////////////// | |
sf::Vector2i WindowImplCocoa::GetPosition() | |
{ | |
- //Beats me, object-c? | |
+ NSPoint position = [myDelegate getWindowPosition]; | |
+ return sf::Vector2i(position.x, position.y); | |
} | |
diff --git a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h | |
index 0986c3d..5fe82bf 100644 | |
--- a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h | |
+++ b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h | |
@@ -145,4 +145,10 @@ namespace sf { | |
//////////////////////////////////////////////////////////// | |
-(void)applyContext:(NSOpenGLContext *)context; | |
+//////////////////////////////////////////////////////////// | |
+/// Get window's position | |
+/// | |
+//////////////////////////////////////////////////////////// | |
+-(NSPoint)getWindowPosition; | |
+ | |
@end | |
-- | |
1.7.5.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment