From e1fcc70667860b7719fad2600f02c95f080b69fc Mon Sep 17 00:00:00 2001 From: Naman Agrawal Date: Fri, 22 Aug 2025 18:17:53 +0530 Subject: [PATCH] bugfix: keyboard input was causing the application to crash. --- examples/layer_shell_window.rs | 60 +++++++++++++++++++--------------- src/input_handler/keyboard.rs | 4 ++- src/input_handler/mod.rs | 10 +++--- src/input_region.rs | 4 +-- src/layer_shell.rs | 6 ++-- src/lib.rs | 3 +- 6 files changed, 47 insertions(+), 40 deletions(-) diff --git a/examples/layer_shell_window.rs b/examples/layer_shell_window.rs index aa2ec7d..ff9e592 100644 --- a/examples/layer_shell_window.rs +++ b/examples/layer_shell_window.rs @@ -6,7 +6,7 @@ use bevy::{ window::{WindowCreated, WindowResolution}, winit::WinitPlugin, }; -use bevy_wayland::{layer_shell::LayerShellSettings, WaylandPlugin}; +use bevy_wayland::{input_region::InputRegion, layer_shell::LayerShellSettings, WaylandPlugin}; use smithay_client_toolkit::shell::wlr_layer::{Anchor, Layer}; const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15); @@ -30,7 +30,10 @@ fn main() { )) .init_resource::() .add_systems(Startup, setup) - .add_systems(Update, (button_system, setup_new_window, spawn_window)) + .add_systems( + Update, + (button_system, spawn_window, setup_new_window, exit_on_esc), + ) .run(); } @@ -75,11 +78,11 @@ fn setup(mut commands: Commands, assets: Res, windows: Query, windows: Query>) { + if keys.just_pressed(KeyCode::Escape) { + std::process::exit(0); + } +} + fn spawn_window( mut commands: Commands, mut windows: Query<(Entity, &mut WindowTimer)>, mut new_window_info: ResMut, + keys: Res>, time: Res