slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Wrong content positioning on Android #5242

Closed Justyna-JustCode closed 3 months ago

Justyna-JustCode commented 4 months ago

Slint 1.6 ("backend-android-activity-06") + Rust Samsung Galaxy A52 5G (SM-A526B/DS) Android 14

I noticed that the Window's content is not placed correctly in landscape mode, with a left-turned orientation. For this code:

export component MainWindow inherits Window {
    background: orange;

    Rectangle {
        background: green;
    }
}

This is how it looks on my phone:

*Landscape, right-turn: OK (the black rectangle on the right is a spacing for the camera notch) image

*Landscape, left-turn: WRONG (additional, unnecessary content shift from the left, causing also part of the content to be displayed below the system buttons) image

ogoffart commented 3 months ago

Thanks for filling a bug. We try to get the geometry in this function:

https://github.com/slint-ui/slint/blob/199a7286a8bfdbabd66ebc3eea7e32e7b21ad2fe/internal/backends/android-activity/java/SlintAndroidJavaHelper.java#L463-L468

The getWindowVisibleDisplayFrame seems to return a rectangle in the screen coordinate and cut the room for the camera. The problem is that the Window is somehow already displaced.

Trying to provide a fix with #5340