OSX, fixed sf::Window::SetPosition
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1773 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
0a7b98dd0b
commit
0cf57db9c2
@ -65,6 +65,7 @@ namespace sf {
|
|||||||
-(id)initWithMode:(sf::VideoMode const*)mode andStyle:(unsigned long)style;
|
-(id)initWithMode:(sf::VideoMode const*)mode andStyle:(unsigned long)style;
|
||||||
-(void)dealloc;
|
-(void)dealloc;
|
||||||
|
|
||||||
|
-(float)screenHeight;
|
||||||
-(float)titlebarHeight;
|
-(float)titlebarHeight;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -263,7 +263,7 @@
|
|||||||
NSPoint point = NSMakePoint(x, y);
|
NSPoint point = NSMakePoint(x, y);
|
||||||
|
|
||||||
// Flip for SFML window coordinate system.
|
// Flip for SFML window coordinate system.
|
||||||
point.y = NSHeight([[myWindow screen] visibleFrame]) - point.y;
|
point.y = [self screenHeight] - point.y;
|
||||||
|
|
||||||
// Place the window.
|
// Place the window.
|
||||||
[myWindow setFrameTopLeftPoint:point];
|
[myWindow setFrameTopLeftPoint:point];
|
||||||
@ -421,6 +421,33 @@
|
|||||||
#pragma mark
|
#pragma mark
|
||||||
#pragma mark Other methods
|
#pragma mark Other methods
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
-(float)screenHeight {
|
||||||
|
// We want to recompute it because the user may have moved the window to another screen
|
||||||
|
// since last time.
|
||||||
|
static float height = 0.f;
|
||||||
|
static NSDate* lastTime = [NSDate date];
|
||||||
|
if (height > 1.f && // height was set at least once.
|
||||||
|
[lastTime timeIntervalSinceNow] > -1.f) { // last time was less than one secode ago.
|
||||||
|
return height; // We don't want to compute it too often because the dock blink.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save current settings.
|
||||||
|
NSApplicationPresentationOptions currentOptions = [NSApp currentSystemPresentationOptions];
|
||||||
|
|
||||||
|
// Hide dock.
|
||||||
|
[NSApp setPresentationOptions:currentOptions | NSApplicationPresentationHideDock];
|
||||||
|
|
||||||
|
// Get the screen height (without apple menu bar if there is one).
|
||||||
|
height = NSHeight([[myWindow screen] visibleFrame]);
|
||||||
|
lastTime = [NSDate date];
|
||||||
|
|
||||||
|
// Set back user's settings.
|
||||||
|
[NSApp setPresentationOptions:currentOptions];
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
-(float)titlebarHeight {
|
-(float)titlebarHeight {
|
||||||
return NSHeight([myWindow frame]) - NSHeight([[myWindow contentView] frame]);
|
return NSHeight([myWindow frame]) - NSHeight([[myWindow contentView] frame]);
|
||||||
|
Loading…
Reference in New Issue
Block a user