Skip to content

Unintuitive ability to change WindowDescriptor #3787

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

Closed
SUPERCILEX opened this issue Jan 27, 2022 · 1 comment
Closed

Unintuitive ability to change WindowDescriptor #3787

SUPERCILEX opened this issue Jan 27, 2022 · 1 comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior S-Duplicate This issue or PR already exists

Comments

@SUPERCILEX
Copy link
Contributor

SUPERCILEX commented Jan 27, 2022

Bevy version

0.6

What you did

fn full_screen_toggle(mut window: ResMut<WindowDescriptor>, keyboard_input: Res<Input<KeyCode>>) {
    if keyboard_input.just_released(KeyCode::F) {
        window.mode = if window.mode == WindowMode::Windowed {
            WindowMode::BorderlessFullscreen
        } else {
            WindowMode::Windowed
        };
    }
}

What you expected to happen

I thought the window mode would change.

What actually happened

Nothing. I would have expected this to fail to compile or panic so I'd know that's not the API to use.

Additional information

This is the right way to do it:

fn full_screen_toggle(mut windows: ResMut<Windows>, keyboard_input: Res<Input<KeyCode>>) {
    if keyboard_input.just_released(KeyCode::F) {
        let window = windows.get_primary_mut().unwrap();
        window.set_mode(if window.mode() == WindowMode::Windowed {
            WindowMode::BorderlessFullscreen
        } else {
            WindowMode::Windowed
        });
    }
}
@SUPERCILEX SUPERCILEX added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 27, 2022
@DJMcNab
Copy link
Member

DJMcNab commented Jan 27, 2022

Duplicate of #2879

@DJMcNab DJMcNab marked this as a duplicate of #2879 Jan 27, 2022
@DJMcNab DJMcNab added A-Windowing Platform-agnostic interface layer to run your app in S-Duplicate This issue or PR already exists and removed S-Needs-Triage This issue needs to be labelled labels Jan 27, 2022
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-Bug An unexpected or incorrect behavior S-Duplicate This issue or PR already exists
Projects
None yet
Development

No branches or pull requests

2 participants