Commitff13463dRecorded14 Nov 2026Repositorysigil-ui

Prepare sigil-ui 0.2.5 with a Windows raster adapter

Message

Add a Windows raster presentation adapter using sigil-window, selected only on Windows. The existing Wayland cursor and text fallback behavior is unchanged.

Changed
 NEWS.md                 |  9 +++++++++
 native/raster.c         |  4 ++--
 package.sgl             | 24 +++++++++++++++++-------
 src/sigil/ui/tree.sgl   |  3 +++
 src/sigil/ui/win32.sgl  | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/sigil/ui/window.sgl |  2 ++
 6 files changed, 95 insertions(+), 9 deletions(-)
Diff
NEWS.mdmodified
@@ -1,3 +1,12 @@
+1
# sigil-ui 0.2.5
+2
+3
A Windows raster adapter release.
+4
+5
Requires Sigil 0.24.6 or later in the 0.24 series.
+6
+7
- Add a Windows raster presentation adapter using sigil-window. Preserve
+8
the existing Wayland cursor and text fallback behavior.
+9
10
# sigil-ui 0.2.4
11
12
A Wayland cursor release.
native/raster.cmodified
@@ -284,7 +284,7 @@ void sigil__register_sigil_ui_surface(SigilVM *vm);
284
void sigil__register_sigil_ui_png(SigilVM *vm);
285
#ifdef __APPLE__
286
void sigil__register_sigil_ui_appkit(SigilVM *vm);
−287
#else
+287
#elif !defined(_WIN32)
288
void sigil__register_sigil_ui_wayland(SigilVM *vm);
289
#endif
290
@@ -312,7 +312,7 @@ void sigil__init_sigil_ui_native(SigilVM *vm)
312
sigil__register_sigil_ui_png(vm);
313
#ifdef __APPLE__
314
sigil__register_sigil_ui_appkit(vm);
−315
#else
+315
#elif !defined(_WIN32)
316
sigil__register_sigil_ui_wayland(vm);
317
#endif
318
}
package.sglmodified
@@ -13,8 +13,9 @@
13
sources: (append ui-common-sources
14
(case (target-os ctx)
15
((darwin) '("native/surface-unavailable.c"))
+16
((windows) '("native/surface-unavailable.c"))
17
((linux) '("native/surface.c" "native/wayland.c"))
−17
(else (error "sigil-ui supports Linux and macOS targets"))))
+18
(else (error "sigil-ui supports Linux, macOS and Windows targets"))))
19
include-dirs: '("native/wayland" "native/wayland/include")
20
flags: (with-sigil-c-flags ui-flags)) ctx)))
21
(if (eq? (target-os ctx) 'darwin)
@@ -22,9 +23,16 @@
23
flags: (with-sigil-c-flags (append ui-flags '("-fobjc-arc")))) compiled)
24
compiled)))
25
+26
(define (compile-ui-modules ctx)
+27
((compile-sigil-modules
+28
sources: "src/**/*.sgl"
+29
exclude: (if (eq? (target-os ctx) 'windows) '()
+30
(list (path-join (context-package-dir ctx) "src/sigil/ui/win32.sgl")))
+31
output-dir: (config-output-subdir "lib")) ctx))
+32
33
(package
34
name: "sigil-ui"
−27
version: "0.2.4"
+35
version: "0.2.5"
36
sigil: "0.24.6"
37
description: "Retained-mode UI framework with a software renderer"
38
url: "https://git.usesigil.org/sigil/sigil-ui"
@@ -43,10 +51,14 @@
51
debug?: #f
52
optimize: 2))
53
−46
dependencies: (list
+54
dependencies: (append
+55
(cond-expand
+56
(windows (list (from-pkg name: "sigil/sigil-window" version: "^0.1.0")))
+57
(else '()))
+58
(list
59
(from-pkg name: "sigil/sigil-font" version: "^0.1.0")
60
(from-pkg name: "sigil/sigil-lib" version: "^0.24.6")
−49
(from-pkg name: "sigil/sigil-stdlib" version: "^0.24.6"))
+61
(from-pkg name: "sigil/sigil-stdlib" version: "^0.24.6")))
62
63
;; The test runner declares its package/build/store helpers transitively.
64
dev-dependencies: (list
@@ -77,8 +89,6 @@
89
(create-static-library
90
name: "sigil-ui")
91
−80
(compile-sigil-modules
−81
sources: "src/**/*.sgl"
−82
output-dir: (config-output-subdir "lib"))
+92
compile-ui-modules
93
94
(copy-package-docs)))))
src/sigil/ui/tree.sglmodified
@@ -45,6 +45,7 @@
45
text-advance
46
make-ui ui? ui-update! ui-reconcile! ui-repaint! ui-items ui-canvas ui-theme ui-scale ui-width ui-height
47
ui-background ui-stats ui-set-theme!
+48
ui-presentation-context set-ui-presentation-context!
49
stats-leaves-kept stats-leaves-built stats-leaves-moved stats-components-skipped stats-components-run
50
element-items merge-rects)
51
(begin
@@ -288,6 +289,8 @@
289
(define-struct ui
290
(theme mutable: #t) (canvas) (scale) (background)
291
(root default: #f mutable: #t)
+292
;; Backend-owned lifetime/generation metadata, collected with the UI.
+293
(presentation-context default: #f mutable: #t)
294
(stats mutable: #t))
295
296
;;; A ui drawing onto canvas at integer scale s over a background color
src/sigil/ui/win32.sgladded
@@ -0,0 +1,62 @@
+1
(cond-expand
+2
(windows
+3
;;; The Win32 host belongs to sigil-window; this module only adapts canvases.
+4
(define-library (sigil ui win32)
+5
(import (sigil window win32) (sigil ui raster) (sigil ui tree) (sigil ui mask))
+6
(export open-window window? window-role window-width window-height window-scale
+7
window-device-width window-device-height window-focused? window-closed?
+8
window-dispatch window-present! window-present-ui! window-make-ui window-close! window-run!
+9
window-set-title! window-clipboard-read window-clipboard-set!
+10
window-fullscreen? window-set-fullscreen! window-fullscreen-status
+11
window-host-token window-present-overlay!)
+12
(begin
+13
(define (present-canvas window canvas damage generation)
+14
(when (pair? damage)
+15
(for-each
+16
(lambda (rectangle)
+17
(unless (and (list? rectangle) (= (length rectangle) 4)
+18
(let loop ((values rectangle))
+19
(or (null? values)
+20
(and (exact-integer? (car values)) (>= (car values) 0)
+21
(loop (cdr values)))))
+22
(<= (+ (car rectangle) (list-ref rectangle 2)) (canvas-width canvas))
+23
(<= (+ (cadr rectangle) (list-ref rectangle 3)) (canvas-height canvas)))
+24
(error "window-present!: invalid device damage rectangle" rectangle)))
+25
(car damage)))
+26
;; Copy into host-owned storage. No Sigil canvas is retained by Win32.
+27
(if (and (pair? damage) (null? (car damage)))
+28
#t
+29
(window-present-pixels! window (canvas-pixels canvas)
+30
(canvas-width canvas) (canvas-height canvas) generation)))
+31
(define (window-present! window canvas . damage)
+32
(present-canvas window canvas damage (window-generation window)))
+33
(define (window-present-ui! window ui damage)
+34
(let ((context (ui-presentation-context ui)))
+35
(unless context
+36
(set! context (vector window (window-generation window)))
+37
(set-ui-presentation-context! ui context))
+38
(and (eq? window (vector-ref context 0))
+39
(= (window-generation window) (vector-ref context 1))
+40
(present-canvas window (ui-canvas ui)
+41
(list (map (lambda (rectangle)
+42
(map (lambda (value) (* value (ui-scale ui))) rectangle))
+43
damage))
+44
(vector-ref context 1)))))
+45
(define (window-make-ui window theme background)
+46
;; Integer supersampling keeps layout in logical units at fractional DPI.
+47
;; The host owns conversion to the exact physical client extent.
+48
(let ((ui (make-ui theme
+49
(make-canvas (window-raster-width window) (window-raster-height window))
+50
(window-scale window) background)))
+51
(set-ui-presentation-context! ui (vector window (window-generation window)))
+52
ui))
+53
(define (window-present-overlay! window canvas alpha)
+54
(unless (and (mask? alpha) (= (mask-width alpha) (canvas-width canvas))
+55
(= (mask-height alpha) (canvas-height canvas)))
+56
(error "window-present-overlay!: alpha must match canvas extent"))
+57
(window-present-overlay-pixels! window (canvas-pixels canvas)
+58
(canvas-width canvas) (canvas-height canvas) (window-generation window) (mask-alpha alpha)))))
+59
+60
)
+61
(else
+62
(define-library (sigil ui win32) (export) (begin))))
src/sigil/ui/window.sglmodified
@@ -3,6 +3,8 @@
3
;;; Backend-specific output and buffer diagnostics remain in that module.
4
(define-library (sigil ui window)
5
(cond-expand
+6
(windows
+7
(import (sigil ui win32)))
8
(darwin
9
(import (rename (sigil ui appkit)
10
(open-appkit-window open-window)