adw@Reading.ac.uk (Anthony Worrall) wrote:
> When you open a ToolTalk conection you get back a file descriptor which is used
> for passing messages. This is okay because the library contains all the code
> for sending a receiving messages. But the one thing you need to do is setup
> an async alerting method so you know when to receive a message. The recomended
> version of application using the Xtoolkit is :-
> ...
>
> The problem is that the pop11 version of XtAppAddInput (XptAppAddInout) expects
> a device and not a file descriptor.
You can use XptLoadProcedures to get to the C version of
XtAppAddInput. Here is an example:
XptLoadProcedures tt_procs lvars XtAppAddInput;
;;; does no type checking. Discards any result.
define myXtAppAddInput(app, fd, mask, efc);
exacc (5) raw_XtAppAddInput(app, fd, mask, efc, 0);
enddefine;
Note the efc is an external function closure. You can get one
of using make_exfunc_closure. Here is a more worked out example:
compile_mode :pop11 +strict;
include xt_constants;
XptLoadProcedures tt_example lvars XtAppAddInput;
constant procedure register_tt_input_callback; ;;; forward decl.
define tt_input_callback(exptr); lvars exptr;
lvars message = exacc tt_message_receive();
... do stuff here
register_tt_input_callback();
enddefine;
constant tt_input_efc = make_exfunc_closure(tt_input_callback,
XptCallbackFlags, false);
define register_tt_input_callback;
exacc (5) rawXtAppAddInput(XptDefaultAppContext, tt_fd,
XtInputReadMask || XtInputExceptMask, tt_input_efc, 0);
enddefine;
Hope this helps. Jon.
|