Skip to content
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

Wrong content positioning on Android #5242

Closed
Justyna-JustCode opened this issue May 15, 2024 · 1 comment · Fixed by #5340
Closed

Wrong content positioning on Android #5242

Justyna-JustCode opened this issue May 15, 2024 · 1 comment · Fixed by #5340
Labels
a:platform-android Android platform integration (mO,bS) bug Something isn't working

Comments

@Justyna-JustCode
Copy link

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:

  • Portrait: OK
    image

*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

@FloVanGH FloVanGH added a:platform-android Android platform integration (mO,bS) labels May 15, 2024
@hunger hunger added the bug Something isn't working label May 16, 2024
ogoffart added a commit that referenced this issue Jun 3, 2024
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.
The insets seems to be a better way to get that value.

Fixes #5242
@ogoffart
Copy link
Member

ogoffart commented Jun 3, 2024

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

// Get the geometry of the view minus the system bars and the keyboard
public Rect get_view_rect() {
Rect rect = new Rect();
mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
return rect;
}

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

ogoffart added a commit that referenced this issue Jun 3, 2024
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.
The insets seems to be a better way to get that value.

Fixes #5242
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:platform-android Android platform integration (mO,bS) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants