-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scarab: Apply scaling factor in Wayland #348427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, I am curious though, since this is an avalonia issue, anyway we can apply this for all avalonia apps?
Good question. I'm not at all familiar with Avalonia, and a quick search for it in nixpkgs didn't reveal anything obvious. @corngood any ideas? |
This is probably where you'd want to do it. You probably couldn't use |
Wanted to bump this again, do we want to apply this change just for scarab for now, and for all avalonia apps later? |
From the upstream issue:
It seems like we're reproducing this logic. I don't understand why it's not working out of the box. |
Same, but this works right now. I'd rather just revert once a more suitable solution is found. I don't know the first thing about Avalonia or how Scarab is built, and I don't have time to work out a better solution. |
# 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)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I run gsettings get org.gnome.desktop.interface scaling-factor | cut --delimiter=' ' --fields=2
on my system I get 0
. Would this be a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the setting I get uint32 0
, using xmonad on xorg.
gsettings describe
says
Integer factor used to scale windows by. For use on high-dpi screens. 0 means pick automatically based on monitor.
So I guess falling through to the other methods would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by assuming that a zero from gsettings
means I'd also get the same or another meaningless value from xrdb
, and simply unsetting the scaling factor if that happens.
# 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)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check for existence of gsettings
instead of bringing it as a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it doesn't make sense to run Scarab in a pure shell, and since non-GNOME users probably won't have gsettings
, I think you're right that we shouldn't pull it in. Done.
The issue is really strange, it does sound like this should be things that upstream should be and already is doing. Perhaps it has to do with XWayland, and how different DEs handle scaling with X11 apps running in XWayland. |
All done @corngood, thank you! |
buildDotnetModule, | ||
fetchFromGitHub, | ||
glibc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these is good if they aren't needed, but I think it should be a separate commit from the wrapper, in case we need to bisect/revert.
@@ -0,0 +1,24 @@ | |||
# Keep existing value if it is already non-empty | |||
if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]] && type gsettings >/dev/null; then | |||
echo 'Attempting to get GNOME desktop interface scaling factor' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably have made these echos go to stderr, since this is a wrapper.
c18e01e
to
7b09fac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me. Thanks!
The only question I have is: are there any automated editorconfig checks that could possibly fail because of the added coverage of .bash files?
I'll try to answer that myself, but if maybe someone knows for sure.
Oh, good point! |
... There are editorconfig checks. They are usually only run on files changed in the PR. There are quite a few existing errors in master when it's run on the whole repo, but I verified that there are no errors in .bash files on this PR. |
@l0b0 I ran the same checks, but with https://github.com/NixOS/nixpkgs/actions/runs/11760835386/workflow?pr=348427 So if it's not going to fail in the regular checks, I think it's fine if you don't fix the other files. It wouldn't hurt though. Up to you... |
OIC, thanks! I didn't look at the indent size check. I'll leave it in for now, and see what people say. I assume the indent check is only disabled temporarily, until more files pass, but worst case that just means we'll commit the .editorconfig change itself. I'll split it into two commits to make this even easier. |
Sorry, I should have actually tried to run this before. Without
I think using If Also... On my laptop I'm using gnome+wayland, and 192 dpi. For some reason, |
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. Does not include `gsettings` and `xrdb` in build inputs, since these should be available on the relevant platforms. Bash does not support decimal/floating point arithmetic, so this *does* include `bc` in the runtime dependencies.
Yes,
We probably won't use this for other packages. It's really just a one-off fix for a persistent issue with Scarab specifically. In the unlikely event that someone reuses this script I'd expect they'd make sure to deal with non-GUI situations if relevant.
Thanks! I've moved the check. |
Sets
AVALONIA_GLOBAL_SCALE_FACTOR
to the GNOME desktop scaling factor based onAvaloniaUI/Avalonia#9390 (comment).
Also:
shfmt --write pkgs/tools/games/scarab/scaling-settings.bash
(necessitated copying the relevant.editorconfig
settings)shellcheck --enable=all --severity=style pkgs/tools/games/scarab/scaling-settings.bash
Thanks to @Artturin for help on Matrix!
Things done
shellcheck
edshfmt
ednix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.