Next: Installation
Up: Using Xlib Primitives
Previous: Displaying Maps
The following points should be kept in mind
when using the Xlib primitives:
- The window used for Xlib output must be completely displayed
before it can be initialised.
To make sure this is the case, it is possible to use
the Tk command tkwait visibility window
,
or the command update
.
- Some Xlib primitives do not require a round trip to the
X server are thus very fast, others are slower.
Moreover, the messages to the X server are buffered and flushed
only from time to time.
Explicit flushing forces an immediate display update
but it also slows down the execution.
- Most arguments of Xlib functions are simply integeres or pointers.
If a bad number is passed as argument,
the X server emits an error message with the name
of the bad request, but it might also crash.
Seemingly serious problems can thus be caused just by a wrong
value of an argument.
- Because of buffering, it often happens that if the X server
encounters a bad request, it send the error message only
after the next buffer flush which may occur long after the bad request
has been issued.
To enforce an immediate reaction of the X server, you can start
Tk with the sync flag, tk([sync]), which causes
each request to be executed immediately and all errors recognised
right after the bad function.
- Tk does not know about drawings done directly through Xlib
and it may erase parts of them during its own updates.
It is probably not a good idea to mix Tk and Xlib primitives
inside the same widget.
The update problems can be usually solved by setting an event
handler which updates the Xlib display when it was erased by Tk,
and to trigger the Xlib operations only after Tk has processed
all events.
This can be done using the Tk commands update
or
after idle
like in our map or rainbow examples.
- Xlib drawings also disappear when their window is covered
by another one or iconised and then exposed again.
The ProTcXl Xlib primitives use by default the BackingStore
facility to minimise these problems, but not all X servers support it
and it does not guarantee display consistence all the time.
To handle this problem correctly, you should catch the Expose
and/or Configure events and make a complete or partial
redrawing of the window contents.
- When using direct Xlib calls, it is quite likely that the
particular Xlib function is not present in the ECLiPSe binary.
If this happens, you can either load it dynamically, using
the -u Name option in the
load/1
predicate,
or to insert a call of this function to the _dummy
function in the ProTcXl file xlib.c and reinstall it.
Next: Installation
Up: Using Xlib Primitives
Previous: Displaying Maps
Micha Meier
Tue Jul 2 09:49:39 MET DST 1996