-
Notifications
You must be signed in to change notification settings - Fork 91
X11 Event Loop
Integration with X11 is written in the Self language itself. At various places in Self the X11 routines are called to find pending X11 events and action them. The glue code mapping these X11 primitives to C++ are in objects/glue/xlib_glue.cpp and related files.
The Morphic environment has an event loop that executes discrete steps. It starts by worldMorph forking a Self process in forkStepProcess which runs startStepProcess to loop in the background executing doStep. This handles the updating of the world and processing of inputs.
doStep calls processInputs which process any events in the X input queue. That method iterates over all window canvas objects calling dispatchFrom on the handMorph.
The handMorph handles most of the event dispatching. dispatchFrom calls getEventFromWindowCanvas: which calls nextEvent on the windowCanvas object. nextEvent results in a call to the X11 primitive XNextEvent().
Given the X11 event, a call is made to convert that to an ui2Event, which is the Self abstract event. It checks for different types of events (mouse, keyboard, window, etc) and forwards them to objects that have previously registered as interested in the events. See handleAndForward:To: in handMorph for details.
The worldMorph calls subscribeWindow on initialization to subscribe to Window event types. This is how it actions X11 window events. When an event happens the handMorph will call windowEvent: in the subscribed worldMorph.