<?xml version="1.0" encoding="UTF-8"?>
<protocol name="cont8nuum_stereo_v1">
  <copyright>
    Written by lowtide, 2026. To the extent possible under law, the
    author has dedicated all copyright and related and neighbouring
    rights to this file to the public domain worldwide (CC0 1.0, see
    the LICENSE file or https://creativecommons.org/publicdomain/zero/1.0/).
    It is distributed without any warranty.
  </copyright>

  <description summary="3D and all-round pictures on a surface">
    A video player (or anything else with such pictures) says with this
    what a surface's buffers hold, so that XR glasses can show each eye
    its own picture of a 3D one, and put an all-round one round the
    viewer instead of on a window.

    A client only knows the frame; what an eye sees is the compositor's
    to draw. So where the compositor says it shows such pictures (the
    shows event), the client attaches the whole frame, both eyes'
    pictures in it or the whole sphere, and says how it is laid out.
    Where it doesn't (a flat screen), the surface is shown like any
    other, and the client is left to take the frame apart itself.

    Any client may use it.
  </description>

  <interface name="c8_stereo_manager_v1" version="1">
    <request name="destroy" type="destructor">
      <description summary="destroy the manager">
        Stereo surfaces made from it live on.
      </description>
    </request>

    <enum name="error">
      <entry name="exists" value="0"
        summary="the surface already has a stereo object"/>
    </enum>

    <request name="get_stereo_surface">
      <description summary="say what a surface's pictures are">
        A wl_surface has one stereo object at most. Subsurfaces are the
        usual ones to have one: the video under a window's controls.
      </description>
      <arg name="id" type="new_id" interface="c8_stereo_surface_v1"/>
      <arg name="surface" type="object" interface="wl_surface"/>
    </request>
  </interface>

  <interface name="c8_stereo_surface_v1" version="1">
    <description summary="what one surface's buffers hold">
      What is said here holds from the moment it is said, for the buffer
      the surface has then and the ones after: say it right before the
      commit of the first buffer it is true of.
    </description>

    <request name="destroy" type="destructor">
      <description summary="the surface is an ordinary one again"/>
    </request>

    <enum name="layout">
      <entry name="mono" value="0" summary="one picture: not 3D"/>
      <entry name="side_by_side" value="1"
        summary="the eyes' pictures are the buffer's left and right halves"/>
      <entry name="top_bottom" value="2"
        summary="the eyes' pictures are the buffer's top and bottom halves"/>
    </enum>

    <enum name="projection">
      <entry name="flat" value="0" summary="a picture on the surface"/>
      <entry name="sphere" value="1"
        summary="equirectangular, all the way round: 360 by 180 degrees"/>
      <entry name="half_sphere" value="2"
        summary="equirectangular, the half in front: 180 by 180 degrees"/>
    </enum>

    <enum name="shows" bitfield="true">
      <entry name="stereo" value="1"
        summary="each eye gets its own picture of a 3D surface"/>
      <entry name="surround" value="2"
        summary="sphere and half_sphere surfaces are put round the viewer"/>
    </enum>

    <request name="set_layout">
      <description summary="where each eye's picture is in the buffer">
        The surface's size (its viewport's destination, usually) is one
        picture's; each eye is shown its half of the buffer stretched
        over it. Where one picture is shown for both eyes, it is the
        left eye's. right_first: the right eye's picture is the left or
        top half.
      </description>
      <arg name="layout" type="uint" enum="layout"/>
      <arg name="right_first" type="uint" summary="0 or 1"/>
    </request>

    <request name="set_projection">
      <description summary="what the picture is of">
        A sphere or half sphere is shown round the viewer, its middle
        straight ahead, and not on the surface's place in its window.
        Its layout still says where each eye's sphere is.
      </description>
      <arg name="projection" type="uint" enum="projection"/>
    </request>

    <event name="shows">
      <description summary="what the compositor does with such surfaces now">
        Sent once after the object is made and again whenever it
        changes (glasses plugged in or switched to their 3D mode, XR
        left). While a bit is off, don't say that of a surface: with
        stereo off attach one eye's picture and say mono; with surround
        off draw the part of the sphere to show yourself and say flat.
      </description>
      <arg name="shows" type="uint" enum="shows"/>
    </event>
  </interface>
</protocol>
