Fixed fullscreen mouse events on MacOS X
Fixed crash when quitting fullscreen mode on MacOS X --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40118
This commit is contained in:
parent
962eabb3ef
commit
77331bf064
3 changed files with 42 additions and 39 deletions
|
@ -16,6 +16,8 @@ be found at the <A HREF="http://www.libsdl.org/"> main SDL page</A>.
|
||||||
Major changes since SDL 1.0.0:
|
Major changes since SDL 1.0.0:
|
||||||
</H2>
|
</H2>
|
||||||
<UL>
|
<UL>
|
||||||
|
<LI> 1.2.2: Fixed crash when quitting fullscreen mode on MacOS X
|
||||||
|
<LI> 1.2.2: Fixed fullscreen mouse events on MacOS X
|
||||||
<LI> 1.2.2: Now returns an error if unable to open audio on BeOS
|
<LI> 1.2.2: Now returns an error if unable to open audio on BeOS
|
||||||
<LI> 1.2.2: Now gets correct keyboard state when starting up on X11
|
<LI> 1.2.2: Now gets correct keyboard state when starting up on X11
|
||||||
<LI> 1.2.2: Improved the DGA 2.0 and framebuffer console drivers
|
<LI> 1.2.2: Improved the DGA 2.0 and framebuffer console drivers
|
||||||
|
|
|
@ -195,8 +195,8 @@ static void QZ_DoModifiers (unsigned int newMods) {
|
||||||
currentMods = newMods;
|
currentMods = newMods;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void QZ_DoActivate (_THIS, NSPoint p) {
|
static void QZ_DoActivate (_THIS)
|
||||||
|
{
|
||||||
inForeground = YES;
|
inForeground = YES;
|
||||||
|
|
||||||
/* Regrab the mouse */
|
/* Regrab the mouse */
|
||||||
|
@ -220,13 +220,10 @@ static void QZ_DoDeactivate (_THIS) {
|
||||||
SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
|
SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void QZ_PumpEvents (_THIS) {
|
static void QZ_PumpEvents (_THIS)
|
||||||
|
{
|
||||||
NSDate *distantPast = [ NSDate distantPast ];
|
NSDate *distantPast = [ NSDate distantPast ];
|
||||||
|
|
||||||
//NSAutoreleasePool *pool;
|
|
||||||
//pool = [ [ NSAutoreleasePool alloc ] init ];
|
|
||||||
|
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
NSRect winRect;
|
NSRect winRect;
|
||||||
NSRect titleBarRect;
|
NSRect titleBarRect;
|
||||||
|
@ -244,29 +241,28 @@ static void QZ_PumpEvents (_THIS) {
|
||||||
|
|
||||||
if (event != nil) {
|
if (event != nil) {
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
NSPoint p;
|
|
||||||
|
|
||||||
type = [ event type ];
|
#define DO_MOUSE_DOWN(button, sendToWindow) \
|
||||||
p = [ event locationInWindow ];
|
if ( inForeground ) { \
|
||||||
|
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
|
||||||
#define DO_MOUSE_DOWN(button, sendToWindow) \
|
NSPointInRect([event locationInWindow], winRect) ) \
|
||||||
if ( inForeground ) { \
|
SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
|
||||||
if ( NSPointInRect(p,winRect)) \
|
else if (sendToWindow) \
|
||||||
SDL_PrivateMouseButton (SDL_PRESSED, button, p.x, SDL_VideoSurface->h - p.y); \
|
[ window sendEvent:event ]; \
|
||||||
else if (sendToWindow) \
|
} \
|
||||||
[ window sendEvent:event ]; \
|
else { \
|
||||||
} \
|
QZ_DoActivate (this); \
|
||||||
else { \
|
|
||||||
QZ_DoActivate (this, p); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DO_MOUSE_UP(button, sendToWindow) \
|
#define DO_MOUSE_UP(button, sendToWindow) \
|
||||||
if ( ! NSPointInRect (p, titleBarRect) ) \
|
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
|
||||||
SDL_PrivateMouseButton (SDL_RELEASED, button, p.x, SDL_VideoSurface->h - p.y); \
|
!NSPointInRect([event locationInWindow], titleBarRect) )\
|
||||||
if (sendToWindow) \
|
SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
|
||||||
|
if (sendToWindow) \
|
||||||
[ window sendEvent:event ]
|
[ window sendEvent:event ]
|
||||||
|
|
||||||
switch ( type) {
|
type = [ event type ];
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
case NSLeftMouseDown:
|
case NSLeftMouseDown:
|
||||||
if ( NSCommandKeyMask & currentMods ) {
|
if ( NSCommandKeyMask & currentMods ) {
|
||||||
|
@ -302,33 +298,39 @@ static void QZ_PumpEvents (_THIS) {
|
||||||
case NSLeftMouseDragged:
|
case NSLeftMouseDragged:
|
||||||
case NSRightMouseDragged:
|
case NSRightMouseDragged:
|
||||||
case 27:
|
case 27:
|
||||||
SDL_PrivateMouseMotion (SDL_PRESSED, 0, p.x, SDL_VideoSurface->h - p.y);
|
|
||||||
break;
|
|
||||||
case NSMouseMoved:
|
case NSMouseMoved:
|
||||||
{
|
{
|
||||||
static int moves = 0;
|
static int moves = 0;
|
||||||
|
NSPoint p;
|
||||||
|
|
||||||
|
if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) {
|
||||||
|
p = [ NSEvent mouseLocation ];
|
||||||
|
p.y = [[NSScreen mainScreen] frame].size.height - p.y;
|
||||||
|
} else {
|
||||||
|
p = [ event locationInWindow ];
|
||||||
|
p.y = SDL_VideoSurface->h - p.y;
|
||||||
|
}
|
||||||
|
|
||||||
if ( (moves % 10) == 0 ) {
|
if ( (moves % 10) == 0 ) {
|
||||||
SDL_PrivateMouseMotion (SDL_RELEASED, 0, p.x, SDL_VideoSurface->h - p.y);
|
SDL_PrivateMouseMotion (0, 0, p.x, p.y);
|
||||||
moves = 0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CGMouseDelta dx, dy;
|
CGMouseDelta dx, dy;
|
||||||
CGGetLastMouseDelta (&dx, &dy);
|
CGGetLastMouseDelta (&dx, &dy);
|
||||||
SDL_PrivateMouseMotion (SDL_RELEASED, 1, dx, dy);
|
SDL_PrivateMouseMotion (0, 1, dx, dy);
|
||||||
moves++;
|
|
||||||
}
|
}
|
||||||
|
moves++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
{
|
{
|
||||||
if (NSPointInRect(p, winRect)) {
|
if (NSPointInRect([ event locationInWindow ], winRect)) {
|
||||||
float dy;
|
float dy;
|
||||||
dy = [ event deltaY ];
|
dy = [ event deltaY ];
|
||||||
if ( dy > 0.0 ) /* Scroll up */
|
if ( dy > 0.0 ) /* Scroll up */
|
||||||
SDL_PrivateMouseButton (SDL_PRESSED, 4, p.x, SDL_VideoSurface->h - p.y);
|
SDL_PrivateMouseButton (SDL_PRESSED, 4, 0, 0);
|
||||||
else /* Scroll down */
|
else /* Scroll down */
|
||||||
SDL_PrivateMouseButton (SDL_PRESSED, 5, p.x, SDL_VideoSurface->h - p.y);
|
SDL_PrivateMouseButton (SDL_PRESSED, 5, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -346,7 +348,7 @@ static void QZ_PumpEvents (_THIS) {
|
||||||
case NSAppKitDefined:
|
case NSAppKitDefined:
|
||||||
switch ( [ event subtype ] ) {
|
switch ( [ event subtype ] ) {
|
||||||
case NSApplicationActivatedEventType:
|
case NSApplicationActivatedEventType:
|
||||||
QZ_DoActivate (this, p);
|
QZ_DoActivate (this);
|
||||||
break;
|
break;
|
||||||
case NSApplicationDeactivatedEventType:
|
case NSApplicationDeactivatedEventType:
|
||||||
QZ_DoDeactivate (this);
|
QZ_DoDeactivate (this);
|
||||||
|
@ -361,8 +363,6 @@ static void QZ_PumpEvents (_THIS) {
|
||||||
case NSCursorUpdate: break;
|
case NSCursorUpdate: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// [ pool release ];
|
|
||||||
|
|
||||||
} while (event != nil);
|
} while (event != nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,7 @@ static void QZ_UnsetVideoMode (_THIS) {
|
||||||
if ( mode_flags & SDL_FULLSCREEN ) {
|
if ( mode_flags & SDL_FULLSCREEN ) {
|
||||||
CGDisplaySwitchToMode (display_id, save_mode);
|
CGDisplaySwitchToMode (display_id, save_mode);
|
||||||
CGDisplayRelease (display_id);
|
CGDisplayRelease (display_id);
|
||||||
|
this->screen->pixels = NULL;
|
||||||
}
|
}
|
||||||
/* Release window mode data structures */
|
/* Release window mode data structures */
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue