feat: move Files to its own process; add window server messaging (multi-format clipboard, drag and drop), undo/redo, sidebar, breadcrumbs, thumbnails, file type icons, New menu and proper text fields

This commit is contained in:
daniel committed 2026-10-24 12:44:20 +02:00
1 parent 07191b1286
commit d3e49a925d
66 files changed
+6855 -905

No files matched your search

+163 -2
View File
@@ -299,6 +299,19 @@ namespace montauk::abi {
thread ends the process rather than only that thread. */
static constexpr uint64_t SYS_EXIT_GROUP = 199; // (exitCode) -> does not return
/* Multi-format clipboard (see "Window server messaging" below). The text
calls above operate on its TRANSFER_MIME_TEXT format. */
static constexpr uint64_t SYS_CLIPBOARD_SET_DATA = 200; // (const TransferItem*, count) -> status
static constexpr uint64_t SYS_CLIPBOARD_FORMATS = 201; // (TransferFormatInfo*, max, uint64_t* serial) -> count
static constexpr uint64_t SYS_CLIPBOARD_GET_DATA = 202; // (mime, buf, max, uint32_t* len) -> status
/* Window server requests and drag and drop. */
static constexpr uint64_t SYS_WIN_REQUEST = 203; // (windowId, const WinRequest*) -> status
static constexpr uint64_t SYS_WIN_REQUEST_POLL = 204; // (WinRequest*) -> 1 / 0; compositor only
static constexpr uint64_t SYS_WIN_DRAG_BEGIN = 205; // (windowId or -1 for the compositor's own surface, const WinDragBegin*, const TransferItem*, count) -> serial
static constexpr uint64_t SYS_WIN_DRAG_FORMATS = 206; // (serial, TransferFormatInfo*, max) -> count
static constexpr uint64_t SYS_WIN_DRAG_GET_DATA = 207; // (serial, mime, buf, max, uint32_t* len) -> status
/* Kernel-owned process capabilities. User identities may namespace
per-user resources, but never participate in authorization decisions. */
static constexpr uint64_t CAP_PROCESS_ADMIN = 1ULL << 0;
@@ -637,14 +650,52 @@ namespace montauk::abi {
};
// Window server shared types
enum WinEventType : uint8_t {
WIN_EVENT_KEY = 0,
WIN_EVENT_MOUSE = 1,
WIN_EVENT_RESIZE = 2,
WIN_EVENT_CLOSE = 3,
WIN_EVENT_SCALE = 4,
// Drag and drop (WinEvent::drag). A window may read the drag's data
// (SYS_WIN_DRAG_*) once it has received one of these for that serial.
WIN_EVENT_DRAG_ENTER = 5, // pointer entered the window during a drag
WIN_EVENT_DRAG_OVER = 6, // pointer moved; coalesced like mouse moves
WIN_EVENT_DRAG_LEAVE = 7, // pointer left, or the drag was cancelled
WIN_EVENT_DROP = 8, // released here; drag.actions = chosen action
WIN_EVENT_DRAG_END = 9, // to the source only; drag.actions = action
// taken (0 = cancelled / not accepted)
};
// Modifier keys held at the time of a drag event (WinEvent::drag.modifiers).
static constexpr uint8_t WIN_MOD_SHIFT = 1u << 0;
static constexpr uint8_t WIN_MOD_CTRL = 1u << 1;
static constexpr uint8_t WIN_MOD_ALT = 1u << 2;
// Drag actions; a source offers a set, a drop carries exactly one.
static constexpr uint8_t WIN_DRAG_COPY = 1u << 0;
static constexpr uint8_t WIN_DRAG_MOVE = 1u << 1;
static constexpr uint8_t WIN_DRAG_LINK = 1u << 2;
struct WinDragEvent {
int32_t x, y; // window-local; -1,-1 when not over the window
uint32_t serial; // identifies the drag
uint8_t actions; // WIN_DRAG_* (see WinEventType)
uint8_t modifiers; // WIN_MOD_*
uint8_t _pad[2];
};
static_assert(sizeof(WinDragEvent) == 16, "WinDragEvent must fit the WinEvent union");
struct WinEvent {
uint8_t type; // 0=key, 1=mouse, 2=resize, 3=close, 4=scale
uint8_t type; // WinEventType
uint8_t _pad[3];
union {
KeyEvent key; // 16 bytes: the union was already that size (mouse)
struct { int32_t x, y, scroll; uint8_t buttons, prev_buttons; } mouse;
// modifiers (WIN_MOD_*) was padding before; compositors that
// predate it send 0.
struct { int32_t x, y, scroll; uint8_t buttons, prev_buttons, modifiers; } mouse;
struct { int32_t w, h; } resize;
struct { int32_t scale; } scale;
WinDragEvent drag; // WIN_EVENT_DRAG_* / WIN_EVENT_DROP
};
};
static_assert(sizeof(WinEvent) == 20, "WinEvent layout is shared with existing binaries");
@@ -668,6 +719,116 @@ namespace montauk::abi {
uint64_t pixelVa; // VA of pixel buffer in caller's address space
};
// ---- Window server messaging ----------------------------------------
//
// Three pieces, shared by the compositor (the desktop) and every app:
// * WinEvent types 5-9 below: drag-and-drop events, compositor -> app.
// * WinRequest: typed records an app posts about one of its own windows
// (SYS_WIN_REQUEST); only the compositor can collect them
// (SYS_WIN_REQUEST_POLL). Unknown types are ignored, so new requests
// can be added without breaking older compositors or apps.
// * Transfers: multi-format payloads (one MIME type per format) carried
// by the clipboard (SYS_CLIPBOARD_*_DATA) and by drags
// (SYS_WIN_DRAG_*). The older text clipboard calls read and write the
// TRANSFER_MIME_TEXT format of the same clipboard.
// Transfers -----------------------------------------------------------
static constexpr uint32_t TRANSFER_MAX_FORMATS = 8;
static constexpr uint32_t TRANSFER_MIME_MAX = 64; // incl. NUL
static constexpr uint32_t TRANSFER_MAX_BYTES = 256 * 1024; // all formats together
// Well-known formats. Any other "type/subtype" string is allowed.
static constexpr const char* TRANSFER_MIME_TEXT = "text/plain;charset=utf-8";
// UTF-8 absolute paths ("0:/..."), one per line.
static constexpr const char* TRANSFER_MIME_FILE_LIST = "application/x-montauk-file-list";
// Clipboard companion to a file list: "copy" or "cut".
static constexpr const char* TRANSFER_MIME_FILE_OP = "application/x-montauk-file-op";
// One format to store. Pointers are carried as 64-bit values so the
// layout is the same for every caller.
struct TransferItem {
uint64_t mime; // const char*, NUL-terminated, < TRANSFER_MIME_MAX
uint64_t data; // const void*
uint32_t len;
uint32_t _reserved;
};
static_assert(sizeof(TransferItem) == 24, "TransferItem is ABI");
struct TransferFormatInfo {
char mime[TRANSFER_MIME_MAX];
uint32_t len;
uint32_t _reserved;
};
static_assert(sizeof(TransferFormatInfo) == 72, "TransferFormatInfo is ABI");
// Requests --------------------------------------------------------------
static constexpr uint32_t WIN_REQUEST_PAYLOAD_MAX = 240;
struct WinRequest {
uint16_t type; // WinRequestType
uint16_t size; // payload bytes in use
int32_t windowId; // window the request is about (the sender must own it
// when posting); -1 if it was destroyed since
int32_t senderPid; // filled in by the kernel
uint32_t serial; // filled in by the kernel; increases per request
uint8_t payload[WIN_REQUEST_PAYLOAD_MAX];
};
static_assert(sizeof(WinRequest) == 256, "WinRequest is ABI");
enum WinRequestType : uint16_t {
WIN_REQ_LAUNCH_ITEM = 1, // WinReqLaunchItem
WIN_REQ_SET_PARENT = 2, // WinReqSetParent
WIN_REQ_DRAG_STATUS = 3, // WinReqDragStatus
WIN_REQ_ACTIVATE = 4, // no payload: raise and focus the window
// Types from here on are generated by the kernel; SYS_WIN_REQUEST
// refuses them so an app cannot forge one.
WIN_REQ_KERNEL_BASE = 0x8000,
WIN_REQ_DRAG_BEGIN = 0x8001, // WinReqDragBegin (from SYS_WIN_DRAG_BEGIN)
};
// Open a desktop catalog item (an app manifest id, or a built-in such as
// "desktop-settings"), as if the user had picked it from the launcher, so
// it runs with the authority the desktop would give it. `args` reach only
// apps whose manifest declares files.types (they take a document path);
// anything else starts without them, so a request cannot steer a
// privileged app through its command line.
struct WinReqLaunchItem {
char itemId[48];
char args[192];
};
// Mark the window as a dialog of another window owned by the same
// process: the compositor centres it over the parent.
struct WinReqSetParent {
int32_t parentWindowId;
};
// Answer to DRAG_ENTER/DRAG_OVER: the action this window would perform
// on a drop at the current position (0 = would refuse). Advisory; it
// drives the compositor's drag feedback.
struct WinReqDragStatus {
uint32_t serial;
uint8_t action; // one WIN_DRAG_* or 0
uint8_t _pad[3];
};
// Describes a drag for the compositor's feedback. Supplied by the app to
// SYS_WIN_DRAG_BEGIN and relayed (with the serial) as WIN_REQ_DRAG_BEGIN.
struct WinDragBegin {
uint8_t actions; // WIN_DRAG_* offered
uint8_t _pad[3];
uint32_t itemCount; // for a "3 items" badge; 0 = do not show
char label[64]; // short description, e.g. the file name
};
static_assert(sizeof(WinDragBegin) == 72, "WinDragBegin is ABI");
struct WinReqDragBegin {
uint32_t serial;
WinDragBegin info;
};
struct DevInfo {
uint8_t category; // 0=CPU, 1=Interrupt, 2=Timer, 3=Input, 4=USB, 5=Network, 6=Display, 7=Storage, 8=PCI, 9=Audio, 10=ACPI
uint8_t _pad[3];