Skip to content

Desktop icons

Desktop icons live in Kestrel, in kestrel/ui/src/desktop/icons. Their settings are in com.lantharos.kestrel.desktop, and Icons on the desktop says how to use them.

Folder Holds
model The placement model: grid and free arrangement, and the places remembered per display
sources The Desktop folder, drives and network locations, the home folder and the trash, as entries
view The layer of icons, selection, the rubber band, keyboard focus and dragging
actions Opening, file operations, the clipboard and the right-click menus

With icons off, Kestrel only watches that one key. Turning it on creates the layer, starts watching the Desktop folder, the volume monitor and the trash, and turning it off again destroys all of it.

The icons sit in one reactive actor that spans the stage, in the desktop layer above the wallpaper and below every window. While a live wallpaper plays, its window is a desktop window, so the layer moves into the window group just above it, as extension layers below windows do. The layer is hidden in the overview and on a board, and takes the desktop’s right-click menu over from the wallpaper, adding its own entries in front.

Each icon is a fixed-size actor placed with set_position, so nothing is laid out again when icons change: an icon whose entry changed gets new artwork, one that moved glides to its new place, and the rest are left alone. Pictures are decoded through glycin, in its sandbox, two at a time, at the icon’s size; a file with a valid thumbnail in the shared thumbnail cache, as Rover makes them, uses that instead.

Everything on the desktop is an item with a span of columns and rows, one by one for an icon. Each display’s work area is a grid of cells sized for the icon size.

  • Grid fills cells column by column on the main display first, from the right in right-to-left languages, and moves on to the next display when one is full. An item bigger than one cell takes every cell it covers.
  • Free puts each item where it was left, as pixels from the top corner of its display’s work area. Items with no place yet take the first cell nothing covers, and are remembered there so they don’t move when other files come and go. A drop that would cover another item moves to the nearest spot along the edges of what’s in the way.

Places are kept in places as JSON, from a display’s connector and resolution to its items. A display at a resolution it has no places for borrows them from the same connector at another resolution, scaled. Switching from the grid to free placement first remembers where the grid had everything.

The model knows nothing about icons beyond their span, so widgets can share it: a widget is an item of a few cells, and the grid and free placement keep icons out of its way.

The Desktop folder is watched with one file monitor. Changes are collected and handled together once they stop for 120 ms, or after 600 ms at most; each changed name is looked up again, and more than 64 at once read the whole folder again instead. Drives follow the volume monitor, at most once per main loop pass, and UDisks decides which to leave out: EFI, BIOS boot, Microsoft reserved, Windows recovery and swap partitions, anything that isn’t a filesystem (such as a locked LUKS or BitLocker container), devices UDisks marks to ignore, filesystems mounted at Luft’s own root, /boot, /efi, /sysroot, /var, /etc or /usr, and unnamed internal partitions under 2 GB. An unnamed NTFS partition is called Windows. LUFT_SYSTEM_ROOT moves Luft’s root for test sessions, as it does for Disks.

A drag starts as a real Wayland drag from the shell, through meta_dnd_start_shell_drag() in Kestrel’s Mutter. It offers the selected files as text/uri-list, x-special/gnome-copied-files and through the document portal, the same way copying them does, so Rover, other Wayland apps and X11 apps take them as they would from another app, copying or moving as they choose. Kestrel draws the dragged icons itself and follows the drag’s position, and shell-drag-end says how it ended.

Over Kestrel’s own actors the drag arrives like any file drag from an app: the desktop takes it on folders, drives, the home folder and the trash, or as a new place when icons are free, and apps on the taskbar open the files. Files dropped within one filesystem move, and between filesystems they are copied; holding Ctrl copies. Folders from an app’s drag get a symbolic link in the Desktop folder instead. Icons with no local path, such as the trash, can’t be handed to apps, so when icons are free they move with a pointer grab inside the shell instead of a Wayland drag. Either way, dropped icons are set down where they were let go before they take their new place, so they never slide back from where they started.

Kestrel draws every icon itself, from one set of light surfaces and soft folds: files as a page with a folded corner and their kind’s symbol, folders with a back, a sheet and a front flap in the accent colour or the colour picked in Rover, the home folder as a house, the trash as a bin that shows when something is in it, internal drives as a disk, removable ones as a USB stick, discs and network locations as a disc and a globe. Pictures show their thumbnail. Labels take dark ink where the wallpaper under them is light and light ink where it’s dark, from the same samples of the wallpaper the taskbar picks its ink from.

Cut and copy put the files on the clipboard with x-special/gnome-copied-files beside the URI list, so Rover and other file managers know whether to move or copy them.