[VM] Hooks from module into platform support code?

Tim Rowledge tim at sumeru.stanford.edu
Mon Oct 30 17:47:29 UTC 2000



Bert Freudenberg wrote:

> Hi folks,
>
> I'm implementing tablet support for X. This usually works by
> using XOpenDevice to, well, open the device, and then handling
> Device* events in the main loop.
>
> So I need to install an event handler in the main HandleEvent loop. Which
> is sorta difficult to do from a module (JoystickTabletPlugin in this
> case). It's not even easy to get at the stDisplay connection, which is a
> global in sqXWindow.

Take a look at how SocketPlugin & SoundPlugin do it (well, the sqUnixBlahBlah
files for those plugins) - basically you can set a global var in the
moduleInitialise and (ab)use the ability of the linker to connect it
properly. Check the aioPoll in sqXWindow.c to see how the polling is then
done.  Personally I prefer to have a callback function (that's what the
examples in the default 'platforms.export' illustrate) to do this simply
because it feels cleaner. Ian prefers the direct approach.

The disadvantage is that you still have to modify the sqXWindow.c to add the
call to the function; some time ago there was some discussion about how to
register functions for this stuff, but since sockets and sound (the two
current usages) require quite different arguments it seemed to be a bit
tricky. I guess it might be useful to have the general registry you suggest
for most cases and perhaps accept that sockets can't work that way.

tim





More information about the Squeak-dev mailing list