bevy icon indicating copy to clipboard operation
bevy copied to clipboard

X11 bug around fullscreen when app startup/init

Open LLNet opened this issue 3 years ago • 1 comments

Bevy version

0.7.0

Relevant system information

  • cargo 1.62.1
  • rustc 1.62.1 (stable) operating system: Ubuntu 22.04 LTS (X11)
winit::platform_impl::platform::x11::window: Guessed window scale factor: 1 
`AdapterInfo { name: "NVIDIA GeForce RTX 3080", vendor: 4318, device: 8714, device_type: DiscreteGpu, backend: Vulkan }`

What you did

works:

use bevy::prelude::*;
use bevy::window::WindowMode;

fn main() {
    App::new()
        .insert_resource(ClearColor(Color::rgb(0.4, 0.4, 0.4)))
        .insert_resource(WindowDescriptor {
            mode: WindowMode::Windowed,
            width: 0.0,
            height: 0.0,
            ..Default::default()
        })
        .add_plugins(DefaultPlugins)
        .add_system(fullscreeen)
        .run();
}

fn fullscreeen(
    input: Res<Input<KeyCode>>,
    mut windows: ResMut<Windows>,
) {
    let window = windows
        .get_primary_mut()
        .unwrap();

    if input.pressed(KeyCode::LAlt) && input.just_pressed(KeyCode::Return) {
        if window.mode() == WindowMode::Windowed {
            println!("Changing to fullscreen");
            window.set_mode(WindowMode::Fullscreen);
        } else {
            println!("Changing to windowed");
            window.set_mode(WindowMode::Windowed);
        }
    }
}

not working:

use bevy::prelude::*;
use bevy::window::WindowMode;

fn main() {
    App::new()
        .insert_resource(ClearColor(Color::rgb(0.4, 0.4, 0.4)))
        .insert_resource(WindowDescriptor {
            mode: WindowMode::Fullscreen,
            width: 0.0,
            height: 0.0,
            ..Default::default()
        })
        .add_plugins(DefaultPlugins)
        .add_system(fullscreeen)
        .run();
}

fn fullscreeen(
    input: Res<Input<KeyCode>>,
    mut windows: ResMut<Windows>,
) {
    let window = windows
        .get_primary_mut()
        .unwrap();

    if input.pressed(KeyCode::LAlt) && input.just_pressed(KeyCode::Return) {
        if window.mode() == WindowMode::Windowed {
            println!("Changing to fullscreen");
            window.set_mode(WindowMode::Fullscreen);
        } else {
            println!("Changing to windowed");
            window.set_mode(WindowMode::Windowed);
        }
    }
}

What went wrong

only changes are what mode app start in. Fullscreen or Windowed

if i run desktop in x11 and try startup app with Fullscreen (from start) it crash.

thread 'main' panicked at 'Error in Surface::configure: parent device is lost', /home/*****/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:214:9

if i run desktop in Wayland - it work fine.

if i run desktop in x11 and startup app with "Windowed" mode. it work fine and can easy change to Fullscreen after...

sorry if my english is bad.

LLNet avatar Jul 29 '22 16:07 LLNet

I've tested this on 0.8.1 and it works as intended here. @LLNet Could you try against latest stable release?

AxiomaticSemantics avatar Nov 12 '22 08:11 AxiomaticSemantics