Comment by qb45
13 years ago
X11 clients communicate with the server using Unix domain sockets or TCP sockets. Requests, responses and event notifications are exchanged as messages.
Asynchronous communication is achieved using syscalls like select and poll which take a set of file descriptors (files, special files, sockets) and block the calling thread until some descriptor from this set has new data available for reading, starts accepting writes or signals an error.
GUI toolkits repeatedly poll the X server descriptor, parse incoming messages and call application-defined callbacks.
> poll and select
That sounds like it's basically the same thing as Windows (GetMessage or MsgWaitForMultipleObjectsEx anyone?)... only that now you don't have the ability to use SendMessage, and need to rely exclusively on PostMessage instead.
Is that correct?
Between threads, you rely exclusively on PostMessage anyway. You can't directly call into a routine on a different thread, so SendMessage to a window owned by another thread just posts the message to a special queue that's serviced before the regular message queue, then blocks until the other thread's window procedure processes the message.
In all boils down to message-passing: in Windows, the win32k is the trusted third party that mediates interactions between different window-system clients. In the X11 case, the X server and the window manager work together to do the same job. The architecture are fundamentally similar.
Hmm... yeah, that does sound very similar.
Why does Windows need kernel-to-user callbacks in the first place then? Now I'm thinking it shouldn't even be necessary at all...
4 replies →