Re: How to programmatically detect that Mission Control is running?
Re: How to programmatically detect that Mission Control is running?
- Subject: Re: How to programmatically detect that Mission Control is running?
- From: Kyle Sluder <email@hidden>
- Date: Mon, 22 Oct 2012 09:09:12 -0700
On Oct 21, 2012, at 11:05 PM, Daiwei Li <email@hidden> wrote:
>
> You might try a Quartz event tap at kCGSessionEventTap. I suspect that
>> -addGlobalMonitorForEventsMatchingMask:... is equivalent to
>> kCGAnnotatedSessionEventTap, and maybe that's the wrong place for Mission
>> Control. (Although I would hope that its events would be routed in the
>> usual manner. *shrug*)
>
>
> I haven't tried this. I suspect it would be the same as the Cocoa API, and
> in any case, requires my application to be accessibility enabled.
>
>> I'm not sure why you're looking to treat Mission Control differently than
>> all Mac apps have treated the application switcher for its entire history –
>> which is to say, ignored it.
>
>
> It doesn't pose a problem to most applications because in most
> applications, there's not much damage you can do by having a mouse button
> held down indefinitely. The application I'm working on uses a mouse to
> drive a robot. Having it held down when the user doesn't intend it to is a
> safety hazard.
Rather than a global event tap, try installing a local event monitor using +[NSEvent addLocalMonitorForEventsMatchingMask:handler:] and watching out for events of type NSSystemDefined. Local monitors, unlike global ones or global CGEvent taps, do not require assistive access enabled.
Have your handler abort your mouse-tracking loop if it gets an event that looks like Mission Control. I cant recall specifically what such an event looks like. We had to do this to work around some mouse-tracking bugs with Spaces in 10.7.
Alternatively, if you're running the mouse tracking loop yourself, you can just check the return value of -[NSApplication nextEventMatchingMask::::]. But I'm kind of partial to the idea of installing the handler once and signalling to all possible mouse tracking loops that could be running that they should abort.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden