gui: on GTK 3 with no font DPI set, magpie gives GDK one before the first webview, so the window and panel no longer collapse (#1371, haoxianhan)
This empty commit holds the message for2018882e, which was pushed with another session's davsync commit message by mistake (a reused scratch file).2018882echanges only docs/subsystems/gui-shell.md, internal/gui/app.go and internal/gui/fontdpi_* (+ testdata probe); it contains no davsync change. GDK's unset font resolution is -1. WebKitGTK 2.54's GTK 3 settings reader (SystemSettingsManagerProxy::xftDPI) multiplies it by 1024 unchecked, and every page laid out at a negative width with a 9000000px body font: the window showed its text one word per line. fontDPI queues a G_PRIORITY_HIGH idle just before app.Run. Wails makes its GtkApplication (and so initialises GTK, with its program name set) inside Run and makes each window from a default-idle-priority callback, so the check runs on the main thread after GTK's own start and before the first webview, without initialising GTK earlier than Wails does. A positive DPI (the user's own) is left alone. An unset one takes gtk-xft-dpi, or 96, times a valid GDK_DPI_SCALE, as GTK does for a positive gtk-xft-dpi. GTK 4 builds, macOS and Windows are unchanged. Run, in Docker (Debian 13 arm64, GTK 3.24.49, WebKitGTK 2.54.0, Xvfb): - testdata/fontdpi_probe.c without the guard at DPI -1: viewport -40320, font 9000000 (the reporter's literal values); with it: DPI 96, viewport 420, font 16. - TestFontDPIUnset (-tags gtk3): 4 cases pass (unset -> 96, unset with GDK_DPI_SCALE 1.25 -> 120, bad scale -> 96, a user's 144 kept). With the guard returning early it FAILs: "font DPI -1, want 96", "page laid out at viewport -40320, body font 9e+06px". - The real magpie binary (-tags gtk3, `magpie gui`, an LD_PRELOAD that leaves GDK's DPI at -1 after gtk_application_new): without fontDPI() both webviews are made at -1, the main page measures viewport -57600, font 9000000px, and the screenshot shows the one-word column; with it both are made at 96, viewport 600, font 13px, normal layout. - go vet -tags gtk3 ./internal/gui; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui; GOOS=windows go build; go test -tags nogui ./internal/gui; gofmt -l: clean. Not run: a real Wayland compositor (the reporter's Niri) or WebKitGTK 2.54.1 exactly; the unset DPI was injected, not natural. The test skips without a display, so CI only compiles it.
This commit is contained in:
1 parent
2018882e47
commit
b86001d432