Re: AXRaise problem with Cocoa apps
Re: AXRaise problem with Cocoa apps
- Subject: Re: AXRaise problem with Cocoa apps
- From: Rainer Brockerhoff <email@hidden>
- Date: Mon, 15 Dec 2008 18:24:31 -0200
At 12:01 -0800 13/12/08, email@hidden wrote:
>Date: Fri, 12 Dec 2008 18:04:41 -0200
>From: Rainer Brockerhoff <email@hidden>
>Message-ID: <p0624080bc5687233a0bb@[192.168.1.100]>
>
>I'm running into a weird problem with my Klicko utility (http://www.brockerhoff.net/klicko).
>Basically, I install an event tap to identify clicks on background windows.
>If the clicked-on window is not a main window, I send AXRaise to it to bring it to the front. Also, if the app it belongs to isn't the front process, I call SetFrontProcess on it to make it so.
>That seems to work well for either case, and also with Carbon apps. However, for Cocoa apps, this doesn't work consistently if the app is in the background _and_ the window isn't the main window.
>Usually, the window I'm AXRaising _does_ become the main window but it stays behind the window that was the main window before that! Most confusing.
Replying to myself here, for the list archives. There were two separate issues, in fact.
What was happening is that I was placing the event tap with kCGAnnotatedSessionEventTap. At that point, the event is already "annotated" with the pid of the destination process. However, it seems that while annotating the event, the Quartz Event Manager also identifies clicks on the window's title bar and sets the window's owning app to be the front process _before_ passing the event onwards to the tap... and it expects taps not to suppress such an event afterwards.
Changing the tap to kCGSessionEventTap fixed that, and allows me to suppress the event, and call SetFrontProcess myself. I suppose I should file a bug on the documentation, which is completely silent on this difference.
The second issue seems to stem from a difference in the way Carbon and Cocoa handle the AXRaise command when the owning process is in the background. In order to cover all bases without having to test what sort of application I'm sending the command to, and to cover some other edge cases, I for now do it in 4 steps:
- send AXRaise to the window
- install an observer on the application
- call SetFrontProcess
- in the observer callback, when the application is activated, send AXRaise again.
I know, rather clunky; but it works.
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden