Linux
Stipple talks to the display server directly over its wire protocol: no GTK,
no Qt, no libwayland or libxcb.
Choosing a backend
App::run tries, in order:
- Wayland, when
$WAYLAND_DISPLAYnames a compositor socket; - X11, when
$DISPLAYis set; - headless, which renders one frame off-screen and returns.
Fonts
Font::system_default() loads the first of Liberation Sans, DejaVu Sans and Noto
Sans it finds in the usual /usr/share/fonts locations, and adds DejaVu Sans as
a fallback for glyphs the main font lacks. Japanese, Chinese and Korean text
draws from Noto Sans CJK (fonts-noto-cjk) or another installed CJK family,
loaded the first time text needs it (see fonts).
Shipping apps should bundle their font and load it with Font::from_bytes.
High-DPI
- X11: the scale is
Xft.dpi / 96, read from the root window'sRESOURCE_MANAGERproperty when the app starts, as GTK and Qt do. Desktops set it; to set it yourself, runxrdb -merge <<< 'Xft.dpi: 192'. Fractional values such as 144 (1.5x) work. - Wayland: the buffer scale follows the integer scale of the output the window is on, and changes when the window moves or the output's scale changes. With fractional scaling, the compositor resamples the next integer scale.
Appearance
Theme::native() reads color-scheme and accent-color from the XDG desktop
portal's settings (GNOME, KDE and others provide it). A GTK_THEME ending in
:dark also selects dark mode. With no portal, the theme is light. The portal
call gives up after 250 ms, so a missing portal can't stall startup. With
Theme::native(), a thread listens for the portal's SettingChanged signal, so
switching dark mode or the accent color restyles the app while it runs.
Controls stay self-drawn: Linux has no platform UI framework to draw them.
Clipboard
Both backends carry text, HTML (text/html) and images (image/png written;
PNG, BMP, JPEG, GIF and WebP read), and the primary selection: a text
field's selection becomes it, and a middle click on editable text pastes it at
the click (see text-editing.md).
- Wayland: copy and paste go through
wl_data_device, offering and acceptingtext/plain;charset=utf-8,UTF8_STRING,text/plainand the rich types. A paste reads the selection through a pipe and gives up after a second; the compositor's events are queued meanwhile, so the window keeps answering. Only the window with keyboard focus sees the selection, as the protocol requires. The primary selection useszwp_primary_selection_device_manager_v1when the compositor has it (sway, KWin, Mutter do). - X11: copying owns the
CLIPBOARD(orPRIMARY) selection and answersSelectionRequestforTARGETS, the text types (UTF8_STRING,STRING, …),text/htmlandimage/png. Pasting sendsConvertSelection(TARGETSfirst, then the best type per format;UTF8_STRING, thenSTRING, for an owner withoutTARGETS) and never blocks the loop: the answer comes back asSelectionNotifyand reaches the app asEvent::Clipboard, which theApppastes. Data bigger than one request travelsINCR, in both directions. A read whose owner stays silent ends after two seconds.
File dialogs
open_file, save_file and pick_folder use the portal's FileChooser, so they
work in Flatpak and Snap sandboxes and show the desktop's own picker. They need
xdg-desktop-portal and a backend such as xdg-desktop-portal-gtk.
Rendering on the GPU
With Renderer::Gpu (or STIPPLE_RENDERER=vulkan / gl), frames are drawn
with Vulkan or OpenGL ES and go straight to the window: a Vulkan swapchain or
an EGL window surface on X11 (over a libxcb connection of the GPU's own), and
on Wayland dma-bufs attached through zwp_linux_dmabuf_v1 on the backend's
own connection (the compositor's formats and modifiers from its feedback, a
few buffers taken back with wl_buffer.release, each frame's damage, frame
callbacks pacing them). The renderer picks the GPU the compositor names as
its main device. Where the compositor has wp_linux_drm_syncobj_v1, frames
go with explicit sync: the GPU's fence as each commit's acquire point,
buffers free once their release point signals, no wait for the GPU before
the commit. Under a title bar Stipple draws (no xdg-decoration: GNOME,
Weston) the frames go in a subsurface, the decorations in the window's own
surface around it. A compositor without zwp_linux_dmabuf_v1, or a driver
that can't export what the compositor takes, gets the GPU's frames read back
and presented through wl_shm. See gpu.md.
Debugging
STIPPLE_WAYLAND_DEBUG=1logs Wayland events, sizes and buffer scales (and thedma-bufformats and commits of GPU frames).STIPPLE_WAYLAND_DMABUF=0reads GPU frames back instead of handing the compositordma-bufs.STIPPLE_WAYLAND_SYNCOBJ=0keepsdma-bufframes off explicit sync (the renderer waits for the GPU before each commit).STIPPLE_X11_DEBUG=1logs X11 events.STIPPLE_COMPOSE_DEBUG=1reports the Compose table when it loads.
URLs that open the app
A .desktop file with MimeType=x-scheme-handler/myapp; and Exec=app %u
(made the default with xdg-mime default app.desktop x-scheme-handler/myapp)
starts the app with the URL as its argument, which App::on_open_url hears
as the loop starts. A URL while the app runs starts a second process, which
a single instance
hands to the running one. See
os-integration.md.
Packaging and D-Bus activation
cargo stipple linux stages the app under a prefix with its .desktop
file and hicolor icons, and a tarball of it (packaging.md).
With linux.dbus-activatable = true in the manifest and
App::dbus_activatable(true) in the app, the .desktop file says
DBusActivatable=true and a session bus .service file lets the bus start
the app: desktops call its org.freedesktop.Application (Activate,
Open, ActivateAction) with the launch's activation token, as for a
GApplication.
Known gaps
- Typed text comes from a simple reading of the keymap: Shift (and Caps Lock, on Wayland) pick the second level, but AltGr levels aren't applied yet. Dead keys and compose sequences work, from the locale's Compose file (see ime.md).
- Input methods (fcitx5, IBus) are wired up on Wayland through
text-input-v3(not yet tried with a real IME in CI), but not yet on X11.