From time to time things are happening in Pharo that are not mentioned in the mailing-lists because there are experiences or just work in progress. We want to share one with you.
Ronie Salgado and Igor Stasenko wanted to accelerate the Cairo, openGL and other renderings.
So they started to create at the image level a way to access all the OS elements for windowings (events and properties) and as such shortcut the old VM code. They can now create windows on X11 and get all the events. They convert the OS events into Morphic events and everything works. This is interesting because it is probably the architecture of future Pharo. We will need to define similar primitives to other platforms and to define some new Events and logic at the image level. They designed a OSWindow abstraction and new event hierarchies.
And this is really exciting.
Here is one of the mails that they sent internally:
Today we worked on translating most basic events like mouse and keyboard.
Things vent quite smooth and we managed to make most of things working:
– mouse movement
– mouse buttons
– and even mouse wheel events without much hassle
Keyboard was also relatively easy to convert, up to the point that most of basic keys work including control ones. But it is not quite complete..
As a bonus, now we can receive separate events generated from pressing keys like shitf/ctrl etc… the only thing which makes me sad is that morphic events tend to obscure and obfuscate things…
We do 2-step translation:
X11 event hierarchy -> OSEvent hierarchy -> Morphic event hierarchy
The OSEvent will be our new platform-neutral evens, which is similar what we did with Stef for SystemEvent(s), except that it doesn’t relies on VM and tries to preserve all of the information which original event(s) has.
Like that there is always a way to deal with special cases if extra information is needed.
Morphic events is a big mess, and translation is lossy, but we just want to make things work more or less fine, and deal with problems step by step.
What is fun, that all this event handling stuff written purely with smalltalk, with FFI and system quite responsive and there is no noticeable lags/whatever.