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.
This commit is contained in:
Ken Thomases 2013-02-06 19:32:22 -06:00 committed by Alexandre Julliard
parent 5f06bf80db
commit 6289a612ae
2 changed files with 34 additions and 0 deletions

View File

@ -43,6 +43,9 @@ @interface WineApplication : NSApplication <NSApplicationDelegate>
CGEventSourceKeyboardType keyboardType;
NSEvent* lastFlagsChanged;
CGFloat primaryScreenHeight;
BOOL primaryScreenHeightValid;
}
@property (nonatomic) CGEventSourceKeyboardType keyboardType;

View File

@ -225,6 +225,32 @@ - (void) keyboardSelectionDidChange
}
}
- (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 @@ - (void) sendEvent:(NSEvent*)anEvent
/*
* ---------- NSApplicationDelegate methods ----------
*/
- (void)applicationDidChangeScreenParameters:(NSNotification *)notification
{
primaryScreenHeightValid = FALSE;
}
- (void)applicationDidResignActive:(NSNotification *)notification
{
macdrv_event event;