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

frame.set_window_size() is not consistent/broken across platforms. #1458

Open
sourcebox opened this issue Apr 5, 2022 · 14 comments
Open

frame.set_window_size() is not consistent/broken across platforms. #1458

sourcebox opened this issue Apr 5, 2022 · 14 comments
Labels
bug Something is broken egui-winit porblems related to winit native-linux Problem specific to Linux

Comments

@sourcebox
Copy link

According to my tests, it works as expected only on macOS. With Linux (Mint Cinnamon 20.3), it simply does nothing, on Windows 10, the resulting window size is wrong when called within setup() but correct when called from update().

@sourcebox sourcebox added the bug Something is broken label Apr 5, 2022
@emilk
Copy link
Owner

emilk commented Apr 5, 2022

What about when using winit directly? e.g. adapt https://github.com/rust-windowing/winit/blob/master/examples/min_max_size.rs to call window.set_inner_size(…) when pressing some keyboard key

@emilk emilk added the egui-winit porblems related to winit label Apr 5, 2022
@sourcebox
Copy link
Author

sourcebox commented Apr 5, 2022

What about when using winit directly? e.g. adapt https://github.com/rust-windowing/winit/blob/master/examples/min_max_size.rs to call window.set_inner_size(…) when pressing some keyboard key

This works as expected on Linux. macOS works anyway, so I don't need to test anything there. So Windows is still in question. It did not work within setup(), but this method was removed from the API recently.

@emilk
Copy link
Owner

emilk commented Apr 5, 2022

Ok, so if it was only ever broken in setup? Then we can close this issue?

@sourcebox
Copy link
Author

Ok, so if it was only ever broken in setup? Then we can close this issue?

It was broken in setup() for Windows. In Linux it is broken even in update().

@sourcebox
Copy link
Author

Now that setup() is gone, is there another way to access the frame when you create the application instance (now with the new()method)?

@emilk
Copy link
Owner

emilk commented Apr 5, 2022

You shouldn't need to - use NativeOptions. If that doesn't work, then let's fix that.

@emilk
Copy link
Owner

emilk commented Apr 5, 2022

So just to be clear, on latest master, frame.set_window_size doesn't work on Linux, even though calling window.set_inner_size directly on the winit::Window works?

If that is correct, can you please investigate further?

frame.set_window_size is just be calling window.set_inner_size with a points->pixel conversion (see fn handle_app_output in egui-winit/src/epi.rs), so either the conversion is broken, or some window setting is different from the winit example.

@emilk emilk added the native-linux Problem specific to Linux label Apr 5, 2022
@sourcebox
Copy link
Author

I'm currently using commit 95efbbc from 2 days ago, That's the one with your DPI fix. When I use the debugger, frame.set_window_size() just sets self.output.window_size inside epi/src/lib.rs in line 311. There is no call to window.set_inner_size().

@emilk
Copy link
Owner

emilk commented Apr 5, 2022

@sourcebox the call to set_inner_size is in handle_app_output

@sourcebox
Copy link
Author

I had a closer look. window.set_inner_size() gets the correct size, but the call simply does nothing.

@sourcebox
Copy link
Author

Now we come closer: it works if I set resizable to true in the NativeOptions.

@emilk
Copy link
Owner

emilk commented Apr 5, 2022

So set_inner_size and resizable interact differently on Linux vs other platforms? Sounds like a bug that should be reported to (and fixed in) winit!

@sourcebox
Copy link
Author

Done, see rust-windowing/winit#2242

@sourcebox
Copy link
Author

As a workaround for Linux, initial_window_size, min_window_size and max_window_size could be set to the same value in the NativeOptions. Doing this in addition to frame.set_window_size() (needed at least for Windows, macOS not tested yet) will make it work on all 3 platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui-winit porblems related to winit native-linux Problem specific to Linux
Projects
None yet
Development

No branches or pull requests

2 participants