Date: Mon, 5 May 2003 00:08:51 -0400
From: Darrell Walisser Subject: SDL Active Events Patch Hi Guys, I was reading sdl-devel the other day and remembered we don't handle SDL_APPACTIVE and SDL_APPMOUSEFOCUS. I hacked together a quick patch to do just this. One thing to note - there are actually two ways to "iconify" the SDL window (which sets SDL_APPACTIVE): hiding the entire application (for example, option-click on some other window) and minimizing the window to the dock. I treat both as SDL_APPACTIVE, since the window is no longer visible. Cheers, Darrell --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40632
This commit is contained in:
parent
e8ce0bc197
commit
4fc311ff37
2 changed files with 41 additions and 0 deletions
|
@ -583,6 +583,16 @@ static void QZ_PumpEvents (_THIS)
|
||||||
|
|
||||||
QZ_PrivateWarpCursor (this, p.x, p.y);
|
QZ_PrivateWarpCursor (this, p.x, p.y);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if ( !isInGameWin && (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
|
||||||
|
|
||||||
|
SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
|
||||||
|
|
||||||
|
SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
if ( isInGameWin ) {
|
if ( isInGameWin ) {
|
||||||
|
|
|
@ -31,6 +31,9 @@ static void QZ_SetPortAlphaOpaque () {
|
||||||
- (void)miniaturize:(id)sender;
|
- (void)miniaturize:(id)sender;
|
||||||
- (void)display;
|
- (void)display;
|
||||||
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
|
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
|
||||||
|
- (void)appDidHide:(NSNotification*)note;
|
||||||
|
- (void)appDidUnhide:(NSNotification*)note;
|
||||||
|
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SDL_QuartzWindow
|
@implementation SDL_QuartzWindow
|
||||||
|
@ -51,6 +54,9 @@ static void QZ_SetPortAlphaOpaque () {
|
||||||
QZ_SetPortAlphaOpaque ();
|
QZ_SetPortAlphaOpaque ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* window is hidden now */
|
||||||
|
SDL_PrivateAppActive (0, SDL_APPACTIVE);
|
||||||
|
|
||||||
[ super miniaturize:sender ];
|
[ super miniaturize:sender ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +69,9 @@ static void QZ_SetPortAlphaOpaque () {
|
||||||
*/
|
*/
|
||||||
if ( (SDL_VideoSurface->flags & SDL_OPENGL) == 0)
|
if ( (SDL_VideoSurface->flags & SDL_OPENGL) == 0)
|
||||||
QZ_SetPortAlphaOpaque ();
|
QZ_SetPortAlphaOpaque ();
|
||||||
|
|
||||||
|
/* window is visible again */
|
||||||
|
SDL_PrivateAppActive (1, SDL_APPACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
|
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
|
||||||
|
@ -100,6 +109,28 @@ static void QZ_SetPortAlphaOpaque () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)appDidHide:(NSNotification*)note
|
||||||
|
{
|
||||||
|
SDL_PrivateAppActive (0, SDL_APPACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)appDidUnhide:(NSNotification*)note
|
||||||
|
{
|
||||||
|
SDL_PrivateAppActive (1, SDL_APPACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
|
||||||
|
{
|
||||||
|
/* Make our window subclass receive these application notifications */
|
||||||
|
[ [ NSNotificationCenter defaultCenter ] addObserver:self
|
||||||
|
selector:@selector(appDidHide:) name:NSApplicationDidHideNotification object:NSApp ];
|
||||||
|
|
||||||
|
[ [ NSNotificationCenter defaultCenter ] addObserver:self
|
||||||
|
selector:@selector(appDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp ];
|
||||||
|
|
||||||
|
return [ super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag ];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* Delegate for our NSWindow to send SDLQuit() on close */
|
/* Delegate for our NSWindow to send SDLQuit() on close */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue