discuss-gnustep
[Top][All Lists]
Advanced

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

Re: focus problem


From: Fred Kiefer
Subject: Re: focus problem
Date: Tue, 21 Aug 2007 14:47:38 +0200
User-agent: Thunderbird 1.5.0.12 (X11/20060911)

Andreas Höschler wrote:
> Hi Yen-Ju,
> 
> I have played some more with Azalea and the focus problem. The problem
> can easily be reproduced by adding a menu item to any application and doing
> 
> - (void)test
> {
>     [[NSWorkspace sharedWorkspace] launchApplication:@"TextEdit"];
> }
> 
> in the corresponding method. I tried this with GNOME, Window Maker and
> Azalea. With all three window managers I got the same result. If the
> above method is called for the first time (TextEdit.app not yet
> running), then the application is correctly started and gets key focus.
> However, if the app is already running, then it is activated, but it
> does not get key focus.
> 
> This seems to be a general problem in GNUstep, nothing specifically
> related to Azalea.
> 


I think I finally found the reason for this problem and as often it
turns out to be rather simple and actually the same problem as the one I
already solved:
The time send along with the XSetInputFocus call is to old, so the
request to set the focus is ignored by the X server.
For this last problem this was caused by the variable generic.lastTime
not being set up properly, it was initialized with 1 and not with
CurrentTime. In our new case the problem is more subtle. The code tries
to keep the time of the last event to use this as the time for the focus
change, based on the reasoning the any focus change must be triggered by
an event and if we set the stored time for every event we are always as
current as the focus change. This reasoning isn't true for the case
where an application gets activated without an event. In our case it was
activated by a DO call from another program. Now the last event time for
the application that is to activate is older then the one at the server
and the request gets ignored.
One simple workaround here is to always use CurrentTime as the time for
the focus change. This of course has some risks, we work around the
protection mechanism of the X server and may easily end up with a race
condition, when a user switches focus too fast. But for the moment this
is the best solution I see.

Any comments?

Fred




reply via email to

[Prev in Thread] Current Thread [Next in Thread]