UXGtkDriver
UXGtkDriver is the GTK4 realization of
UXViewDriver: the Linux desktop
backend.
#use <UXKit> // or #import "UXGtkDriver.xc"Built to a pattern, not from scratch
Section titled “Built to a pattern, not from scratch”It is a sibling of UXAppKitDriver
and uses the same arrangement as the iOS driver:
- the shared shadow tree, which the driver walks to paint and hit-test
- custom views painting through
drawRect→UXCairoGraphics→ thecairo_tof the current draw realizeTreeoverlaying real GTK widgets whose signals land in the toolkit’sfire/value/fieldseams
| neutral | GTK4 |
|---|---|
UXButton | GtkButton |
UXCheckbox | GtkCheckButton |
UXTextField | GtkEntry |
UXSlider | GtkScale |
UXStepper | GtkSpinButton |
UXProgressBar | GtkProgressBar |
UXPopUpButton | GtkDropDown |
This fifth backend follows the existing pattern without adding to it. The interface already reflects three very different systems: GEM’s AES objects, Win32’s HWNDs and AppKit’s NSViews.
The neutral loop owns the run loop
Section titled “The neutral loop owns the run loop”driverOwnsRunLoop() // falseGTK’s main context pumps under the neutral blocking loop; GTK does not call the toolkit back.
This is the desktop arrangement, and the opposite of
UXIOSDriver and
UXAndroidDriver, where the
platform owns the loop and the application is a set of callbacks.
driverOwnsRunLoop is the one flag that tells the neutral layer which
arrangement applies.
Pointer input had to be added
Section titled “Pointer input had to be added”By default GTK4 does not deliver raw button and motion events to a drawing
area; it expects gesture controllers. The driver therefore attaches a
GtkEventControllerLegacy and exposes ux_gtk_drag_next.
The shim keeps structs out of xtc
Section titled “The shim keeps structs out of xtc”As on every other hosted backend, the exported signatures use primitives only:
i32 ux_gtk_boot(i32* w, i32* h);void ux_gtk_pump(void);void ux_gtk_wait_event(void);i32 ux_gtk_alert(i32 parent, u8* lines, u8* buttons, i32 defBtn);No GdkRectangle or cairo_t* crosses into portable code. For the same
reason, the clip stack is ux_gtk_clip / ux_gtk_clip_end instead of a
context object.
Testing
Section titled “Testing”The gates are run_gtk_real.sh, run_gtk_loop.sh, run_gtk_mouse.sh,
run_gtk_alert.sh and run_gtk_settings.sh. They run on Linux and cannot
run on macOS, so verify a change here on Linux.
The GTK gates print a heartbeat, because a headless GTK run that has stopped looks the same as one that is waiting.
See also
Section titled “See also”UXViewDriver: the interfaceUXCairoGraphics: the drawing vocabularyUXAppKitDriver: the sibling this followsUXIOSDriver: where the platform owns the loop instead