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

Game window opens off-screen on Windows #5358

Open
darthdeus opened this issue Jul 17, 2022 · 2 comments
Open

Game window opens off-screen on Windows #5358

darthdeus opened this issue Jul 17, 2022 · 2 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior O-Windows Specific to the Windows desktop operating system

Comments

@darthdeus
Copy link
Contributor

darthdeus commented Jul 17, 2022

Bevy version

0.7

Relevant system information

Windows 10

What you did

Running a game with 1920x1080 resolution on a 3440x1440 monitor, with WindowDescriptor being simply the following

App::new()
    .insert_resource(WindowDescriptor {
        width: 1920.0,
        height: 1080.0,
        ..Default::default()
    })

What went wrong

The window opens about 1/3 from both top/left, and the bottom half of the game window is off-screen. Since there is no way to center the window (as in #4876) this is a bit problematic.

I don't think there's any current workaround that doesn't include hardcoding the position (which isn't desirable considering different screen resolutions). winit does allow centering the window rather easily

if let Some(monitor) = window.current_monitor() {
    let screen_size = monitor.size();
    let window_size = window.outer_size();

    window.set_outer_position(winit::dpi::PhysicalPosition {
        x: screen_size.width.saturating_sub(window_size.width) as f64 / 2.
            + monitor.position().x as f64,
        y: screen_size.height.saturating_sub(window_size.height) as f64 / 2.
            + monitor.position().y as f64,
    });
}```

The problem is that even with `winit`, the `monitor.size()` API can only be accessed via a `window`, which isn't available at the time `WindowDescriptor` is created.
@darthdeus darthdeus added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 17, 2022
@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in O-Windows Specific to the Windows desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Jul 18, 2022
@alice-i-cecile
Copy link
Member

Possibly a duplicate of #4876. Does #4999 resolve this for you?

@lesleyrs
Copy link

I'm on 0.8 but windows 10 as well and for some reason the window sometimes appears off screen, and other times it appears correctly (without changing anything).

The fact it appears off screen doesn't surprise me because I need to use the hidpi setting in Godot as well for games to be centered.

I have no clue as to why it randomly seems to change the position it pops up in though. I'm just using the getting started project and it didn't seem to make a difference if I added the new #4999 centered option or not.

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 O-Windows Specific to the Windows desktop operating system
Projects
None yet
Development

No branches or pull requests

3 participants