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

Incorrect window size obtained from WindowResolution in version 0.12 #10642

Closed
wgxh-cli opened this issue Nov 19, 2023 · 2 comments · Fixed by #10741
Closed

Incorrect window size obtained from WindowResolution in version 0.12 #10642

wgxh-cli opened this issue Nov 19, 2023 · 2 comments · Fixed by #10741
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior

Comments

@wgxh-cli
Copy link

wgxh-cli commented Nov 19, 2023

Bevy version

latest(0.12)

What you did

I'm a archlinux and tiling window manager user, also used to coding in neovim.

To reproduce, just write the following program and run it:

// main.rs

use bevy::prelude::*;
use bevy::window::PrimaryWindow;

fn init_system(
  window: Query<&mut Window, With<PrimaryWindow>>,
) {
  let window = window.single_mut();
  let size = Vec2::new(window.width(), window.height());
  println!("Size: {}", size);
  window.set_cursor_position(Some(size / 2.0));
}

fn main() {
  App::new()
    .add_plugins(DefaultPlugins)
    .add_systems(Startup, init_system)
    .run()
}

What went wrong

Expected:

  1. Correct input in terminal to report the window size.
    Since the bevy window split in half the 1920 * 1080 screen, so the correct size must be that divided by 2.

  2. The cursor should be at the center of the window.
    As the window.set_cursor_position(Some(size / 2) showed.

That was what I expected but in newer version bevy, I get these:

  1. In terminal I got the size of 1280 * 720
    Notice that 1280 * 720 is the default value in window.rs

  2. Since that I got incorrect cursor position in my window.

That is very strange because the same program act normally in 0.11.3 bevy, that I find out.

Additional information

Before running this program I executed sudo pacman -Syu in my archlinux system.
That is to say, I already have the latest system environment.

I chose wezterm as my default terminal, and bash as my main shell.

In my project, I have dynamic_linking feature enabled, and naturally, have resolver = "2" in [workspace] entry.

Can anyone give me a help hand? Thanks a lot!

@wgxh-cli wgxh-cli added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 19, 2023
@mockersf
Copy link
Member

this is probably the same issue as #10407
for the first run of your systems, the window size / scale is not updated with the actual window but has the default values

@mockersf mockersf added A-Windowing Platform-agnostic interface layer to run your app in and removed S-Needs-Triage This issue needs to be labelled labels Nov 19, 2023
@wgxh-cli
Copy link
Author

Thanks! I solved that, close this soon.

github-merge-queue bot pushed a commit that referenced this issue Nov 26, 2023
# Objective

- Window size, scale and position are not correct on the first execution
of the systems
- Fixes #10407,  fixes #10642

## Solution

- Don't run `update` before we get a chance to create the window in
winit
- Finish reverting #9826 after #10389
cart pushed a commit that referenced this issue Nov 30, 2023
# Objective

- Window size, scale and position are not correct on the first execution
of the systems
- Fixes #10407,  fixes #10642

## Solution

- Don't run `update` before we get a chance to create the window in
winit
- Finish reverting #9826 after #10389
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants