CNP - Compositor Notification Protocol CNP is designed for use between an X compositor client and other X clients who may have redirected drawables. The CNP helps facilitate memory and performance savings by allowing redirected clients to reduce their memory size and bandwidth consumption. It can also enable throttling for redirected clients. Normally, redirected client buffer swaps and other operations complete immediately (because there's no vertical blank event to synchronize with). Using this protocol, the compositor and client can interact, and the compositor can drive frame and drawable updates from clients. To implement memory size and bandwidth savings, CNP aware clients can, when connected to a CNP aware compositor, use single buffered rendering, sending CNPDrawableReady notifications to the compositor as each frame finishes drawing. This eliminates the back->front copy overhead as well as the memory consumed the extra offscreen buffer. To implement throttling, clients simply have to stop drawing until they receive a CNPDrawableConsumed event. This will throttle them to the compositor's framerate, and prevent unnecessary drawing that won't ever be displayed to the end user. Protocol definitions ┌─── CNPDrawableReady 2 1 CNPDrawableReady opcode 2 8 length 4 DRAWABLE drawable ▶ └─── Notifies the compositor that the drawable ID indicated by drawable is ready to be composited into a new frame. Depending on the server implementation, it may be best for the client to wait until it receives a swap event message before sending this message to the compositor. In other cases, simply sending it after a glXSwapBuffers or copy sub-buffer request is sufficient. Note that unless the client is using triple buffering or is otherwise not modifying the drawable sent to the compositor by this message, it should wait until it receives the CNPDrawableConsumed message (described below) before doing further drawing. This prevents partially drawn drawables from being composited into an on-screen frame. ┌─── CNPDrawableConsumed 2 2 CNPDrawableConsumed opcode 2 8 length 4 DRAWABLE drawable ▶ └─── This message comes from the compositor and indicates to clients that their previously complete drawable has been consumed (likely copied or sourced for an on-screen frame update). Upon receiving this message, clients can resume drawing to the drawable previously submitted to the compositor. Ports To implement the protocol, the compositor should listen for client connections on a local port (how should this be advertised; D-bus? unix sockets? what about remote clients?)