Event System Design

Peter William Lount peter at smalltalk.org
Sun Jun 20 20:09:01 UTC 1999


Hi,

I am wondering if anyone can describe in detail the mouse/keyboard event
system used in Squeak VM and Squeak Image. In particular, I am interested
in how events flow from the hardware to the VM and up to the Image object
level. I am also wondering if "events" can be lost in this process if
Squeak is busy or if the events just get queued somewhere.

Is is polled or "event driven"? Are the events coming from the OS Window
event queue or are they polled or a combination of the two? Is this the
same on every port of Squeak?

It seems that, on the Windows version of Squeak, events are recorded when
messages are received from the Window that Squeak calls home. These events
are placed in VM global variables defined in the file: "sqWin32Window.c".

/*** Variables -- Event Recording ***/
#define KEYBUF_SIZE 64

int keyBuf[KEYBUF_SIZE];	/* circular buffer */
int keyBufGet= 0;		/* index of next item of keyBuf to read */
int keyBufPut= 0;		/* index of next item of keyBuf to write */
int keyBufOverflows= 0;	        /* number of characters dropped */

int buttonState= 0;		/* mouse button and modifier state when mouse
				   button went down or 0 if not pressed */

Then what happens to the events?

It looks like key presses get a buffer of upto 64 characters while the
mouse buttons get a single value. This design looks like it could loose
mouse button presses as only the most current one is remembered. Why are
they not stored in an "event list" made up of Smalltalk "event" objects
directly in the VM code that records them (recordKeystroke,
recordMouseDown, recordModifierButtons)? Does this happen later? If so,
where?

Is it possible to miss events like a mouse up, mouse move, or mouse down if
Squeak is busy doing something else at the time? Or do the events end up in
some queue somewhere?

Thanks...

Peter William Lount
http://www.smalltalk.org
peter at smalltalk.org





More information about the Squeak-dev mailing list