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

Add resizable flag and windowmode option to window creation #149

Merged
merged 2 commits into from
Aug 13, 2020

Conversation

joejoepie
Copy link
Contributor

Hello, I'm very impressed by the project and it was very easy to understand the code.
That is why this is my first ever open source contribution!

I've tested the changes on the windowing examples.
The only issue i see is that this change is non-backwards compatible.

Short explanation for (very basic) video mode selection when using Fullscreen:

  • when the boolean use_size is set, a video mode is selected where the width and height are the closest to the width and height fields of the Window struct
  • When it's not set, simply the video mode with the biggest width, height and refresh rate is chosen

@karroffel karroffel added C-Feature A new feature, making something new possible A-Windowing Platform-agnostic interface layer to run your app in labels Aug 12, 2020
@karroffel
Copy link
Contributor

Welcome to bevy @joejoepie and thanks so much for your first open source contribution! This looks pretty nice and useful! (unfortunately it might take a tiny bit before it gets reviewed/merged, things are a bit busy with the sudden interest of so many awesome people 💙 )

@joejoepie
Copy link
Contributor Author

Welcome to bevy @joejoepie and thanks so much for your first open source contribution! This looks pretty nice and useful! (unfortunately it might take a tiny bit before it gets reviewed/merged, things are a bit busy with the sudden interest of so many awesome people blue_heart )

Thank you @karroffel ! Of course i understand these things take time. But I'm very happy that the project gets the attention it deserves. I've rarely encountered a project where it's this easy to jump in and contribute!

@jakerr
Copy link
Contributor

jakerr commented Aug 13, 2020

Hi @joejoepie,

My #160 was just merged in that conflicts with this PR.

If you use the winit_window_builder.with_foo(...) builder methods instead of calling winit_window.set_foo(...) you can prevent regression of issue #159.

Thanks!

@joejoepie
Copy link
Contributor Author

Hi @joejoepie,

My #160 was just merged in that conflicts with this PR.

If you use the winit_window_builder.with_foo(...) builder methods instead of calling winit_window.set_foo(...) you can prevent regression of issue #159.

Thanks!

Thanks for letting me know, i've update the PR.

.unwrap();
winit_window_builder = winit_window_builder.with_title(&window.title);

let winit_window = match window.mode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend making this match return the builder so you can just call build once at the end.

let winit_window = match window.mode {
WindowMode::BorderlessFullscreen => {
let winit_window = winit_window_builder.build(&event_loop).unwrap();
winit_window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of set_fullscreen you can call with_fullscreen to continue chaining onto the builder.

I imagine as it is this would probably flash a non-fullscreen window first.

I think you can get the monitors from EventLoopWindowTarget since they don't exist on the builder. It has available_monitors and primary_monitor.

crates/bevy_winit/src/winit_windows.rs Show resolved Hide resolved
@@ -17,18 +17,39 @@ impl WinitWindows {
#[cfg(target_os = "windows")]
let winit_window_builder = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would have to be mut too for the windows configuration.

@joejoepie
Copy link
Contributor Author

@jakerr Thanks so much for reviewing my PR! I didn't realize the video mode could be retrieved using the event_loop. The resulting code is a lot more compact as well!

@jakerr
Copy link
Contributor

jakerr commented Aug 13, 2020

@joejoepie My pleasure! You might want to squash your commits since the first one would be a compiler error on windows. It's nice to try to avoid any broken commits even if part of the same PR so that if someone goes digging in history with git bisect or the like, they don't get tripped up. :)

I'm as new to this project as you are so I don't have much of an informed opinion on tradeoff with the breaking API change so I'll defer to the maintainers there. Code looks good to me though 👍

@joejoepie
Copy link
Contributor Author

joejoepie commented Aug 13, 2020

I'd rather do a squash merge to master than in my PR. I don't think rewriting the history in a PR has much use. It might also be less clear for people trying to follow along the comment and commit history :)

@jakerr
Copy link
Contributor

jakerr commented Aug 13, 2020

I'd rather do a squash merge to master than in my PR. I don't think rewriting the history in a PR has much use. It might also be less clear for people trying to follow along the comment and commit history :)

Interesting! I wasn't so familiar with that feature. Haven't been on github in quite a while. That said isn't it up to the person accepting the pull request to select the merge option? I wonder what the culture is around that. Do people just put a note in the comments like this or leave it to person accepting the PR to determine if the history should be kept or squashed?

Your point about making the review more clear is a good one though. It definitely was convenient for me reviewing this PR to see the progress.

@joejoepie
Copy link
Contributor Author

I'd rather do a squash merge to master than in my PR. I don't think rewriting the history in a PR has much use. It might also be less clear for people trying to follow along the comment and commit history :)

Interesting! I wasn't so familiar with that feature. Haven't been on github in quite a while. That said isn't it up to the person accepting the pull request to select the merge option? I wonder what the culture is around that. Do people just put a note in the comments like this or leave it to person accepting the PR to determine if the history should be kept or squashed?

Your point about making the review more clear is a good one though. It definitely was convenient for me reviewing this PR to see the progress.

Now that i look at it, the default on github isn't squash merge, but rather merging into a single commit. So this means the branches are still merged, but it will always only result in one commit on the target branch. So for your use case - git bisect - this would still perfectly work, since you'll get all the changes in one commit. Nobody wants to visit every single branch ever used when doing history research work anyway 😅

@cart
Copy link
Member

cart commented Aug 13, 2020

Just tested on my end. Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants