the messages between heimdalld (the window server) and its clients.
a client connects to the Unix socket HEIM_SOCKET. every message, in both directions, is one heim_msg_t of 64 bytes. a message that carries an open file (a shared memory buffer) has it in an SCM_RIGHTS control message sent with it.
the start: the client sends HEIM_REQ_HELLO, the server answers with HEIM_EV_WELCOME (the screen size).
a window: the client picks a window number (not 0, its own), sends HEIM_REQ_CREATE, then HEIM_REQ_ATTACH with a shared memory buffer of premultiplied ARGB pixels, draws into it, and sends HEIM_REQ_COMMIT with the part it changed. the window shows after its first commit. after a commit, the server sends HEIM_EV_FRAME when the change is on the screen; a client that draws again before that can be seen half drawn.
the server draws the title bar and the buttons (server-side decorations); the size of a window is the size of its content. a window is placed by the server. HEIM_EV_CONFIGURE asks the client for another size (maximize, a resize with the mouse): the client attaches a buffer of that size and commits it.
a popup (a menu, a select's choices, a popover, a tooltip) is a window with HEIM_WINDOW_POPUP and a parent window. it has no decorations and its pixels can be see-through; the client draws its shadow in a margin around it. HEIM_REQ_PLACE gives a rect in the parent's content to show it next to and a side; the server puts it there, on the other side when there is no room, and inside the screen. a popup is above its parent and gets the keyboard (a tooltip, HEIM_WINDOW_TOOLTIP, gets no input at all). a press outside the open popups closes them: each gets HEIM_EV_CLOSE, and the press goes nowhere else.
a panel (HEIM_WINDOW_PANEL) is a bar of the desktop shell: the server puts it at the bottom of the screen, the full width (it sends HEIM_EV_CONFIGURE for the width), above the windows. its height is not part of the work area: maximized and new windows stay above it. a click on it does not take the keyboard from the window that has it.
the shell: one client can ask to be the shell (HEIM_REQ_SHELL, the first that asks). it then gets HEIM_EV_WINDOW for each normal window when the window shows or changes (title, state), HEIM_EV_WINDOW_APP with the program of the window, and HEIM_EV_WINDOW_GONE; the window field is 0 and info.id is the server's number for the window. the shell can activate, minimize and close any window (HEIM_REQ_ACT) and end the session (HEIM_REQ_QUIT).