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:
parent
5f06bf80db
commit
6289a612ae
|
@ -43,6 +43,9 @@ @interface WineApplication : NSApplication <NSApplicationDelegate>
|
|||
|
||||
CGEventSourceKeyboardType keyboardType;
|
||||
NSEvent* lastFlagsChanged;
|
||||
|
||||
CGFloat primaryScreenHeight;
|
||||
BOOL primaryScreenHeightValid;
|
||||
}
|
||||
|
||||
@property (nonatomic) CGEventSourceKeyboardType keyboardType;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue