TODO ---- * Command for executing new programs. * Commands for changing z order and focus. * Command for transferring icon. * Think about protocol version management * Try to assure that messages aren't repeated or are sent for hidden windows. Overview ======== The protocol is a line based protocol following this simple syntax: OPERATION[,ARG1[,ARG2,[...]]] The goal is to have a generic protocol that can be used for other display systems (e.g. VNC) as well. One line may not exceed 1024 bytes, including newline. The protocol has no concept of hidden or unmapped windows. A window does not exist unless it is visible. Note that a minimized window is an exception to this rule. Data types ========== Window ID are written in hex, like 0x4321. Window positions can be negative. This happens when a window is moved outside the desktop. All integers fit inside 32 bits. Strings are sent in UTF-8 and do not contain any characters less than 0x20 or the character , (comma). Server to Client Operations =========================== CREATE ------ Allocate structures for a new window. Syntax: CREATE,,, Indicates that a window has appeared on the server. If PARENT is non-zero then the new window is a child of that window (it's transient for it). Note that very little information is included in this message. Things like title and state will come in subsequent messages. This message should only be used to allocate data structures for the new window. DESTROY ------- Remove a window. Syntax: DESTROY,, Remove the window and deallocate all associated structures. POSITION -------- Move and/or resize a window. Syntax: POSITION,,,,,, If the window isn't visible yet (because a STATE hasn't been set or because it's minimized), you must store the position and size. A new POSITION is not guaranteed to be sent when the window changes state. TITLE ----- Sets a window title. Syntax: TITLE,,,<FLAGS> The text is guaranteed to be stripped of control characters (< 0x20). Note that this has the same requirement as POSITION, that the title needs to be stored for newly created windows until a STATE is sent. It is however not guaranteed that a TITLE will be sent before the first STATE. ZCHANGE ------- The window moved in z order. Syntax: ZCHANGE,<ID>,<BEHIND>,<FLAGS> The window with the id ID is behind the window with the id BEHIND. If BEHIND is 0, then this window should be brought to the front. STATE ----- Changes the window's state and/or title. Syntax: STATE,<ID>,<STATE>,<FLAGS> State can have one of three values: 0 : "Normal" window. 1 : Minimized. 2 : Maximized. The initial STATE for a window will always be preceeded by one CREATE and one POSITION. Optionally, a TITLE may also be sent before the first STATE. DEBUG ----- Debug output from the server component. Syntax: DEBUG,<STRING> Used for debugging. SYNCBEGIN --------- Indicates that a synchronisation has begun. Syntax: SYNCBEGIN,<FLAGS> Sent when the server starts a synchronisation. The client should flush all information at this point. SYNCEND ------- Indicates that a synchronisation is complete. Syntac: SYNCEND,<FLAGS> Sent when the last message that is part of the synchronisation has been sent. This may be followed by duplicate messages and/or messages referring invalid windows that were queued up during the synchronisation. Client to Server Operations =========================== SYNC ---- Request a synchronisation of window information. Syntax: SYNC,<FLAGS> For each window, the server will send CREATE, POSITION and STATE, in that order, just as if the window was created. Note that a TITLE may also, optionally, be sent before the STATE. POSITION -------- Identical to the command sent from server to client. TITLE ----- Identical to the command sent from server to client. ZCHANGE ------- Identical to the command sent from server to client. STATE ----- Identical to the command sent from server to client. FOCUS ----- Sets which window has input focus. Syntax: FOCUS,<ID>,<FLAGS> Changes which window that will recieve the keyboard events. Note that this might cause the window to change z order.