Event handling

Blog post by axeld on Mon, 2005-11-14 19:05

The font stuff is still not completed, but it works good enough to leave it as is for now. Missing is foremost work on the font cache - I haven’t done anything in this regard yet.

In the last days I’ve mostly fixed bugs, and cleaned up things - there are still enough bugs left, but overall things are improving. Next topic I’d like to work on is the event handling in the app_server.

While I haven’t got a detailed plan yet, the basic idea is to make it more flexible and move it out of the class currently taking care of it (RootLayer). While that probably wouldn’t keep me busy for too long, I will also try to move as much functionality as possible to the client. The app_server will only make sure the right window gets the event - the rest is mostly up to the client. An exception to this rule are views that are using the BView::SetEventMask() feature; they need special care as they may demand getting events even if they don’t have focus and are not below the mouse cursor.

I will also attack a problem that is mostly visible when using Haiku in Qemu or when an application becomes unresponsive: the mouse cursor visually hangs and makes navigation quite hard. The reason for this is quite simple: every mouse move is sent to the window below the mouse cursor - if that one is currently busy, the app_server waits a bit until it gives up sending the message: and that delay is what’s responsible for the hanging mouse cursor.

The solution to this problem is the decoupling of the “mouse moved” messages and the updating of the cursor on screen as BeOS does it for ages. A high priority thread will do nothing else than waiting for notifications that the mouse cursor has been moved - these notifications are not sent over ports, but use shared memory to cause as little delay as possible between the physical mouse move and the visual feedback on screen. Now the window can take as long as it wants to read its messages, it won’t impact the cursor movement anymore. Jérôme has already laid the foundation to this, and I will move this into the new event handling design and make sure it’ll work.