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

Windows size returned from webview.window().inner_size() is incorrect #1027

Closed
1 of 2 tasks
rhysd opened this issue Sep 29, 2023 · 2 comments · Fixed by #1028
Closed
1 of 2 tasks

Windows size returned from webview.window().inner_size() is incorrect #1027

rhysd opened this issue Sep 29, 2023 · 2 comments · Fixed by #1028

Comments

@rhysd
Copy link
Contributor

rhysd commented Sep 29, 2023

Describe the bug

Window size returned from webview.window().inner_size() does not change even if the window was resized.

I'm not sure this is actually a bug or an intended behavior. Please feel free to close this issue if it is intentional.

Steps To Reproduce

Clone this repository and apply the following patch.

diff --git a/examples/hello_world.rs b/examples/hello_world.rs
index f74d276..089854b 100644
--- a/examples/hello_world.rs
+++ b/examples/hello_world.rs
@@ -16,13 +16,14 @@ fn main() -> wry::Result<()> {
   let window = WindowBuilder::new()
     .with_title("Hello World")
     .build(&event_loop)?;
-  let _webview = WebViewBuilder::new(window)?
+  let webview = WebViewBuilder::new(window)?
     .with_url("https://www.netflix.com/browse")?
     // .with_incognito(true)
     .build()?;
 
   event_loop.run(move |event, _, control_flow| {
     *control_flow = ControlFlow::Wait;
+    dbg!(webview.window().inner_size());
 
     match event {
       Event::NewEvents(StartCause::Init) => println!("Wry has started!"),

Then run hello_world example and resize the window and observe the debug prints in your terminal.

Expected behavior

webview.window().inner_size() returns the current window size.

Screenshots

N/A

Platform and Versions (please complete the following information):
OS: macOS
Rustc: rustc 1.72.1 (d5c2e9c34 2023-09-13)

Would you want to assign yourself to resolve this bug?

  • Yes
  • No

Additional context

I noticed webview.inner_size() can return the correct size so it can be used as the replacement.

@wusyong
Copy link
Member

wusyong commented Sep 29, 2023

the tao and winit's window inner sizes are incorrect because we have to replace its NSView.
The reasons to replace it are because of keyboard accelerators and menu items. tao and winit control many keyboard handling methods. We couldn't find any better ways to handle these.
So we have webview.inner_size() as alternatives. Perhaps we should add documentation on why we need this method.

@rhysd
Copy link
Contributor Author

rhysd commented Sep 29, 2023

Thank you @wusyong for the clarification. I'll try to add documentation for this since it was a bit surprising for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants