X Event

In the current implementation, an event structure is received in a fixed event buffer (an integer-vector of 25 elements) and the same buffer is reused on all events. The event structure has to be copied when more than one events need to be referenced at the same time.

Window-main-loop is the function which captures all events sent from the X server and delivers them to each window where the event happened.



event [variable]

a 25-element integer-vector holding the most recent event structure.


next-event [function]

stores the event structure in event and returns it if there is at least one pending event, NIL if there is no pending event.


event-type event [function]

returns the keyword symbol representing the event-type in the event structure. The event-type keywords are: :KeyPress (2), :KeyRelease (3), :ButtonPress (4), :ButtonRelease (5), :MotionNotify (6), :EnterNotify (7), :LeaveNotify (8), :FocusIn (9), :FocusOut (0), :KeymapNotify (1), :Expose (12), :GraphicsExpose (13), :NoExpose (14), :VisibilityNotify (15), :CreateNotify (16), :DestroyNotify (17), :UnmapNotify (18), :MapNotify (19), :MapRequest (20), :ConfigureNotify (22), :ConfigureRequest (23), :GravityNotify (24), :ResizeRequest (25), :CirculateNotify (26), :CirculateRequest (27), :PropertyNotify (28), :SelectionClear (29), :SelectionRequest (30), :SelectionNotify (31), :ColormapNotify (32), :ClientMessage (33), :MappingNotify (34), :LASTEvent (35).


event-window event [function]

returns the window object where the event occurred.


event-x event [function]

extracts the x coordinate, (i.e., the horizontal position of the mouse pointer relatively in the window) out of the event.


event-y event [function]
extracts the x coordinate, (i.e., the vertical position of the mouse pointer relatively in the window) out of the event.


event-width event [function]
returns the eighth element of the event structure which represents the width parameter at the :configureNotify event.


event-height event [function]
returns the ninth element of the event structure which represents the height parameter at the :configureNotify event.


event-state event [function]
returns a list of keywords representing the mouse button and modifier key state. Keywords are: :shift, :control, :meta, :left, :middle and :right. For example, if left mouse button is pressed while shift key is down, (:shift :left) is returned.


display-events [function]
displays all xwindow events captured by x:nextevent. Control-C is the only way to terminate this function.


window-main-loop &rest forms [macro]

receives Xevents and delivers them to window objects where the event occurred. According to the event-type, methods in the window's class named :KeyPress, :KeyRelease, :ButtonPress, :ButtonRelease, :MotionNotify, :EnterNotify, :LeaveNotify and :ConfigureNotify are invoked with event as the argument. If forms is given, evaluates them each time event arrival is checked.


window-main-thread [function]

Do the same thing as window-main-loop in a different thread. Window-main-thread is only available on Solaris2. Window-main-thread installs an error handler which does not enter a read-eval-print loop. After printing the error information, the event processing continues.


k-okada 2013-05-21