Skip to content

fix: size wallpapers against the display's natural orientation - #295

Open
chunjiw wants to merge 1 commit into
you-apps:mainfrom
chunjiw:fix-natural-orientation-metrics
Open

fix: size wallpapers against the display's natural orientation#295
chunjiw wants to merge 1 commit into
you-apps:mainfrom
chunjiw:fix-natural-orientation-metrics

Conversation

@chunjiw

@chunjiw chunjiw commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

getMetrics() returns the current window bounds, which rotate with the device — but a wallpaper is stored once and reused for every rotation, so it has to be measured in the display's natural orientation.

Applied from a landscape device, the image is cropped to a landscape aspect and suggestDesiredDimensions() is told the wallpaper is landscape too; the home screen then scales that to cover a portrait screen and crops it a second time. The two crops multiply into a small, heavily magnified patch instead of the expected centre slice. This mostly hits the background changer, which fires whichever way the phone happens to be held.

Un-rotates the bounds via Display.rotation rather than min/max, so landscape-natural tablets stay correct.

Fixes #293, fixes #257.

Comment on lines +92 to +93
(context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager)
.getDisplay(Display.DEFAULT_DISPLAY)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the DisplayManager way works for all Android versions, so why do we fall back to the WindowManager on old Android versions?

Comment on lines +92 to +93
(context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager)
.getDisplay(Display.DEFAULT_DISPLAY)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager)
.getDisplay(Display.DEFAULT_DISPLAY)
context.getSystemService<DisplayManager>().getDisplay(Display.DEFAULT_DISPLAY)

@Bnyro

Bnyro commented Sep 2, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, looks good overall 👍

metrics.widthPixels to metrics.heightPixels
}

return when (getDisplayRotation(context)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return when (getDisplayRotation(context)) {
// `width` and `height` depend on the current screen orientation. To get the real metrics,
// we additionally check the current rotation of the display.
return when (getDisplayRotation(context)) {

Please add a short comment here to explain what we're doing, e.g. as the one proposed here.

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.

Same wallpaper renders differently depending on phone orientation Image resize methods don't work for landscape devices

2 participants