-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scarab: Apply scaling factor in Wayland
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available.
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Keep existing value if it is already non-empty | ||
if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then | ||
# Attempt to get GNOME desktop interface scaling factor | ||
AVALONIA_GLOBAL_SCALE_FACTOR="$(gsettings get org.gnome.desktop.interface scaling-factor | cut --delimiter=' ' --fields=2)" | ||
fi | ||
|
||
if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then | ||
# Attempt to get scaling factor from X FreeType DPI setting | ||
dpi="$(xrdb -get Xft.dpi)" | ||
if [[ -n "$dpi" ]]; then | ||
AVALONIA_GLOBAL_SCALE_FACTOR=$(echo "scale=2; $dpi/96" | bc) | ||
fi | ||
fi | ||
|
||
if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then | ||
export AVALONIA_GLOBAL_SCALE_FACTOR | ||
fi |