Better mouse event control for full screen mode

This commit is contained in:
nigel 2002-06-05 10:18:51 +00:00
parent 15baaf886a
commit ca896c0838
2 changed files with 28 additions and 19 deletions

View File

@ -46,7 +46,10 @@
BOOL drawView, // Set when the bitmap is all set up BOOL drawView, // Set when the bitmap is all set up
// and ready to display // and ready to display
fullScreen; // Is this Emulator running in a full screen? fullScreen; // Is this Emulator using the whole screen?
NSRect displayBox; // Cached dimensions of the screen
int screen_height;
} }
- (void) benchmark; - (void) benchmark;
@ -76,7 +79,7 @@
#endif #endif
- (void) disableDrawing; - (void) disableDrawing;
- (void) startedFullScreen; - (void) startedFullScreen: (CGDirectDisplayID) theDisplay;
- (short) width; - (short) width;
- (short) height; - (short) height;

View File

@ -64,7 +64,8 @@
[super dealloc]; [super dealloc];
} }
// Mouse click in this window. If window is not active, should click be passed to this view? // Mouse click in this window. If window is not active,
// should the click be passed to this view?
- (BOOL) acceptsFirstMouse: (NSEvent *) event - (BOOL) acceptsFirstMouse: (NSEvent *) event
{ {
return [self mouseInView]; return [self mouseInView];
@ -114,14 +115,21 @@ static int prevFlags;
- (BOOL) mouseInView: (NSEvent *) event - (BOOL) mouseInView: (NSEvent *) event
{ {
NSPoint loc = [event locationInWindow];
NSRect box; NSRect box;
NSPoint loc;
if ( fullScreen ) if ( fullScreen )
return YES; {
box = displayBox;
loc = [NSEvent mouseLocation];
}
else else
{
box = [self frame]; box = [self frame];
D(NSLog (@"%s - loc.x=%f, loc.y=%f, box.origin.x=%f, box.origin.y=%f", loc = [event locationInWindow];
__PRETTY_FUNCTION__, loc.x, loc.y, box.origin.x, box.origin.y)); }
D(NSLog (@"%s - loc.x=%f, loc.y=%f, box.origin.x=%f, box.origin.y=%f, box.size.width=%f, box.size.height=%f", __PRETTY_FUNCTION__, loc.x, loc.y, box.origin.x, box.origin.y, box.size.width, box.size.height));
return [self mouse: loc inRect: box]; return [self mouse: loc inRect: box];
} }
@ -134,7 +142,6 @@ static int prevFlags;
return [self mouse: loc inRect: box]; return [self mouse: loc inRect: box];
} }
// //
// Custom methods // Custom methods
// //
@ -229,9 +236,13 @@ static int prevFlags;
drawView = NO; drawView = NO;
} }
- (void) startedFullScreen - (void) startedFullScreen: (CGDirectDisplayID) display
{ {
CGRect displayBounds = CGDisplayBounds(display);
fullScreen = YES; fullScreen = YES;
memcpy(&displayBox, &displayBounds, sizeof(displayBox));
screen_height = (int)displayBounds.size.height;
} }
- (short) width - (short) width
@ -300,22 +311,17 @@ static NSPoint mouse; // Previous/current mouse location
- (BOOL) processMouseMove: (NSEvent *) event - (BOOL) processMouseMove: (NSEvent *) event
{ {
NSPoint locInView; NSPoint location;
if ( fullScreen ) if ( fullScreen )
locInView = [NSEvent mouseLocation]; location = [NSEvent mouseLocation];
// CGAssociateMouseAndMouseCursorPosition(bool)
// which will let you unlink the mouse input and the mouse cursor. So I
// unlink the two, and the cursor doesn't move, but I still receive
// MouseMoved events and can get the movement value using
// CGGetLastMouseDelta.
else else
locInView = [self convertPoint: [event locationInWindow] fromView:nil]; location = [self convertPoint: [event locationInWindow] fromView:nil];
if ( NSEqualPoints(locInView, mouse) ) if ( NSEqualPoints(location, mouse) )
return NO; return NO;
mouse = locInView; mouse = location;
if ( fullScreen ) if ( fullScreen )
{ {