Scapegoat TIL

TIL - X11 Selection Protocol Internals

Protocol Flow

  1. On Copy:

    Owner sends SelectionClear to previous owner
    Owner sends SelectionNotify claiming ownership
    Sets XA_PRIMARY or CLIPBOARD atom
    
  2. On Paste Request:

    Requestor -> Owner: SelectionRequest
      - target atom (desired format)
      - property atom (where to put data)
      - requestor window ID
    
    Owner -> Requestor: SelectionNotify  
      - sets property on requestor's window with data
      - or None if format unavailable
    
  3. Format Discovery:

    Request with target=TARGETS
    Owner responds with array of atom IDs
    Each atom ID = supported format
    

All data transfer happens through X server window properties - no direct IPC between apps. Max property size = server's max request size (usually ~256KB).

Large transfers split into multiple INCR protocol chunks.