mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
app/internal/window: apply monitorScale to sp values on Wayland
macOS and Windows already applies monitorScale to sp values. Wayland didn't apply the monitorScale when font scale detection fails. Do that. Run gofmt -s -w . as well. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -52,7 +52,7 @@ func mustLoadDLL(dll *syscall.LazyDLL, name string) {
|
|||||||
if loadErr == nil {
|
if loadErr == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pmsg := syscall.StringToUTF16Ptr("Failed to load " + name+ ". Gio requires the ANGLE OpenGL ES driver to run. A prebuilt version can be downloaded from https://gioui.org/doc/install.")
|
pmsg := syscall.StringToUTF16Ptr("Failed to load " + name + ". Gio requires the ANGLE OpenGL ES driver to run. A prebuilt version can be downloaded from https://gioui.org/doc/install.")
|
||||||
ptitle := syscall.StringToUTF16Ptr("Error")
|
ptitle := syscall.StringToUTF16Ptr("Error")
|
||||||
syscall.MessageBox(0 /* HWND */, pmsg, ptitle, syscall.MB_ICONERROR|syscall.MB_SYSTEMMODAL)
|
syscall.MessageBox(0 /* HWND */, pmsg, ptitle, syscall.MB_ICONERROR|syscall.MB_SYSTEMMODAL)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -1071,17 +1071,17 @@ func (w *window) surface() (*C.struct_wl_surface, int, int) {
|
|||||||
|
|
||||||
func (w *window) ShowTextInput(show bool) {}
|
func (w *window) ShowTextInput(show bool) {}
|
||||||
|
|
||||||
// detectFontScale reports current font scale, or 1.0
|
// detectFontScale reports the system font scale, or monitorScale
|
||||||
// if it fails.
|
// if it fails.
|
||||||
func detectFontScale() float32 {
|
func detectFontScale() float32 {
|
||||||
// TODO: What about other window environments?
|
// TODO: What about other window environments?
|
||||||
out, err := exec.Command("gsettings", "get", "org.gnome.desktop.interface", "text-scaling-factor").Output()
|
out, err := exec.Command("gsettings", "get", "org.gnome.desktop.interface", "text-scaling-factor").Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 1.0
|
return monitorScale
|
||||||
}
|
}
|
||||||
scale, err := strconv.ParseFloat(string(bytes.TrimSpace(out)), 32)
|
scale, err := strconv.ParseFloat(string(bytes.TrimSpace(out)), 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 1.0
|
return monitorScale
|
||||||
}
|
}
|
||||||
return float32(scale)
|
return float32(scale)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user