Skip to content

gtk: GTK4-hosted Linux backend — native controls over a GtkPicture framebuffer - #90

Merged
tannevaled merged 1 commit into
mainfrom
feat/gtk-backend
Aug 31, 2026
Merged

gtk: GTK4-hosted Linux backend — native controls over a GtkPicture framebuffer#90
tannevaled merged 1 commit into
mainfrom
feat/gtk-backend

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The third native-control host — the Linux sibling of internal/cocoa and internal/win32. Completes native controls on all three OSes.

How

GTK owns the window (go-gtk/gtk4 v0.2.0, pure-Go over purego, no cgo). The toolkit's pixel framebuffer is presented in a GtkPicture each frame (GdkMemoryTexture), and native controls (toolkit.NativeControl) are real GtkEntry/GtkButton/GtkCheckButton overlaid in a GtkFixed above it. It runs the same gatherNative+syncNative descriptor reconcile the cocoa/win32 backends do, with the same immediate-mode-safe value-diff binding — so a Surface app's secure field, button and checkbox become real GTK widgets with no app changes.

Selection

Opt-in via $GO_WIDGETS_GTK, so the default stays the dependency-free from-scratch X11/Wayland backends; the GTK path needs the libgtk-4 runtime (no -dev).

Proof

TestGTKBackendReconcilesControls + a new live-gtk CI lane (libgtk-4 + Xvfb): a secure-entry descriptor becomes a GtkEntry whose value round-trips, follows an app-side change, and is reconciled away when the descriptor disappears. All platforms build (android/darwin/windows via the binding's stub); Backend conformance asserted.

Follow-ups (noted, not blocking)

Slider/pop-up hosting (pending trackbar/combo in the binding); input routing to the drawn surface + continuous frame ticking; native radio grouping via GTK groups. The core (present + control reconcile) is proven.

…amebuffer

The third native-control host, the sibling of internal/cocoa and internal/win32.
GTK owns the window (github.com/go-gtk/gtk4, pure-Go over purego, no cgo); the
toolkit's pixel framebuffer is presented in a GtkPicture each frame, and native
platform controls (toolkit.NativeControl) are real GtkEntry/GtkButton/GtkCheckButton
overlaid above it in a GtkFixed. It runs the same descriptor reconcile (gatherNative
+ syncNative) the cocoa and win32 backends do, with the same immediate-mode-safe
value-diff binding, so a Surface app's secure field, button and checkbox become
real GTK widgets with no app changes.

Selected by $GO_WIDGETS_GTK (opt-in, so the default stays the dependency-free
from-scratch X11/Wayland backends); needs the libgtk-4 runtime. Proven on real
GTK4 under Xvfb (TestGTKBackendReconcilesControls + a new live-gtk CI lane): a
secure-entry descriptor becomes a GtkEntry whose value round-trips, follows an
app-side change, and is reconciled away when the descriptor disappears.

Slider and pop-up are not yet hosted (pending trackbar/combo in the binding);
input routing to the drawn surface and continuous frame ticking are the next
steps. Requires go-gtk/gtk4 v0.2.0.
@tannevaled
tannevaled merged commit 341a853 into main Aug 31, 2026
23 of 28 checks passed
@tannevaled
tannevaled deleted the feat/gtk-backend branch August 31, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant