fixes for linux and macos

This commit is contained in:
Peter Li 2026-10-11 16:14:13 -07:00
parent 8c99ac7912
commit da1f67d347
4 changed files with 34 additions and 30 deletions

View File

@ -1,7 +1,7 @@
# Uhdk # Uhdk
A small desktop platform library written in Zig 0.17.0 with a C99 ABI. A small desktop platform library written in Zig 0.17.0 with a C99 ABI.
It provides windows, input and IME, clipboard, file dialogs, drag and drop, menus, tray icons, It provides windows, input and IME, clipboard, file dialogs, incoming file drops, menus, tray icons,
async file operations, file watching, and OpenGL context creation. The macOS async file operations, file watching, and OpenGL context creation. The macOS
backend uses AppKit, OpenGL, and FSEvents through a private Objective-C bridge. backend uses AppKit, OpenGL, and FSEvents through a private Objective-C bridge.
File dialog filters accept suffixes without a leading dot, including compound File dialog filters accept suffixes without a leading dot, including compound
@ -12,8 +12,9 @@ types, and helpers connecting the Zig runtime with native platform code. Public
C API symbols use `uhdk_`. C API symbols use `uhdk_`.
macOS builds require Xcode Command Line Tools. The Windows Win32/WGL backend macOS builds require Xcode Command Line Tools. The Windows Win32/WGL backend
cross-compiles for `x86_64-windows-gnu`; runtime verification on Windows is pending. It requires targets `x86_64-windows-gnu`. Demo applications have been tested under Wine and
Windows 10 version 1703 or later and an OpenGL 3.3-capable driver. on a Windows 11 host with no issues observed so far. The backend requires
Windows 10 version 1703 or later and an OpenGL 3.3-capable driver for GL sessions.
The Linux Wayland preview implements windows, EGL/OpenGL, keyboard/pointer and The Linux Wayland preview implements windows, EGL/OpenGL, keyboard/pointer and
text input, clipboard/file drops, portal dialogs/preferences, activation, icons, text input, clipboard/file drops, portal dialogs/preferences, activation, icons,
@ -103,9 +104,9 @@ state or directly undo minimization, and suspension is not proof of occlusion.
Explicitly unavailable Wayland window-manager actions complete with `UNSUPPORTED`. Explicitly unavailable Wayland window-manager actions complete with `UNSUPPORTED`.
Render hints do not replace presentation pacing or event processing. Render hints do not replace presentation pacing or event processing.
This library is unreleased and experimental; the changed C struct layout requires UHDK is experimental and does not guarantee API or ABI compatibility between
rebuilding consumers, without ABI compatibility guarantees. Windows and Linux revisions. Rebuild consumers when updating the library and headers. Demo testing
runtime qualification must accompany cross-compilation checks. does not qualify every IME, window manager, display configuration or driver.
## Build ## Build
@ -302,9 +303,7 @@ advance this lifetime. Copy data you need to keep; copying an envelope alone
copies only its pointers. Retain file/menu references when needed beyond an iteration, copies only its pointers. Retain file/menu references when needed beyond an iteration,
but even retained handles cannot outlive the app. but even retained handles cannot outlive the app.
UHDK is pre-release: API and ABI compatibility with earlier revisions is not Event envelopes have a fixed array stride within each returned batch.
guaranteed. Session options require only struct_size and the desired options. Event envelopes have
a fixed array stride within each returned batch.
The scratch arena is maintained as UHDK-owned code in The scratch arena is maintained as UHDK-owned code in
[src/arenas.zig](src/arenas.zig), including its supporting storage and tests. [src/arenas.zig](src/arenas.zig), including its supporting storage and tests.
@ -410,5 +409,6 @@ cause and retires the interaction, without deciding whether
the application should commit or undo its work. Destruction invalidates cycles the application should commit or undo its work. Destruction invalidates cycles
immediately; fatal errors or early close may prevent delivery of queued endings. immediately; fatal errors or early close may prevent delivery of queued endings.
The C API exposes spans and plain event payloads. Typed payload helpers remain The C API exposes spans and plain event payloads. `UHDK_EVENT_PAYLOAD` checks an
consumer-owned; they are not part of the public header. event's type and payload size before returning a typed pointer; languages that
cannot use C macros perform those checks explicitly.

View File

@ -17,7 +17,7 @@ or libraries disable their features without a desktop-name whitelist.
## Build and run ## Build and run
Normal builds require only Zig 0.16.0 on a glibc Linux target: Normal builds require only Zig 0.17.0 on a glibc Linux target:
```sh ```sh
zig build zig build
@ -57,7 +57,7 @@ nix-shell
zig build zig build
``` ```
Zig 0.16.0 should already be on PATH. The shell is optional for compilation. Zig 0.17.0 should already be on PATH. The shell is optional for compilation.
Its nixpkgs revision and source hash live in `nix/pkgs.nix`. It also supports Its nixpkgs revision and source hash live in `nix/pkgs.nix`. It also supports
maintainer [header/protocol refreshes](vendor/README.md). Running packaged apps maintainer [header/protocol refreshes](vendor/README.md). Running packaged apps
on NixOS should use the application's normal Nix wrapper and graphics setup. on NixOS should use the application's normal Nix wrapper and graphics setup.
@ -89,9 +89,10 @@ NixOS with Plasma 6.5.6 and Mesa 25.2.6; other systems are not runtime-qualified
decoration request at runtime. No desktop-name checks or Qt/KDE linkage are used. decoration request at runtime. No desktop-name checks or Qt/KDE linkage are used.
- The application ID is copied from `uhdk_options` and sent as the xdg-toplevel - The application ID is copied from `uhdk_options` and sent as the xdg-toplevel
app ID. Applications own their desktop-file and icon installation. app ID. Applications own their desktop-file and icon installation.
- A window is created hidden after its first configure. Showing requests mapping; - `uhdk_open` returns a primary window with visibility requested;
the first successful buffer swap supplies its content. `visible` is the `uhdk_window_create` returns an additional hidden native window. Showing
application's show/hide intent, not proof that the compositor displays it. requests mapping; the first committed buffer supplies its content. `visible`
is the application's show/hide intent, not proof that the compositor displays it.
- Size/state commands acknowledge submission. Confirmed geometry and focus arrive - Size/state commands acknowledge submission. Confirmed geometry and focus arrive
through metrics. Wayland cannot report minimized state, force focus, or directly through metrics. Wayland cannot report minimized state, force focus, or directly
undo minimization. Metrics expose known resizing and (xdg-shell v6+) suspension undo minimization. Metrics expose known resizing and (xdg-shell v6+) suspension
@ -111,11 +112,15 @@ NixOS with Plasma 6.5.6 and Mesa 25.2.6; other systems are not runtime-qualified
- Hiding replaces the EGL presentation surface so an outstanding frame callback - Hiding replaces the EGL presentation surface so an outstanding frame callback
cannot hang remapping. The GL context and its application-owned resources cannot hang remapping. The GL context and its application-owned resources
survive. Swapping a hidden/unconfigured window returns `UNAVAILABLE`. survive. Hidden windows still receive events; `uhdk_end_frame` does not present
- Every GL call belongs inside begin/end-frame. Clear/make-current are supported iterations whose `frame.drawable` is false.
within that bracket. Actual GL version reporting is queried in the active - In GL sessions, the context is current after `uhdk_open` and between iterations
context. Window framebuffer dimensions describe the presentation target; until `uhdk_close`. Create and destroy GL resources on OS main, including
applications continue to own their viewport and rendering resources. before the first frame and after the loop. `uhdk_next_frame` releases GL
ownership while pumping native work and restores it before returning. Draw
to the window only when `frame.drawable` is true, and pair each successful
`uhdk_next_frame` with `uhdk_end_frame`. Framebuffer dimensions describe the
presentation target; applications own their viewport and rendering resources.
## Input and desktop services ## Input and desktop services
@ -204,7 +209,7 @@ NixOS with Plasma 6.5.6 and Mesa 25.2.6; other systems are not runtime-qualified
reconnecting to a replaced session bus requires restarting the application. reconnecting to a replaced session bus requires restarting the application.
Restarting just the menu consumer does not require reattachment. Restarting just the menu consumer does not require reattachment.
- Context menus use an internal software renderer and `xdg_popup`, with a - Context menus use an internal software renderer and `xdg_popup`, with a
checked-in 16px Roboto bitmap (about 24 KB). They need `wl_shm` and a seat, checked-in 16px Roboto bitmap. They need `wl_shm` and a seat,
independently of KDE appmenu export or a session bus. No Qt/GTK, runtime font independently of KDE appmenu export or a session bus. No Qt/GTK, runtime font
library, image decoder, or application GL context is used for menu drawing. library, image decoder, or application GL context is used for menu drawing.
`CONTEXT_MENU` reports protocol availability; opening also requires a visible, `CONTEXT_MENU` reports protocol availability; opening also requires a visible,
@ -220,12 +225,11 @@ NixOS with Plasma 6.5.6 and Mesa 25.2.6; other systems are not runtime-qualified
hiding/destruction and seat removal complete as `CANCELLED`. hiding/destruction and seat removal complete as `CANCELLED`.
- This small menu has its own light/dark palette, selected from portal appearance - This small menu has its own light/dark palette, selected from portal appearance
preferences when available. It does not reproduce arbitrary KDE widget themes preferences when available. It does not reproduce arbitrary KDE widget themes
or expose an accessibility tree. The bitmap covers printable ASCII, Latin-1 or expose an accessibility tree. The bitmap covers printable ASCII and uses
and selected punctuation/arrows, with a replacement glyph for other text; no `?` for unsupported codepoints; no shaping or bidi is implemented. Output
shaping or bidi is implemented. Output scales enlarge the 16px bitmap instead scales enlarge the 16px bitmap instead of rerasterizing it. Font provenance,
of rerasterizing it. Font provenance, license and maintainer regeneration license and regeneration instructions are in [font/README.md](font/README.md).
instructions are in [font/README.md](font/README.md). The renderer and font stay The renderer and font stay entirely inside the Linux backend.
entirely inside the Linux backend.
- File watches use inotify. A document watch follows its named path through - File watches use inotify. A document watch follows its named path through
atomic replacement by observing its parent. Directory watches observe immediate atomic replacement by observing its parent. Directory watches observe immediate
children. Queue overflow requests a rescan; lost roots are invalidated. Each children. Queue overflow requests a rescan; lost roots are invalidated. Each

View File

@ -24,7 +24,7 @@ reserved byte). Row-major coverage uses two 4-bit samples per byte, low nibble
first. A byte with its high bit set encodes 1–128 zero bytes; otherwise it gives first. A byte with its high bit set encodes 1–128 zero bytes; otherwise it gives
the number of following literal bytes. The low seven bits hold length minus one. the number of following literal bytes. The low seven bits hold length minus one.
this file exists to implement the fallback right click menus in wayland desktops To check the bundled bitmap or regenerate it:
```sh ```sh
python3 src/linux/tools/bitmap-font.py --check python3 src/linux/tools/bitmap-font.py --check

View File

@ -1,5 +1,5 @@
/* Win32 bridge. Queues, handles, ownership and bounded file I/O remain in Zig. /* Win32 bridge. Queues, handles, ownership and bounded file I/O remain in Zig.
* Cross-compiled implementation: native Windows runtime validation is pending. */ * Platform requirements and validation scope are documented in ../../README.md. */
#define COBJMACROS #define COBJMACROS
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>