X11 calls that can fail silently.

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

1 post / 0 new
X11 calls that can fail silently.

 

Hi

Background
The motif Library calls several X11 functions that takes a timestamp as argument.
The X man pages mention that the the Call is NOT carried out of the TIMESTAMP is too old.
In some cases the Command/Query returns with some Error if this occurs.
( Examples XGrabPointer )
But for some calls there is nothing returned from the X server. This is at least the following calls:
XUngrabPointer, XUngrabKeyboard, XAllowEvents, XChangeActivePointerGrab, XSetInputFocus

There is no direct indication about the result of the call, if it failed or not, with regards to the timestamp.

Example of a situation:
# Grab occurs
XGrabXXX( aa, time )
Do some stuff
# Ungrab
XUngrabXXX( disp, time ) <= This could SILENTLY fail

Normally the Grab and Ungrab happens Very close to each other, so if one of the Grab/ or Ungrab fails the other
is very likely to fail as well.
But X11 could be run with XSynchronize or use some operations "Do some stuff" which could cause a Flush/XSync.
This could cause a delay between Grab and the Ungrab operations.

Proposal
For all calls which have the potential to silently fail because of a too old timestamp, use the constant
CurrentTime instead of a timestamp.
In all cases where XUngrabPointer or XUngrabKeyboard or XAllowEvents are used,
the program "wants" event processing to be activated/continued.
I cannot see any use for "selective" use of a timestamp that could enable events
in some cases and not in all cases.

The possibility of silent failure also exists for the XSetSelectionOwner,
but that call does not affect the event flow from X and cannot lock up the
system as if a XUngrabPointer or one of the other calls would fail.

Notes:
Not all X server seems to get into this situation (I think that some X servers ignore the timestamp).
I have only encountered this with system that has some delay/lag.

The suggested proposal can be simmulated by overriding the XUngrabPointer and the other calls
with something like LD_PRELOAD and change time argument to CurrentTime.