mirror of
https://github.com/SFML/SFML.git
synced 2025-01-31 21:55:13 +08:00
Fixed Mac OS X 10.6 support
This time it *should* be ok!
This commit is contained in:
parent
b18b771c33
commit
19cdceb039
@ -169,50 +169,25 @@ NSUInteger keepOnlyMaskFromData(NSUInteger data, NSUInteger mask);
|
|||||||
// but the recommended -[NSWindow convertRectToScreen] is not
|
// but the recommended -[NSWindow convertRectToScreen] is not
|
||||||
// available until 10.7.
|
// available until 10.7.
|
||||||
//
|
//
|
||||||
// So we choose at runtime which code to execute.
|
// So we stick with the old one for now.
|
||||||
|
|
||||||
#ifndef NSAppKitVersionNumber10_6
|
|
||||||
#define NSAppKitVersionNumber10_6 1038
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
// Flip SFML coordinates to match window coordinates
|
||||||
|
y = [self frame].size.height - y;
|
||||||
|
|
||||||
// Flip SFML coordinates to match window coordinates
|
// Get the position of (x, y) in the coordinate system of the window.
|
||||||
y = [self frame].size.height - y;
|
NSPoint p = [self convertPoint:NSMakePoint(x, y) toView:self];
|
||||||
|
p = [self convertPoint:p toView:nil]; // nil means window
|
||||||
|
|
||||||
// Get the position of (x, y) in the coordinate system of the window.
|
// Convert it to screen coordinates
|
||||||
NSRect r = [self convertRect:NSMakeRect(x, y, 1, 1) toView:self];
|
p = [[self window] convertBaseToScreen:p];
|
||||||
r = [self convertRect:r toView:nil]; // nil means window
|
|
||||||
|
|
||||||
// Convert it to screen coordinates
|
// Flip screen coodinates to match CGDisplayMoveCursorToPoint referential.
|
||||||
r = [[self window] convertRectToScreen:r];
|
float const screenHeight = [[[self window] screen] frame].size.height;
|
||||||
|
p.y = screenHeight - p.y;
|
||||||
|
|
||||||
// Flip screen coodinates to match CGDisplayMoveCursorToPoint referential.
|
x = p.x;
|
||||||
float const screenHeight = [[[self window] screen] frame].size.height;
|
y = p.y;
|
||||||
r.origin.y = screenHeight - r.origin.y;
|
|
||||||
|
|
||||||
x = r.origin.x;
|
|
||||||
y = r.origin.y;
|
|
||||||
|
|
||||||
} else { // 10.6 or lower
|
|
||||||
|
|
||||||
// Flip SFML coordinates to match window coordinates
|
|
||||||
y = [self frame].size.height - y;
|
|
||||||
|
|
||||||
// Get the position of (x, y) in the coordinate system of the window.
|
|
||||||
NSPoint p = [self convertPoint:NSMakePoint(x, y) toView:self];
|
|
||||||
p = [self convertPoint:p toView:nil]; // nil means window
|
|
||||||
|
|
||||||
// Convert it to screen coordinates
|
|
||||||
p = [[self window] convertBaseToScreen:p];
|
|
||||||
|
|
||||||
// Flip screen coodinates to match CGDisplayMoveCursorToPoint referential.
|
|
||||||
float const screenHeight = [[[self window] screen] frame].size.height;
|
|
||||||
p.y = screenHeight - p.y;
|
|
||||||
|
|
||||||
x = p.x;
|
|
||||||
y = p.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Get the id of the screen
|
// Get the id of the screen
|
||||||
|
Loading…
Reference in New Issue
Block a user