Module: wine Branch: master Commit: 6289a612ae6bbe0fcd07d7a3c8ff802db10fc5c6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6289a612ae6bbe0fcd07d7a3c8...
Author: Ken Thomases ken@codeweavers.com Date: Wed Feb 6 19:32:22 2013 -0600
winemac: Add WineApplication methods to convert from Cocoa to Win32 coordinate space.
Cocoa coordinate space has its origin in the lower left of the primary screen and y increases up.
---
dlls/winemac.drv/cocoa_app.h | 3 +++ dlls/winemac.drv/cocoa_app.m | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index 2ccaec9..1166087 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -43,6 +43,9 @@
CGEventSourceKeyboardType keyboardType; NSEvent* lastFlagsChanged; + + CGFloat primaryScreenHeight; + BOOL primaryScreenHeightValid; }
@property (nonatomic) CGEventSourceKeyboardType keyboardType; diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 3853ec9..ae2353b 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -225,6 +225,32 @@ int macdrv_err_on; } }
+ - (CGFloat) primaryScreenHeight + { + if (!primaryScreenHeightValid) + { + NSArray* screens = [NSScreen screens]; + if ([screens count]) + { + primaryScreenHeight = NSHeight([[screens objectAtIndex:0] frame]); + primaryScreenHeightValid = TRUE; + } + else + return 1280; /* arbitrary value */ + } + + return primaryScreenHeight; + } + + - (NSPoint) flippedMouseLocation:(NSPoint)point + { + /* This relies on the fact that Cocoa's mouse location points are + actually off by one (precisely because they were flipped from + Quartz screen coordinates using this same technique). */ + point.y = [self primaryScreenHeight] - point.y; + return point; + } +
/* * ---------- NSApplication method overrides ---------- @@ -241,6 +267,11 @@ int macdrv_err_on; /* * ---------- NSApplicationDelegate methods ---------- */ + - (void)applicationDidChangeScreenParameters:(NSNotification *)notification + { + primaryScreenHeightValid = FALSE; + } + - (void)applicationDidResignActive:(NSNotification *)notification { macdrv_event event;