<?xml version="1.0" encoding="UTF-8"?>
<protocol name="cont8nuum_shell_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="the cont8nuum shell and the compositor">
    The shell (Start, all apps, charms, flyouts, the switcher and the
    launch splash) is a client of its own. The compositor starts it over a
    private connection and only that client sees this global; it is
    started again if it exits.

    The compositor stays in charge of windows, input and the Start mode
    (whether Start covers the apps). The shell draws all of the shell,
    live tiles included: their content reaches the shell over D-Bus
    (org.cont8nuum.Tiles1), not through the compositor.

    All coordinates are logical pixels. Positions are relative to the
    output the shell lives on.
  </description>

  <interface name="c8_shell_v1" version="1">
    <enum name="error">
      <entry name="role" value="0" summary="the surface already has another role"/>
      <entry name="start_exists" value="1" summary="there is already a start surface"/>
    </enum>

    <enum name="role">
      <entry name="start" value="0" summary="Start: above apps, below layer-shell top surfaces; full output"/>
      <entry name="panel" value="1" summary="charms, flyouts, switcher: above layer-shell top surfaces"/>
      <entry name="splash" value="2" summary="the launch splash: above everything; full output"/>
      <entry name="osd" value="3" summary="volume and brightness: placed like a panel, but leaves the keyboard, clicks and hot corners alone"/>
      <entry name="bar" value="4" summary="XR's charms bar: off every screen, shown in the glasses while you look down (or after the charms binding); set_rect gives only its size"/>
    </enum>

    <enum name="action">
      <entry name="start" value="0" summary="Super tapped, or the Start binding"/>
      <entry name="search" value="1"/>
      <entry name="apps" value="2" summary="all apps"/>
      <entry name="charms" value="3"/>
      <entry name="settings" value="4" summary="the Settings charm"/>
      <entry name="corner_charms" value="5" summary="the pointer hit a right-hand hot corner"/>
      <entry name="corner_switcher" value="6" summary="the pointer hit the top-left hot corner with apps open"/>
      <entry name="volume_up" value="7"/>
      <entry name="volume_down" value="8"/>
      <entry name="volume_mute" value="9" summary="toggle"/>
      <entry name="mic_mute" value="10" summary="toggle"/>
      <entry name="brightness_up" value="11"/>
      <entry name="brightness_down" value="12"/>
      <entry name="media_play_pause" value="13"/>
      <entry name="media_next" value="14"/>
      <entry name="media_previous" value="15"/>
      <entry name="media_stop" value="16"/>
      <entry name="corner_start" value="17" summary="the pointer hit the bottom-left hot corner with apps open: a hint that a click there shows Start (or, on Start, the last app)"/>
      <entry name="project" value="18" summary="Super+P or the display key: the Second screen flyout"/>
    </enum>

    <enum name="power" bitfield="true">
      <entry name="sign_out" value="1" summary="a real session: sign out ends it"/>
      <entry name="exit" value="2" summary="nested in another desktop: exit closes the window"/>
      <entry name="lock" value="4"/>
      <entry name="sleep" value="8"/>
      <entry name="restart" value="16"/>
      <entry name="shut_down" value="32"/>
    </enum>

    <enum name="command">
      <entry name="pc_settings" value="0"/>
      <entry name="sign_out" value="1" summary="also exit, when nested"/>
      <entry name="lock" value="2"/>
      <entry name="sleep" value="3"/>
      <entry name="restart" value="4"/>
      <entry name="shut_down" value="5"/>
    </enum>

    <request name="get_surface">
      <description summary="give a surface a shell role">
        The surface is shown once it has a buffer, after the configure
        event. There is at most one start surface.
      </description>
      <arg name="id" type="new_id" interface="c8_shell_surface_v1"/>
      <arg name="surface" type="object" interface="wl_surface"/>
      <arg name="role" type="uint" enum="role"/>
    </request>

    <request name="set_start_visible">
      <description summary="show or hide Start">
        The compositor answers with start_visible, which may not be what
        was asked: with no apps open Start stays up.
      </description>
      <arg name="visible" type="uint"/>
    </request>

    <request name="launch">
      <description summary="run a command">
        Run it as the compositor runs commands from bindings, so @terminal,
        @settings and the like work.
      </description>
      <arg name="command" type="string"/>
    </request>

    <request name="run">
      <description summary="do something only the compositor can"/>
      <arg name="command" type="uint" enum="command"/>
    </request>

    <request name="set_appearance">
      <description summary="change a personalisation setting">
        The compositor saves it, tells PC settings, and sends the new
        values back with appearance events.
      </description>
      <arg name="key" type="string"/>
      <arg name="value" type="string"/>
    </request>

    <event name="start_visible">
      <description summary="Start was shown or hidden">
        Sent once after binding, and whenever it changes, for whatever
        reason (an app was focused, the last app closed).
      </description>
      <arg name="visible" type="uint"/>
    </event>

    <event name="action">
      <description summary="the user asked for part of the shell">
        From a key binding, the Super key or a hot corner.
      </description>
      <arg name="action" type="uint" enum="action"/>
    </event>

    <event name="switcher">
      <description summary="step through open apps">
        Alt+Tab and the like. modifiers is the wl_keyboard modifier mask the
        binding was pressed with: the switch happens once those are
        released. The panel should take the keyboard to see that.
      </description>
      <arg name="direction" type="int" summary="1 forward, -1 back"/>
      <arg name="modifiers" type="uint"/>
    </event>

    <event name="appearance">
      <description summary="a personalisation setting">
        Sent for every key after binding, then whenever one changes, each
        batch followed by appearance_done. Keys: accent and background
        (#rrggbb), pattern (none, circles, lines, squares), more_tiles and
        live_tiles (true, false), font, icon_theme. Unknown keys are to be
        ignored. Also project (what the screens show now:
        pc, duplicate, second, xr, or none with one screen) and
        project_choices (the ones that can be picked now, comma separated;
        empty with one screen); set_appearance("project", choice) picks
        one, which is saved as [display] project in config.ini.
        night_light (on, off) is whether Night light is warming the
        screens now; set_appearance("night_light", on or off) turns it on
        or off for now, until its schedule next turns.
      </description>
      <arg name="key" type="string"/>
      <arg name="value" type="string"/>
    </event>

    <event name="appearance_done"/>

    <event name="power">
      <description summary="which power commands there are">
        Sent once after binding, and when the configuration changes.
      </description>
      <arg name="available" type="uint" enum="power"/>
    </event>

    <event name="window">
      <description summary="an app window was opened">
        Sent for each open top-level window after binding, least recently
        used first, then as windows open.
      </description>
      <arg name="id" type="new_id" interface="c8_shell_window_v1"/>
    </event>


    <event name="locked">
      <description summary="the screen was locked or unlocked">
        Sent once after binding, then on every change. While locked, the
        shell's surfaces are hidden under the lock screen and get no
        input. Launching "@lock" locks the screen.
      </description>
      <arg name="locked" type="uint"/>
    </event>

    <event name="snap">
      <description summary="an app was snapped to a side">
        Sent when window is snapped to a side (-1 left, 1 right) and
        other apps could take the rest of the screen: x, y, width and
        height are that rest, where the shell shows their pictures to
        pick one from (activate puts it there). Only sent when there is
        a choice (at least one app besides the one already filling it).
        side 0 means it is over (unsnapped, or the app closed), or that
        the same two apps swapped sides or moved the split, which is no
        occasion for a pick: window is null and the rect empty. Sent
        once after binding if an app is snapped then, and on every
        change. While the pick is open (until the
        shell sends pick_done) the same window snapped to another side
        or with another split is sent again with the new rest: the
        pick follows it there rather than closing.
      </description>
      <arg name="window" type="object" interface="c8_shell_window_v1" allow-null="true"/>
      <arg name="side" type="int"/>
      <arg name="x" type="int"/>
      <arg name="y" type="int"/>
      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
    </event>


    <request name="set_start_width">
      <description summary="how wide Start's tiles run">
        From the left edge to past the last group, margins included. In
        XR the shell's screen is made that wide while Start
        is up (never narrower than it is), so every group shows without
        scrolling: there is room all round you.
      </description>
      <arg name="width" type="uint"/>
    </request>


    <request name="pick_done">
      <description summary="the pick for a snapped app's other side closed">
        An app was picked from it, or it was dismissed (Escape, a click
        outside, Start). Until this the compositor sends the open pick
        every move of its window's side or split; after it, only a
        fresh snap offers a pick again. window is the one the pick was
        for, so one closed after a newer snap event was sent is told
        apart.
      </description>
      <arg name="window" type="object" interface="c8_shell_window_v1" allow-null="true"/>
    </request>
  </interface>

  <interface name="c8_shell_surface_v1" version="1">
    <request name="destroy" type="destructor">
      <description summary="the surface loses its role"/>
    </request>

    <request name="set_rect">
      <description summary="where a panel goes">
        Panels, OSDs and the bar only (the bar's x and y are ignored: the
        compositor places it). Applied on the next surface commit, so a
        panel can slide by moving and committing. A changed size is
        answered with configure.
      </description>
      <arg name="x" type="int"/>
      <arg name="y" type="int"/>
      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
    </request>

    <request name="grab_keyboard">
      <description summary="take the keyboard">
        While on, this surface has the keyboard, over apps and Start. A
        hidden surface (no buffer) never has it. The bar taking it is
        brought up where you look and kept up until it lets go.
      </description>
      <arg name="grab" type="uint"/>
    </request>

    <event name="configure">
      <description summary="the size to draw at">
        Full output for start and splash, sent again when the output
        changes; the asked-for size for panels.
      </description>
      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
    </event>

    <event name="dismissed">
      <description summary="the user clicked outside the panel">
        The click itself goes nowhere. Panels, and the bar while it has
        the keyboard (grab_keyboard), which XR also sends when
        the bar goes from view or a press lands elsewhere.
      </description>
    </event>
  </interface>

  <interface name="c8_shell_window_v1" version="1">
    <description summary="an open app window">
      Sends title, app_id and focused, then done; again on every change.
    </description>

    <request name="destroy" type="destructor"/>

    <request name="activate">
      <description summary="bring it to the front and focus it">
        This hides Start.
      </description>
    </request>

    <request name="close"/>

    <request name="set_style">
      <description summary="the window's tile colour and icon">
        The compositor draws them on the window's title bar and drag card.
        icon is an icon name or path, or empty.
      </description>
      <arg name="rgb" type="uint"/>
      <arg name="icon" type="string"/>
    </request>

    <event name="title">
      <arg name="title" type="string"/>
    </event>

    <event name="app_id">
      <arg name="app_id" type="string"/>
    </event>

    <event name="focused">
      <description summary="it has the keyboard">
        The shell keeps the most-recently-used order from these.
      </description>
      <arg name="focused" type="uint"/>
    </event>

    <event name="done"/>

    <event name="closed">
      <description summary="the window went away">
        Destroy this object; requests on it are ignored from now on.
      </description>
    </event>


    <event name="pid">
      <description summary="the process the window belongs to">
        Sent once, before the first done. With several copies of an app
        open, it tells them apart (the shell asks the right one for its
        charms). 0 when not known (X11 windows).
      </description>
      <arg name="pid" type="uint"/>
    </event>


    <request name="capture">
      <description summary="draw a small picture of the window">
        The compositor draws the window's own surfaces (not what covers
        it, not its popups), scaled to fit within width x height keeping
        its shape and never larger than its logical size, into fd from
        offset 0: ARGB8888 with premultiplied alpha, rows of 4 x the
        drawn width bytes. fd must hold width x height x 4 bytes; width
        and height are at most 4096. Answered with captured.
      </description>
      <arg name="serial" type="uint" summary="handed back in captured"/>
      <arg name="fd" type="fd"/>
      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
    </request>

    <event name="captured">
      <description summary="the picture is in the fd">
        The size drawn, or 0 x 0 if nothing could be (the screen is
        locked, the window has nothing to show yet).
      </description>
      <arg name="serial" type="uint"/>
      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
    </event>
  </interface>
</protocol>
