Re: [g-a-devel]accessible state of foreground application



David Bolter wrote:
... 
> i am currently trying to figure out the right way to get the Accessible* to
> the foreground application (without having to trigger on an event).

I believe that tracking events is a better approach.
 
> i was wondering if i could count on the foreground application to have the 
> SPI_STATE_ACTIVE state (if not now - then in the future?).  if i am going about 
> this all wrong please call me on it ;-)

Not sure about whether the foreground application will have
SPI_STATE_ACTIVE set, this depends on what happens in gail.  Padraig?
 
> here's an attempt at solving my task (modified sample code) but the 
> stateset seems to be 0...  (i tried a few examples from /gnome/head/cvs/gtk+/examples)
> 
> // left off here...
> Accessible* gok_get_foreground_accessible ()
> {
>         int i,j;
>         int n_desktops;
>         int n_apps;
>         Accessible* desktop;
>         Accessible* application;
>         AccessibleStateSet* stateset;
> 
>         n_desktops = SPI_getDesktopCount ();
> 
>         for (i=0; i<n_desktops; ++i)
>         {
>                 desktop = SPI_getDesktop (i);
>                 n_apps = Accessible_getChildCount (desktop);
>                 for (j=0; j<n_apps; ++j)
>                 {
>                         application = Accessible_getChildAtIndex (desktop, j);
>                         stateset = Accessible_getStateSet(application);
>                         printf("looking at an app state set: %d\n",stateset);
>                         if (AccessibleStateSet_contains(stateset, SPI_STATE_ACTIVE) == TRUE)
>                         {
>                                 printf("found active app\n");
>                                 Accessible_unref (desktop);
>                                 return application;
>                         }
>                         Accessible_unref (application);
>                 }
>                 Accessible_unref (desktop);
>         }
>         return NULL;
> }
> 
> thoughts?

I think that a much better approach is to track focus, and
navigate upwards via Accessible_getParent ().  You can tell
when you are at the toplevel by:

(a) checking to see that role is SPI_ROLE_TOPLEVEL or
    one of the other "toplevel" roles;

(b) checking to see that getParent () returns an AccessibleApplication.

It may be reasonable to expect that your approach should work also, but
I don't think it's as efficient when dealing with a desktop with
lots of apps on it.  Also it's possible that more than one app
is "active", the semantics are not guaranteed since "active" doesn't
mean
"has keyboard focus".
 
We may consider adding an Accessible_getToplevel () call in the future,
to
get the toplevel window accessible of any given Accessible object, but
probably can't do that before GNOME 2.0 FCS unless there is no
workaround.

Best regards,

Bill

> cheers,
> 
> ~~david
> 
> _______________________________________________
> Gnome-accessibility-devel mailing list
> Gnome-accessibility-devel gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-accessibility-devel



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]