Skip navigation.
 
mlRe: Could kEventAppSystemUIModeChanged arrive too early to my handler
FROM : Jean-Daniel Dupas
DATE : Sun Jun 15 20:10:18 2008

Le 15 juin 08 à 18:15, Mohsan Khan a écrit :

> Hi
>
> I'm trying to handle when some other app changes to fullscreen by 
> handling the kEventAppSystemUIModeChanged event.
>
> The event handler is called but then when I check if the menu bar is 
> visibe I get TRUE!
>
> So I figured, either the apps I'm testing fullscreen mode with (VLC, 
> Photoshop) don't really enter fullscreen mode as they should like 
> Mac OS X wants an app too.
> Or, the event arrives too early, I even tried putting a 2 seconds 
> sleep but get the same result - menu is always visible.
>
> I must be doing something wrong here, maybe there is a simpler Cocoa 
> way?


The documentation is clear about this:

GetSystemUIMode:
....
Discussion:
This function returns information about the presentation mode of the 
calling application, not the presentation mode of the current login 
session.The login session mode may be different, since the login 
session mode is determined by the presentation mode of the frontmost 
application. If the calling application is not currently the frontmost 
application, then its presentation mode will not be in use. To track 
changes in the login session’s presentation mode, you may handle the 
kEventAppSystemUIModeChanged Carbon event.
Yo have to query the new mode directly into the event parameters (this 
is an UInt32 as returned by GetSystemUIMode()):

GetEventParameter(theEvent, kEventParamSystemUIMode, typeUInt32, …);


>
> pascal OSStatus AppEventHandler( EventHandlerCallRef inCallRef, 
> EventRef inEvent, void* inUserData )
> {
>     #pragma unused( inCallRef, inUserData )
>     
>     //sleep( 2 );
>     
>     OSStatus status = eventNotHandledErr;
>     
>     switch( GetEventClass( inEvent ) )
>     {
>         case kEventClassApplication:
>         {
>             NSLog( @"kEventClassApplication" );
>             
>             // check menu visibility, or ui mode
>             SystemUIMode *outMode;
>             SystemUIOptions *outOptions;
>             
>             GetSystemUIMode( outMode, outOptions );
>             
>             NSLog( @"UI mode: %d %d", *outMode, *outOptions );    // = 0 0
>             
>             NSLog( @"menu: %d", [NSMenu menuBarVisible] );        // = 1
>             NSLog( @"menu: %d", IsMenuBarVisible() );            // = 1
>             
>             status = noErr;        // everything went well, event handled
>         }
>         break;
>         
>         default:
>         {
>             NSLog( @"..." );
>         }
>         break;
>     }
>     
>     
>    return status;
> }
>
> static const EventTypeSpec sAppEvents[] = 
> { { kEventClassApplication, kEventAppSystemUIModeChanged } };
>
> InstallApplicationEventHandler( NewEventHandlerUPP( AppEventHandler ),
>                             GetEventTypeCount( sAppEvents ),
>                             sAppEvents, 0, NULL );
>
> Thanks.
>
>
> Yours sincerely,
>            Mohsan Khan.
> _______________________________________________________________
> www.xybernic.com
> There is no place like 127.0.0.1.
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlCould kEventAppSystemUIModeChanged arrive too early to my handler Mohsan Khan Jun 15, 18:15
mlRe: Could kEventAppSystemUIModeChanged arrive too early to my handler Jean-Daniel Dupas Jun 15, 20:10