Skip to content

Display: fixes scale calculation for displays rotated 90 or 270 degrees#2224

Closed
bnfour wants to merge 1 commit intofastfetch-cli:devfrom
bnfour:rotated-displays-scale-fix
Closed

Display: fixes scale calculation for displays rotated 90 or 270 degrees#2224
bnfour wants to merge 1 commit intofastfetch-cli:devfrom
bnfour:rotated-displays-scale-fix

Conversation

@bnfour
Copy link

@bnfour bnfour commented Mar 12, 2026

Summary

This makes the scale calculations swap display's width and height for rotated displays for correct results.

The issue

The scale calculation always uses display's native height. This leads for issues for rotated displays. For example, my display setup is the following:
image

All displays are set to their native 1× scale, yet fastfetch reports the rotated one having 0.56×, as its scaled size is 1080×1920, and the scale is calculated as original height (1080) over scaled height (1920):

$ fastfetch -l none -s display 
Display (DELL S2522HG): 1920x1080 in 25", 240 Hz [External] *
Display (BenQ GW2270): 1920x1080 @ 0.56x in 22", 60 Hz [External] <=======
Display (LG HDR WFHD): 2560x1080 in 34", 75 Hz [External]

I've also tested this on my laptop's display 1920×1080 with 1.25× scaling enabled (scaled size 1536×864): if the screen is rotated, the reported scale is 0.7× (1080/1536).

The solution

Note: this change only applies to the default non-compact mode.

With my patch applied, the scale display is correct:

$ ./fastfetch -l none -s display
Display (DELL S2522HG): 1920x1080 in 25", 240 Hz [External] *
Display (BenQ GW2270): 1080x1920 in 22", 60 Hz [External]
Display (LG HDR WFHD): 2560x1080 in 34", 75 Hz [External]

The resolution display is also changed to show the rotation (this part is probably optional, let me know what you think).

Related issue (required for new logos for new distros)

None, I went straight for a pull.

Changes

  • Made the scale calculations aware of the fact that for displays rotated 90° or 270°, width and height are effectively swapped.
  • Made the default output mode show effective resolution for rotated displays.

Checklist

  • I have tested my changes locally.

I'm not really a C dev, so I'd be grateful for any feedback.

This makes the scale calculations swap display's width and height for rotated displays for correct results.
@CarterLi
Copy link
Member

Thanks for reporting! I'll come up with a better solution, I think.

@bnfour
Copy link
Author

bnfour commented Mar 12, 2026

Sure! Code in this pull is really more of a proof-of-concept, done in a few hours — I just searched the code for the issue source and tried to fix it myself, "tried" being the operative word here.

Should I close this pull and open an issue instead?

@CarterLi CarterLi closed this in 37b8bb4 Mar 13, 2026
@CarterLi
Copy link
Member

Please test 37b8bb4

@bnfour
Copy link
Author

bnfour commented Mar 13, 2026

Please test 37b8bb4

This commit fixes the scale value in both cases I originally mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants