[comp.windows.x] Why doesn't the WM_TAKE_FOCUS time work for XSetInputFocus?

denis@saturn.uucp (Denis Bohm) (10/03/90)

The ICCCM document states that "Clients must not use CurrentTime
in  the  ``time'' field." when using XSetInputFocus.  So I made
my code use the time from the WM TAKE FOCUS message, but this
doesn't work at all with mwm or olwm (it does work sometimes with
twm).  I changed my code to use CurrentTime instead and it now
seems to work fine.  Does anyone know why this is happening?
Will I have other problems from using CurrentTime?

From the ICCCM:
|> 4.2.7.  Input Focus
...
|> Once a client satisfies these conditions,  it  may  transfer
|> the  focus to another of its windows using the SetInputFocus
|> request:
|> 
|> SetInputFocus
|>         focus:  WINDOW or PointerRoot or None
|>         revert-to:      {Parent, PointerRoot, None}
|>         time:   TIMESTAMP or CurrentTime
|> 
|>      Convention: Clients using SetInputFocus  must  set
|>      the  ``time''  field to the timestamp of the event
|>      that caused them to make the attempt.   Note  that
|>      this cannot be a FocusIn event,  since they do not
|>      have timestamps,  and that clients may acquire the
|>      focus   without   a   corresponding   EnterNotify.
|>      Clients must not use CurrentTime in  the  ``time''
|>      field.

Denis Bohm    (usenet: decwrl!vlsisj!denis)
              (internet: vlsisj!denis@decwrl.dec.com)

) (10/06/90)

| The ICCCM document states that "Clients must not use CurrentTime
| in  the  ``time'' field." when using XSetInputFocus.  So I made
| my code use the time from the WM TAKE FOCUS message, but this
| doesn't work at all with mwm or olwm (it does work sometimes with
| twm).

This is odd.  I can see no reason that it wouldn't work, and in fact it
does work when done properly.  The bit about "sometimes" working under twm
makes me suspicious, because twm has a bug where it \always/ uses
CurrentTime to set the focus.

| I changed my code to use CurrentTime instead and it now
| seems to work fine.  Does anyone know why this is happening?
| Will I have other problems from using CurrentTime?

Yes, you will.  Please don't use CurrentTime.

What ICCCM focus model are you using?  If you want to use the Globally
Active model (like XView) you must ask for WM_TAKE_FOCUS and also set
WM_HINTS.input to False.  If you have WM_HINTS.input set to True, the
window manager will set the focus to your top-level window automatically.
If you also call XSetInputFocus in this case, you may be getting into a
"fight" with the window manager over the focus.

s'marks

Stuart W. Marks			ARPA: smarks@eng.sun.com
Windows & Graphics Software	UUCP: sun!smarks
Sun Microsystems, Inc.