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

[MacOS] WindowEvent::Resized event doesn't return correct window size #490

Open
1 of 2 tasks
nickav opened this issue Feb 9, 2022 · 3 comments
Open
1 of 2 tasks

Comments

@nickav
Copy link

nickav commented Feb 9, 2022

Describe the bug

The WindowEvent::Resized(size) event doesn't report the correct window dimensions on MacOS.

Steps To Reproduce

Run the following sample code (tweaked from hello_world.rs):

fn main() -> wry::Result<()> {
  use wry::{
    application::{
      event::{Event, StartCause, WindowEvent},
      event_loop::{ControlFlow, EventLoop},
      window::WindowBuilder,
    },
    webview::WebViewBuilder,
  };

  let event_loop = EventLoop::new();
  let window = WindowBuilder::new()
    .with_title("Hello World")
    .build(&event_loop)?;
  let webview = WebViewBuilder::new(window)?
    .build()?;

  event_loop.run(move |event, _, control_flow| {
    *control_flow = ControlFlow::Wait;

    match event {
      Event::NewEvents(StartCause::Init) => println!("Wry has started!"),
      Event::WindowEvent {
        event: WindowEvent::CloseRequested,
        ..
      } => *control_flow = ControlFlow::Exit,
      Event::WindowEvent {
          event: WindowEvent::Resized(size),
          ..
      } => {
          //let _ = webview.resize();

          // @Bug: always reports PhysicalSize { width: 1600, height: 1200 }
          println!("{:?}", size);
          println!("{:?}", webview.window().inner_size());
          println!("");
      },
      _ => {}
    }
  });
}

Expected behavior

size and webview.window().inner_size() both should return the correct window dimensions during and after resize.

Screenshots

wry_window_resize_bug.mov

Platform and Versions (please complete the following information):
OS: MacOS Version 10.14.6 (18G103)
Rustc: rustc 1.46.0, rustc 1.60.0-nightly (0c292c966 2022-02-08)

Would you assign yourself to resolve this bug?

  • Yes
  • No

Additional context

N/A

@amrbashir
Copy link
Member

This is a known issue, and that's why we provide webview.inner_size() to get the correct value.

@progrium
Copy link

Nice to have a workaround, but as a known issue is there a known way to fix it? Willing to look into it and submit a PR..

@amrbashir
Copy link
Member

amrbashir commented Feb 10, 2022

thanks @progrium, here is the original issue #384 , now I am not a macOS developer but seems like we would need a way to set the private nsview field in tao for everything to magically work? but it might not work because in the future we might support multiple webviews in one window.

cc @wusyong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests

3 participants