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

On wayland ViewportCommand::InnerSize doesn't update the content size #4196

Closed
ColinKinloch opened this issue Mar 20, 2024 · 2 comments · Fixed by #4211
Closed

On wayland ViewportCommand::InnerSize doesn't update the content size #4196

ColinKinloch opened this issue Mar 20, 2024 · 2 comments · Fixed by #4211
Labels
bug Something is broken

Comments

@ColinKinloch
Copy link
Contributor

ColinKinloch commented Mar 20, 2024

Describe the bug

On wayland (mutter) when the window is resized using ViewportCommand::InnerSize the viewport size doesn't match the window.

Drag Resize Handle Press "Phone Size" Drag Resize Handle Press "Desktop Size"
Screenshot from 2024-03-20 11-30-33 Screenshot from 2024-03-20 11-28-20 Screenshot from 2024-03-20 11-30-54 Screenshot from 2024-03-20 11-28-35

I suspect this is because winit doesn't send Resized events after the resize, the correct way to handle this is applying the value returned from request_inner_size to the viewport here:

ViewportCommand::InnerSize(size) => {
let width_px = pixels_per_point * size.x.max(1.0);
let height_px = pixels_per_point * size.y.max(1.0);
if window
.request_inner_size(PhysicalSize::new(width_px, height_px))
.is_some()
{
log::debug!("ViewportCommand::InnerSize ignored by winit");
}
}

To Reproduce
Steps to reproduce the behavior:

  1. On gnome shell press the Phone Size button, note the window contents are stretched
  2. Resize the window, note the window contents are not stretched
  3. Repeat

Expected behavior
Contents are not stretched

Screenshots

Desktop (please complete the following information):

  • OS: Fedora 39

#4197 makes it easier to test.

@zeta0134
Copy link

I just ran into this bug today. Same behavior, this time on Arch+KDE. Only occurs in Wayland, the same device with an x11 session computes the dimensions correctly, even with DPI scaling applied.

@ColinKinloch
Copy link
Contributor Author

emilk pushed a commit that referenced this issue Mar 25, 2024
An alternative to the "Phone Size" button useful for testing
`ViewportCommand::InnerSize`.

I created this to make it easy to debug
#4196 there are more details there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
2 participants