Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slouken committed May 29, 2003
1 parent 6e7ff9d commit 74475ac
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/video/quartz/SDL_QuartzEvents.m
Expand Up @@ -583,6 +583,16 @@ but not as a result of the warp (so it's in the right direction).

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;
case NSScrollWheel:
if ( isInGameWin ) {
Expand Down
31 changes: 31 additions & 0 deletions src/video/quartz/SDL_QuartzWindow.m
Expand Up @@ -31,6 +31,9 @@ @interface SDL_QuartzWindow : NSWindow
- (void)miniaturize:(id)sender;
- (void)display;
- (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

@implementation SDL_QuartzWindow
Expand All @@ -51,6 +54,9 @@ - (void)miniaturize:(id)sender
QZ_SetPortAlphaOpaque ();
}

/* window is hidden now */
SDL_PrivateAppActive (0, SDL_APPACTIVE);

[ super miniaturize:sender ];
}

Expand All @@ -63,6 +69,9 @@ - (void)display
*/
if ( (SDL_VideoSurface->flags & SDL_OPENGL) == 0)
QZ_SetPortAlphaOpaque ();

/* window is visible again */
SDL_PrivateAppActive (1, SDL_APPACTIVE);
}

- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
Expand Down Expand Up @@ -100,6 +109,28 @@ - (void)setFrame:(NSRect)frameRect display:(BOOL)flag
}
}

- (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

/* Delegate for our NSWindow to send SDLQuit() on close */
Expand Down

0 comments on commit 74475ac

Please sign in to comment.