We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 55 - Cleaning up application activation/deactivation code on Mac OS X (Quartz)
Summary: Cleaning up application activation/deactivation code on Mac OS X (Quartz)
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 1.2
Hardware: PowerPC Mac OS X (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-19 12:28 UTC by Christian Walther
Modified: 2018-07-08 08:53 UTC (History)
2 users (show)

See Also:


Attachments
proposed patch (7.81 KB, patch)
2006-01-19 12:29 UTC, Christian Walther
Details | Diff
Proposed patch (Updated to apply to latest CVS) (7.54 KB, patch)
2006-03-22 13:49 UTC, Max Horn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Walther 2006-01-19 12:28:27 UTC
When writing my patch for #12, I ended up doing all sorts of changes to the way application/window activating/deactivating is handled in the Quartz backend, resulting in the attached patch. It does make the code a bit cleaner IMHO, but as it might be regarded as a case of "if it ain't broken, don't fix it" I'd like to hear other people's opinion about it. Please shout if some change strikes you as unnecessary or wrong, and I'll explain the reasons behind it. As far as I tested it, it does not introduce any new bugs, but I may well have missed some.

- The most fundamental change (that triggered most of the others) is irrelevant for the usual single-window SDL applications, it only affects the people who are crazy enough to display other Cocoa windows alongside the SDL window (I'm actually doing this currently, although the additional window only displays debugging info and won't be present in the final product): Before, some things were done on the application becoming active, some on the window becoming key, and some on the window becoming main. Conceptually, all these actions belong to the window becoming key, so that's what I implemented. However, since in a single-window application these three events always happen together, the previous implementation "ain't broken".

- This slightly changed the meaning of the SDL_APPMOUSEFOCUS flag from SDL_GetAppState(): Before, it meant "window is main and mouse is inside window (or mode is fullscreen)". Now, it means "window is key and mouse is inside window (or mode is fullscreen)". It makes more sense to me that way. (See http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Concepts/ChangingMainKeyWindow.html for a discussion of what key and main windows are.) The other two flags are unchanged: SDL_APPACTIVE = application is not hidden and window is not minimized, SDL_APPINPUTFOCUS = window is key (or mode is fullscreen).

- As a side effect, the reorganization fixes the following two issues (and maybe others) (but they could also be fixed in less invasive ways):

* A regression that was introduced in revision 1.42 of SDL_QuartzVideo.m (http://libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzVideo.m.diff?r1=1.41&r2=1.42) (from half-desirable to undesirable behavior):

Situation: While in windowed mode, hide the cursor using SDL_ShowCursor(SDL_DISABLE), move the mouse outside of the window so that the cursor becomes visible again, and SDL_SetVideoMode() to a fullscreen mode.
What happened before revision 1.42: The cursor is visible, but becomes invisible as soon as the mouse is moved (half-desirable).
What happens in revision 1.42 and after (including current CVS): The cursor is visible and stays visible (undesirable).
What happens after my patch: The cursor is invisible from the beginning (desirable).

* When the cursor is hidden and grabbed, switch away from the application using cmd-tab (which ungrabs and makes the cursor visible), move the cursor outside of the SDL window, then cmd-tab back to the application. In 1.2.8 and in the current CVS, the cursor is re-grabbed, but it stays visible (immovable in the middle of the window). With my patch, the cursor is correctly re-grabbed and hidden. (For some reason, it still doesn't work correctly if you switch back to the application using the dock instead of cmd-tab. I haven't been able to figure out why. I can step over [NSCursor hide] being called in the debugger, but it seems to have no effect.)

- The patch includes my patch for #12 (it was easier to obtain using cvs diff that way). If you apply both of them, you will end up with 6 duplicate lines in SDL_QuartzEvents.m.
Comment 1 Christian Walther 2006-01-19 12:29:22 UTC
Created attachment 26 [details]
proposed patch
Comment 2 Ryan C. Gordon 2006-01-27 11:23:17 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 3 Max Horn 2006-03-22 13:49:04 UTC
Created attachment 92 [details]
Proposed patch (Updated to apply to latest CVS)

The patch seems sane to me. I just recompiled SDL CVS with the patch applied. That way, both I and everybody using builds made by me will give it some testing :-). I'll return here when I either think it works fine, or find a problem.
Comment 4 Max Horn 2006-03-27 05:47:18 UTC
So far the patch worked flawlessly for me. I think it could safely be accepted, and would benefit SDL, as it both simplifies and fixes the activation handling.
Comment 5 Sam Lantinga 2006-04-13 10:18:04 UTC
This patch is in CVS, thanks!
Comment 6 Christian Walther 2006-04-14 09:51:27 UTC
Thanks, and thanks for testing, Max.
Comment 7 terence 2018-07-08 06:37:33 UTC
Comment on attachment 92 [details]
Proposed patch (Updated to apply to latest CVS)

>Index: src/video/quartz/SDL_QuartzEvents.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzEvents.m,v
>retrieving revision 1.41
>diff -u -d -r1.41 SDL_QuartzEvents.m
>--- src/video/quartz/SDL_QuartzEvents.m	21 Mar 2006 00:35:22 -0000	1.41
>+++ src/video/quartz/SDL_QuartzEvents.m	22 Mar 2006 18:44:15 -0000
>@@ -614,8 +614,10 @@
>     QZ_PrivateCocoaToSDL (this, p);
> }
> 
>-static void QZ_DoActivate (_THIS)
>-{
>+void QZ_DoActivate (_THIS) {
>+
>+    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ? SDL_APPMOUSEFOCUS : 0));
>+    
>     /* Hide the cursor if it was hidden by SDL_ShowCursor() */
>     if (!cursor_should_be_visible)
>         QZ_HideMouse (this);
>@@ -635,7 +637,9 @@
>     }
> }
> 
>-static void QZ_DoDeactivate (_THIS) {
>+void QZ_DoDeactivate (_THIS) {
>+    
>+    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
> 
>     /* Get the current cursor location, for restore on activate */
>     QZ_GetMouseLocation (this, &cursor_loc);
>@@ -753,14 +757,9 @@
>             BOOL isInGameWin;
>             
>             #define DO_MOUSE_DOWN(button) do {                                               \
>-                            if ( [ NSApp isActive ] ) {                                      \
>-                                if ( isInGameWin ) {                                         \
>-                                    SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);      \
>-                                    expect_mouse_up |= 1<<button;                            \
>-                                }                                                            \
>-                            }                                                                \
>-                            else {                                                           \
>-                                QZ_DoActivate (this);                                        \
>+                            if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {                   \
>+                                SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);          \
>+                                expect_mouse_up |= 1<<button;                                \
>                             }                                                                \
>                             [ NSApp sendEvent:event ];                                       \
>             } while(0)
>@@ -916,7 +915,7 @@
>                             QZ_ShowMouse (this);
>                     }
>                     else
>-                    if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
>+                    if ( isInGameWin && (SDL_GetAppState() & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) == SDL_APPINPUTFOCUS ) {
>                     
>                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>                         if (!cursor_should_be_visible)
>@@ -950,17 +949,7 @@
>                     break;
>                 case NSFlagsChanged:
>                     break;
>-                case NSAppKitDefined:
>-                    switch ( [ event subtype ] ) {
>-                        case NSApplicationActivatedEventType:
>-                            QZ_DoActivate (this);
>-                            break;
>-                        case NSApplicationDeactivatedEventType:
>-                            QZ_DoDeactivate (this);
>-                            break;
>-                    }
>-                    [ NSApp sendEvent:event ];
>-                    break;
>+                    /* case NSAppKitDefined: break; */
>                     /* case NSApplicationDefined: break; */
>                     /* case NSPeriodic: break; */
>                     /* case NSCursorUpdate: break; */
>Index: src/video/quartz/SDL_QuartzVideo.h
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.h,v
>retrieving revision 1.30
>diff -u -d -r1.30 SDL_QuartzVideo.h
>--- src/video/quartz/SDL_QuartzVideo.h	8 Mar 2006 06:21:04 -0000	1.30
>+++ src/video/quartz/SDL_QuartzVideo.h	22 Mar 2006 18:44:16 -0000
>@@ -224,3 +224,5 @@
> void         QZ_PrivateGlobalToLocal (_THIS, NSPoint *p);
> void         QZ_PrivateCocoaToSDL (_THIS, NSPoint *p);
> BOOL         QZ_IsMouseInWindow (_THIS);
>+void         QZ_DoActivate (_THIS);
>+void         QZ_DoDeactivate (_THIS);
>Index: src/video/quartz/SDL_QuartzVideo.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.m,v
>retrieving revision 1.57
>diff -u -d -r1.57 SDL_QuartzVideo.m
>--- src/video/quartz/SDL_QuartzVideo.m	15 Mar 2006 17:46:40 -0000	1.57
>+++ src/video/quartz/SDL_QuartzVideo.m	22 Mar 2006 18:44:16 -0000
>@@ -560,8 +560,8 @@
>     /* Save the flags to ensure correct tear-down */
>     mode_flags = current->flags;
> 
>-    /* we're fullscreen, so flag all input states... */
>-    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS | SDL_APPACTIVE);
>+    /* Set app state, hide cursor if necessary, ... */
>+    QZ_DoActivate(this);
> 
>     return current;
> 
>Index: src/video/quartz/SDL_QuartzWM.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWM.m,v
>retrieving revision 1.27
>diff -u -d -r1.27 SDL_QuartzWM.m
>--- src/video/quartz/SDL_QuartzWM.m	21 Feb 2006 08:47:46 -0000	1.27
>+++ src/video/quartz/SDL_QuartzWM.m	22 Mar 2006 18:44:17 -0000
>@@ -78,15 +78,14 @@
> }
> 
> void QZ_HideMouse (_THIS) {
>-    BOOL isInGameWin = QZ_IsMouseInWindow (this);
>-    if (isInGameWin && cursor_visible) {
>+    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
>         [ NSCursor hide ];
>         cursor_visible = NO;
>     }
> }
> 
> BOOL QZ_IsMouseInWindow (_THIS) {
>-    if (mode_flags & SDL_FULLSCREEN) return YES;
>+    if (qz_window == nil) return YES; /*fullscreen*/
>     else {
>         NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ];
>         p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */
>@@ -166,7 +165,7 @@
>         *p = [ window_view convertPoint:*p fromView: nil ];
>         
>         /* We need a workaround in OpenGL mode */
>-        if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
>+        if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) {
>             p->y = [window_view frame].size.height - p->y;
>         }
>     }
>Index: src/video/quartz/SDL_QuartzWindow.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWindow.m,v
>retrieving revision 1.11
>diff -u -d -r1.11 SDL_QuartzWindow.m
>--- src/video/quartz/SDL_QuartzWindow.m	9 Mar 2006 06:33:21 -0000	1.11
>+++ src/video/quartz/SDL_QuartzWindow.m	22 Mar 2006 18:44:17 -0000
>@@ -208,24 +208,12 @@
> 
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
>+    QZ_DoActivate (current_video);
> }
> 
> - (void)windowDidResignKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
>-}
>-
>-- (void)windowDidBecomeMain:(NSNotification *)aNotification
>-{
>-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
>-    if (this && QZ_IsMouseInWindow (this))
>-        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>-}
>-
>-- (void)windowDidResignMain:(NSNotification *)aNotification
>-{
>-    SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
>+    QZ_DoDeactivate (current_video);
> }
> 
> @end
Comment 8 terence 2018-07-08 08:52:01 UTC
Comment on attachment 92 [details]
Proposed patch (Updated to apply to latest CVS)

>Index: src/video/quartz/SDL_QuartzEvents.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzEvents.m,v
>retrieving revision 1.41
>diff -u -d -r1.41 SDL_QuartzEvents.m
>--- src/video/quartz/SDL_QuartzEvents.m	21 Mar 2006 00:35:22 -0000	1.41
>+++ src/video/quartz/SDL_QuartzEvents.m	22 Mar 2006 18:44:15 -0000
>@@ -614,8 +614,10 @@
>     QZ_PrivateCocoaToSDL (this, p);
> }
> 
>-static void QZ_DoActivate (_THIS)
>-{
>+void QZ_DoActivate (_THIS) {
>+
>+    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ? SDL_APPMOUSEFOCUS : 0));
>+    
>     /* Hide the cursor if it was hidden by SDL_ShowCursor() */
>     if (!cursor_should_be_visible)
>         QZ_HideMouse (this);
>@@ -635,7 +637,9 @@
>     }
> }
> 
>-static void QZ_DoDeactivate (_THIS) {
>+void QZ_DoDeactivate (_THIS) {
>+    
>+    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
> 
>     /* Get the current cursor location, for restore on activate */
>     QZ_GetMouseLocation (this, &cursor_loc);
>@@ -753,14 +757,9 @@
>             BOOL isInGameWin;
>             
>             #define DO_MOUSE_DOWN(button) do {                                               \
>-                            if ( [ NSApp isActive ] ) {                                      \
>-                                if ( isInGameWin ) {                                         \
>-                                    SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);      \
>-                                    expect_mouse_up |= 1<<button;                            \
>-                                }                                                            \
>-                            }                                                                \
>-                            else {                                                           \
>-                                QZ_DoActivate (this);                                        \
>+                            if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {                   \
>+                                SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);          \
>+                                expect_mouse_up |= 1<<button;                                \
>                             }                                                                \
>                             [ NSApp sendEvent:event ];                                       \
>             } while(0)
>@@ -916,7 +915,7 @@
>                             QZ_ShowMouse (this);
>                     }
>                     else
>-                    if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
>+                    if ( isInGameWin && (SDL_GetAppState() & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) == SDL_APPINPUTFOCUS ) {
>                     
>                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>                         if (!cursor_should_be_visible)
>@@ -950,17 +949,7 @@
>                     break;
>                 case NSFlagsChanged:
>                     break;
>-                case NSAppKitDefined:
>-                    switch ( [ event subtype ] ) {
>-                        case NSApplicationActivatedEventType:
>-                            QZ_DoActivate (this);
>-                            break;
>-                        case NSApplicationDeactivatedEventType:
>-                            QZ_DoDeactivate (this);
>-                            break;
>-                    }
>-                    [ NSApp sendEvent:event ];
>-                    break;
>+                    /* case NSAppKitDefined: break; */
>                     /* case NSApplicationDefined: break; */
>                     /* case NSPeriodic: break; */
>                     /* case NSCursorUpdate: break; */
>Index: src/video/quartz/SDL_QuartzVideo.h
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.h,v
>retrieving revision 1.30
>diff -u -d -r1.30 SDL_QuartzVideo.h
>--- src/video/quartz/SDL_QuartzVideo.h	8 Mar 2006 06:21:04 -0000	1.30
>+++ src/video/quartz/SDL_QuartzVideo.h	22 Mar 2006 18:44:16 -0000
>@@ -224,3 +224,5 @@
> void         QZ_PrivateGlobalToLocal (_THIS, NSPoint *p);
> void         QZ_PrivateCocoaToSDL (_THIS, NSPoint *p);
> BOOL         QZ_IsMouseInWindow (_THIS);
>+void         QZ_DoActivate (_THIS);
>+void         QZ_DoDeactivate (_THIS);
>Index: src/video/quartz/SDL_QuartzVideo.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.m,v
>retrieving revision 1.57
>diff -u -d -r1.57 SDL_QuartzVideo.m
>--- src/video/quartz/SDL_QuartzVideo.m	15 Mar 2006 17:46:40 -0000	1.57
>+++ src/video/quartz/SDL_QuartzVideo.m	22 Mar 2006 18:44:16 -0000
>@@ -560,8 +560,8 @@
>     /* Save the flags to ensure correct tear-down */
>     mode_flags = current->flags;
> 
>-    /* we're fullscreen, so flag all input states... */
>-    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS | SDL_APPACTIVE);
>+    /* Set app state, hide cursor if necessary, ... */
>+    QZ_DoActivate(this);
> 
>     return current;
> 
>Index: src/video/quartz/SDL_QuartzWM.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWM.m,v
>retrieving revision 1.27
>diff -u -d -r1.27 SDL_QuartzWM.m
>--- src/video/quartz/SDL_QuartzWM.m	21 Feb 2006 08:47:46 -0000	1.27
>+++ src/video/quartz/SDL_QuartzWM.m	22 Mar 2006 18:44:17 -0000
>@@ -78,15 +78,14 @@
> }
> 
> void QZ_HideMouse (_THIS) {
>-    BOOL isInGameWin = QZ_IsMouseInWindow (this);
>-    if (isInGameWin && cursor_visible) {
>+    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
>         [ NSCursor hide ];
>         cursor_visible = NO;
>     }
> }
> 
> BOOL QZ_IsMouseInWindow (_THIS) {
>-    if (mode_flags & SDL_FULLSCREEN) return YES;
>+    if (qz_window == nil) return YES; /*fullscreen*/
>     else {
>         NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ];
>         p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */
>@@ -166,7 +165,7 @@
>         *p = [ window_view convertPoint:*p fromView: nil ];
>         
>         /* We need a workaround in OpenGL mode */
>-        if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
>+        if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) {
>             p->y = [window_view frame].size.height - p->y;
>         }
>     }
>Index: src/video/quartz/SDL_QuartzWindow.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWindow.m,v
>retrieving revision 1.11
>diff -u -d -r1.11 SDL_QuartzWindow.m
>--- src/video/quartz/SDL_QuartzWindow.m	9 Mar 2006 06:33:21 -0000	1.11
>+++ src/video/quartz/SDL_QuartzWindow.m	22 Mar 2006 18:44:17 -0000
>@@ -208,24 +208,12 @@
> 
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
>+    QZ_DoActivate (current_video);
> }
> 
> - (void)windowDidResignKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
>-}
>-
>-- (void)windowDidBecomeMain:(NSNotification *)aNotification
>-{
>-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
>-    if (this && QZ_IsMouseInWindow (this))
>-        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>-}
>-
>-- (void)windowDidResignMain:(NSNotification *)aNotification
>-{
>-    SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
>+    QZ_DoDeactivate (current_video);
> }
> 
> @end
Comment 9 terence 2018-07-08 08:52:14 UTC
Comment on attachment 92 [details]
Proposed patch (Updated to apply to latest CVS)

>Index: src/video/quartz/SDL_QuartzEvents.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzEvents.m,v
>retrieving revision 1.41
>diff -u -d -r1.41 SDL_QuartzEvents.m
>--- src/video/quartz/SDL_QuartzEvents.m	21 Mar 2006 00:35:22 -0000	1.41
>+++ src/video/quartz/SDL_QuartzEvents.m	22 Mar 2006 18:44:15 -0000
>@@ -614,8 +614,10 @@
>     QZ_PrivateCocoaToSDL (this, p);
> }
> 
>-static void QZ_DoActivate (_THIS)
>-{
>+void QZ_DoActivate (_THIS) {
>+
>+    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ? SDL_APPMOUSEFOCUS : 0));
>+    
>     /* Hide the cursor if it was hidden by SDL_ShowCursor() */
>     if (!cursor_should_be_visible)
>         QZ_HideMouse (this);
>@@ -635,7 +637,9 @@
>     }
> }
> 
>-static void QZ_DoDeactivate (_THIS) {
>+void QZ_DoDeactivate (_THIS) {
>+    
>+    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
> 
>     /* Get the current cursor location, for restore on activate */
>     QZ_GetMouseLocation (this, &cursor_loc);
>@@ -753,14 +757,9 @@
>             BOOL isInGameWin;
>             
>             #define DO_MOUSE_DOWN(button) do {                                               \
>-                            if ( [ NSApp isActive ] ) {                                      \
>-                                if ( isInGameWin ) {                                         \
>-                                    SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);      \
>-                                    expect_mouse_up |= 1<<button;                            \
>-                                }                                                            \
>-                            }                                                                \
>-                            else {                                                           \
>-                                QZ_DoActivate (this);                                        \
>+                            if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {                   \
>+                                SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);          \
>+                                expect_mouse_up |= 1<<button;                                \
>                             }                                                                \
>                             [ NSApp sendEvent:event ];                                       \
>             } while(0)
>@@ -916,7 +915,7 @@
>                             QZ_ShowMouse (this);
>                     }
>                     else
>-                    if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
>+                    if ( isInGameWin && (SDL_GetAppState() & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) == SDL_APPINPUTFOCUS ) {
>                     
>                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>                         if (!cursor_should_be_visible)
>@@ -950,17 +949,7 @@
>                     break;
>                 case NSFlagsChanged:
>                     break;
>-                case NSAppKitDefined:
>-                    switch ( [ event subtype ] ) {
>-                        case NSApplicationActivatedEventType:
>-                            QZ_DoActivate (this);
>-                            break;
>-                        case NSApplicationDeactivatedEventType:
>-                            QZ_DoDeactivate (this);
>-                            break;
>-                    }
>-                    [ NSApp sendEvent:event ];
>-                    break;
>+                    /* case NSAppKitDefined: break; */
>                     /* case NSApplicationDefined: break; */
>                     /* case NSPeriodic: break; */
>                     /* case NSCursorUpdate: break; */
>Index: src/video/quartz/SDL_QuartzVideo.h
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.h,v
>retrieving revision 1.30
>diff -u -d -r1.30 SDL_QuartzVideo.h
>--- src/video/quartz/SDL_QuartzVideo.h	8 Mar 2006 06:21:04 -0000	1.30
>+++ src/video/quartz/SDL_QuartzVideo.h	22 Mar 2006 18:44:16 -0000
>@@ -224,3 +224,5 @@
> void         QZ_PrivateGlobalToLocal (_THIS, NSPoint *p);
> void         QZ_PrivateCocoaToSDL (_THIS, NSPoint *p);
> BOOL         QZ_IsMouseInWindow (_THIS);
>+void         QZ_DoActivate (_THIS);
>+void         QZ_DoDeactivate (_THIS);
>Index: src/video/quartz/SDL_QuartzVideo.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.m,v
>retrieving revision 1.57
>diff -u -d -r1.57 SDL_QuartzVideo.m
>--- src/video/quartz/SDL_QuartzVideo.m	15 Mar 2006 17:46:40 -0000	1.57
>+++ src/video/quartz/SDL_QuartzVideo.m	22 Mar 2006 18:44:16 -0000
>@@ -560,8 +560,8 @@
>     /* Save the flags to ensure correct tear-down */
>     mode_flags = current->flags;
> 
>-    /* we're fullscreen, so flag all input states... */
>-    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS | SDL_APPACTIVE);
>+    /* Set app state, hide cursor if necessary, ... */
>+    QZ_DoActivate(this);
> 
>     return current;
> 
>Index: src/video/quartz/SDL_QuartzWM.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWM.m,v
>retrieving revision 1.27
>diff -u -d -r1.27 SDL_QuartzWM.m
>--- src/video/quartz/SDL_QuartzWM.m	21 Feb 2006 08:47:46 -0000	1.27
>+++ src/video/quartz/SDL_QuartzWM.m	22 Mar 2006 18:44:17 -0000
>@@ -78,15 +78,14 @@
> }
> 
> void QZ_HideMouse (_THIS) {
>-    BOOL isInGameWin = QZ_IsMouseInWindow (this);
>-    if (isInGameWin && cursor_visible) {
>+    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
>         [ NSCursor hide ];
>         cursor_visible = NO;
>     }
> }
> 
> BOOL QZ_IsMouseInWindow (_THIS) {
>-    if (mode_flags & SDL_FULLSCREEN) return YES;
>+    if (qz_window == nil) return YES; /*fullscreen*/
>     else {
>         NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ];
>         p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */
>@@ -166,7 +165,7 @@
>         *p = [ window_view convertPoint:*p fromView: nil ];
>         
>         /* We need a workaround in OpenGL mode */
>-        if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
>+        if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) {
>             p->y = [window_view frame].size.height - p->y;
>         }
>     }
>Index: src/video/quartz/SDL_QuartzWindow.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWindow.m,v
>retrieving revision 1.11
>diff -u -d -r1.11 SDL_QuartzWindow.m
>--- src/video/quartz/SDL_QuartzWindow.m	9 Mar 2006 06:33:21 -0000	1.11
>+++ src/video/quartz/SDL_QuartzWindow.m	22 Mar 2006 18:44:17 -0000
>@@ -208,24 +208,12 @@
> 
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
>+    QZ_DoActivate (current_video);
> }
> 
> - (void)windowDidResignKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
>-}
>-
>-- (void)windowDidBecomeMain:(NSNotification *)aNotification
>-{
>-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
>-    if (this && QZ_IsMouseInWindow (this))
>-        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>-}
>-
>-- (void)windowDidResignMain:(NSNotification *)aNotification
>-{
>-    SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
>+    QZ_DoDeactivate (current_video);
> }
> 
> @end
Comment 10 terence 2018-07-08 08:52:31 UTC
Comment on attachment 92 [details]
Proposed patch (Updated to apply to latest CVS)

>Index: src/video/quartz/SDL_QuartzEvents.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzEvents.m,v
>retrieving revision 1.41
>diff -u -d -r1.41 SDL_QuartzEvents.m
>--- src/video/quartz/SDL_QuartzEvents.m	21 Mar 2006 00:35:22 -0000	1.41
>+++ src/video/quartz/SDL_QuartzEvents.m	22 Mar 2006 18:44:15 -0000
>@@ -614,8 +614,10 @@
>     QZ_PrivateCocoaToSDL (this, p);
> }
> 
>-static void QZ_DoActivate (_THIS)
>-{
>+void QZ_DoActivate (_THIS) {
>+
>+    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ? SDL_APPMOUSEFOCUS : 0));
>+    
>     /* Hide the cursor if it was hidden by SDL_ShowCursor() */
>     if (!cursor_should_be_visible)
>         QZ_HideMouse (this);
>@@ -635,7 +637,9 @@
>     }
> }
> 
>-static void QZ_DoDeactivate (_THIS) {
>+void QZ_DoDeactivate (_THIS) {
>+    
>+    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
> 
>     /* Get the current cursor location, for restore on activate */
>     QZ_GetMouseLocation (this, &cursor_loc);
>@@ -753,14 +757,9 @@
>             BOOL isInGameWin;
>             
>             #define DO_MOUSE_DOWN(button) do {                                               \
>-                            if ( [ NSApp isActive ] ) {                                      \
>-                                if ( isInGameWin ) {                                         \
>-                                    SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);      \
>-                                    expect_mouse_up |= 1<<button;                            \
>-                                }                                                            \
>-                            }                                                                \
>-                            else {                                                           \
>-                                QZ_DoActivate (this);                                        \
>+                            if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {                   \
>+                                SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);          \
>+                                expect_mouse_up |= 1<<button;                                \
>                             }                                                                \
>                             [ NSApp sendEvent:event ];                                       \
>             } while(0)
>@@ -916,7 +915,7 @@
>                             QZ_ShowMouse (this);
>                     }
>                     else
>-                    if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
>+                    if ( isInGameWin && (SDL_GetAppState() & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) == SDL_APPINPUTFOCUS ) {
>                     
>                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>                         if (!cursor_should_be_visible)
>@@ -950,17 +949,7 @@
>                     break;
>                 case NSFlagsChanged:
>                     break;
>-                case NSAppKitDefined:
>-                    switch ( [ event subtype ] ) {
>-                        case NSApplicationActivatedEventType:
>-                            QZ_DoActivate (this);
>-                            break;
>-                        case NSApplicationDeactivatedEventType:
>-                            QZ_DoDeactivate (this);
>-                            break;
>-                    }
>-                    [ NSApp sendEvent:event ];
>-                    break;
>+                    /* case NSAppKitDefined: break; */
>                     /* case NSApplicationDefined: break; */
>                     /* case NSPeriodic: break; */
>                     /* case NSCursorUpdate: break; */
>Index: src/video/quartz/SDL_QuartzVideo.h
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.h,v
>retrieving revision 1.30
>diff -u -d -r1.30 SDL_QuartzVideo.h
>--- src/video/quartz/SDL_QuartzVideo.h	8 Mar 2006 06:21:04 -0000	1.30
>+++ src/video/quartz/SDL_QuartzVideo.h	22 Mar 2006 18:44:16 -0000
>@@ -224,3 +224,5 @@
> void         QZ_PrivateGlobalToLocal (_THIS, NSPoint *p);
> void         QZ_PrivateCocoaToSDL (_THIS, NSPoint *p);
> BOOL         QZ_IsMouseInWindow (_THIS);
>+void         QZ_DoActivate (_THIS);
>+void         QZ_DoDeactivate (_THIS);
>Index: src/video/quartz/SDL_QuartzVideo.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.m,v
>retrieving revision 1.57
>diff -u -d -r1.57 SDL_QuartzVideo.m
>--- src/video/quartz/SDL_QuartzVideo.m	15 Mar 2006 17:46:40 -0000	1.57
>+++ src/video/quartz/SDL_QuartzVideo.m	22 Mar 2006 18:44:16 -0000
>@@ -560,8 +560,8 @@
>     /* Save the flags to ensure correct tear-down */
>     mode_flags = current->flags;
> 
>-    /* we're fullscreen, so flag all input states... */
>-    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS | SDL_APPACTIVE);
>+    /* Set app state, hide cursor if necessary, ... */
>+    QZ_DoActivate(this);
> 
>     return current;
> 
>Index: src/video/quartz/SDL_QuartzWM.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWM.m,v
>retrieving revision 1.27
>diff -u -d -r1.27 SDL_QuartzWM.m
>--- src/video/quartz/SDL_QuartzWM.m	21 Feb 2006 08:47:46 -0000	1.27
>+++ src/video/quartz/SDL_QuartzWM.m	22 Mar 2006 18:44:17 -0000
>@@ -78,15 +78,14 @@
> }
> 
> void QZ_HideMouse (_THIS) {
>-    BOOL isInGameWin = QZ_IsMouseInWindow (this);
>-    if (isInGameWin && cursor_visible) {
>+    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
>         [ NSCursor hide ];
>         cursor_visible = NO;
>     }
> }
> 
> BOOL QZ_IsMouseInWindow (_THIS) {
>-    if (mode_flags & SDL_FULLSCREEN) return YES;
>+    if (qz_window == nil) return YES; /*fullscreen*/
>     else {
>         NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ];
>         p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */
>@@ -166,7 +165,7 @@
>         *p = [ window_view convertPoint:*p fromView: nil ];
>         
>         /* We need a workaround in OpenGL mode */
>-        if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
>+        if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) {
>             p->y = [window_view frame].size.height - p->y;
>         }
>     }
>Index: src/video/quartz/SDL_QuartzWindow.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWindow.m,v
>retrieving revision 1.11
>diff -u -d -r1.11 SDL_QuartzWindow.m
>--- src/video/quartz/SDL_QuartzWindow.m	9 Mar 2006 06:33:21 -0000	1.11
>+++ src/video/quartz/SDL_QuartzWindow.m	22 Mar 2006 18:44:17 -0000
>@@ -208,24 +208,12 @@
> 
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
>+    QZ_DoActivate (current_video);
> }
> 
> - (void)windowDidResignKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
>-}
>-
>-- (void)windowDidBecomeMain:(NSNotification *)aNotification
>-{
>-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
>-    if (this && QZ_IsMouseInWindow (this))
>-        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>-}
>-
>-- (void)windowDidResignMain:(NSNotification *)aNotification
>-{
>-    SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
>+    QZ_DoDeactivate (current_video);
> }
> 
> @end
Comment 11 terence 2018-07-08 08:53:35 UTC
Comment on attachment 92 [details]
Proposed patch (Updated to apply to latest CVS)

>Index: src/video/quartz/SDL_QuartzEvents.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzEvents.m,v
>retrieving revision 1.41
>diff -u -d -r1.41 SDL_QuartzEvents.m
>--- src/video/quartz/SDL_QuartzEvents.m	21 Mar 2006 00:35:22 -0000	1.41
>+++ src/video/quartz/SDL_QuartzEvents.m	22 Mar 2006 18:44:15 -0000
>@@ -614,8 +614,10 @@
>     QZ_PrivateCocoaToSDL (this, p);
> }
> 
>-static void QZ_DoActivate (_THIS)
>-{
>+void QZ_DoActivate (_THIS) {
>+
>+    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ? SDL_APPMOUSEFOCUS : 0));
>+    
>     /* Hide the cursor if it was hidden by SDL_ShowCursor() */
>     if (!cursor_should_be_visible)
>         QZ_HideMouse (this);
>@@ -635,7 +637,9 @@
>     }
> }
> 
>-static void QZ_DoDeactivate (_THIS) {
>+void QZ_DoDeactivate (_THIS) {
>+    
>+    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
> 
>     /* Get the current cursor location, for restore on activate */
>     QZ_GetMouseLocation (this, &cursor_loc);
>@@ -753,14 +757,9 @@
>             BOOL isInGameWin;
>             
>             #define DO_MOUSE_DOWN(button) do {                                               \
>-                            if ( [ NSApp isActive ] ) {                                      \
>-                                if ( isInGameWin ) {                                         \
>-                                    SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);      \
>-                                    expect_mouse_up |= 1<<button;                            \
>-                                }                                                            \
>-                            }                                                                \
>-                            else {                                                           \
>-                                QZ_DoActivate (this);                                        \
>+                            if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {                   \
>+                                SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);          \
>+                                expect_mouse_up |= 1<<button;                                \
>                             }                                                                \
>                             [ NSApp sendEvent:event ];                                       \
>             } while(0)
>@@ -916,7 +915,7 @@
>                             QZ_ShowMouse (this);
>                     }
>                     else
>-                    if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
>+                    if ( isInGameWin && (SDL_GetAppState() & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) == SDL_APPINPUTFOCUS ) {
>                     
>                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>                         if (!cursor_should_be_visible)
>@@ -950,17 +949,7 @@
>                     break;
>                 case NSFlagsChanged:
>                     break;
>-                case NSAppKitDefined:
>-                    switch ( [ event subtype ] ) {
>-                        case NSApplicationActivatedEventType:
>-                            QZ_DoActivate (this);
>-                            break;
>-                        case NSApplicationDeactivatedEventType:
>-                            QZ_DoDeactivate (this);
>-                            break;
>-                    }
>-                    [ NSApp sendEvent:event ];
>-                    break;
>+                    /* case NSAppKitDefined: break; */
>                     /* case NSApplicationDefined: break; */
>                     /* case NSPeriodic: break; */
>                     /* case NSCursorUpdate: break; */
>Index: src/video/quartz/SDL_QuartzVideo.h
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.h,v
>retrieving revision 1.30
>diff -u -d -r1.30 SDL_QuartzVideo.h
>--- src/video/quartz/SDL_QuartzVideo.h	8 Mar 2006 06:21:04 -0000	1.30
>+++ src/video/quartz/SDL_QuartzVideo.h	22 Mar 2006 18:44:16 -0000
>@@ -224,3 +224,5 @@
> void         QZ_PrivateGlobalToLocal (_THIS, NSPoint *p);
> void         QZ_PrivateCocoaToSDL (_THIS, NSPoint *p);
> BOOL         QZ_IsMouseInWindow (_THIS);
>+void         QZ_DoActivate (_THIS);
>+void         QZ_DoDeactivate (_THIS);
>Index: src/video/quartz/SDL_QuartzVideo.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzVideo.m,v
>retrieving revision 1.57
>diff -u -d -r1.57 SDL_QuartzVideo.m
>--- src/video/quartz/SDL_QuartzVideo.m	15 Mar 2006 17:46:40 -0000	1.57
>+++ src/video/quartz/SDL_QuartzVideo.m	22 Mar 2006 18:44:16 -0000
>@@ -560,8 +560,8 @@
>     /* Save the flags to ensure correct tear-down */
>     mode_flags = current->flags;
> 
>-    /* we're fullscreen, so flag all input states... */
>-    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS | SDL_APPACTIVE);
>+    /* Set app state, hide cursor if necessary, ... */
>+    QZ_DoActivate(this);
> 
>     return current;
> 
>Index: src/video/quartz/SDL_QuartzWM.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWM.m,v
>retrieving revision 1.27
>diff -u -d -r1.27 SDL_QuartzWM.m
>--- src/video/quartz/SDL_QuartzWM.m	21 Feb 2006 08:47:46 -0000	1.27
>+++ src/video/quartz/SDL_QuartzWM.m	22 Mar 2006 18:44:17 -0000
>@@ -78,15 +78,14 @@
> }
> 
> void QZ_HideMouse (_THIS) {
>-    BOOL isInGameWin = QZ_IsMouseInWindow (this);
>-    if (isInGameWin && cursor_visible) {
>+    if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
>         [ NSCursor hide ];
>         cursor_visible = NO;
>     }
> }
> 
> BOOL QZ_IsMouseInWindow (_THIS) {
>-    if (mode_flags & SDL_FULLSCREEN) return YES;
>+    if (qz_window == nil) return YES; /*fullscreen*/
>     else {
>         NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ];
>         p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */
>@@ -166,7 +165,7 @@
>         *p = [ window_view convertPoint:*p fromView: nil ];
>         
>         /* We need a workaround in OpenGL mode */
>-        if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
>+        if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) {
>             p->y = [window_view frame].size.height - p->y;
>         }
>     }
>Index: src/video/quartz/SDL_QuartzWindow.m
>===================================================================
>RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/quartz/SDL_QuartzWindow.m,v
>retrieving revision 1.11
>diff -u -d -r1.11 SDL_QuartzWindow.m
>--- src/video/quartz/SDL_QuartzWindow.m	9 Mar 2006 06:33:21 -0000	1.11
>+++ src/video/quartz/SDL_QuartzWindow.m	22 Mar 2006 18:44:17 -0000
>@@ -208,24 +208,12 @@
> 
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
>+    QZ_DoActivate (current_video);
> }
> 
> - (void)windowDidResignKey:(NSNotification *)aNotification
> {
>-    SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
>-}
>-
>-- (void)windowDidBecomeMain:(NSNotification *)aNotification
>-{
>-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
>-    if (this && QZ_IsMouseInWindow (this))
>-        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
>-}
>-
>-- (void)windowDidResignMain:(NSNotification *)aNotification
>-{
>-    SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
>+    QZ_DoDeactivate (current_video);
> }
> 
> @end