bugfix: keyboard input was causing the application to crash.
This commit is contained in:
@@ -409,6 +409,7 @@ impl KeyboardHandler for WaylandState {
|
||||
let active_window_entity = **self.world().resource::<ActiveWindow>();
|
||||
let keyboard_event =
|
||||
convert_keyboard_event(event, active_window_entity, ButtonState::Pressed);
|
||||
self.world_mut().send_event(keyboard_event.clone());
|
||||
self.world_mut()
|
||||
.send_event(WindowEvent::KeyboardInput(keyboard_event));
|
||||
}
|
||||
@@ -425,6 +426,7 @@ impl KeyboardHandler for WaylandState {
|
||||
let mut keyboard_event =
|
||||
convert_keyboard_event(event, active_window_entity, ButtonState::Pressed);
|
||||
keyboard_event.repeat = true;
|
||||
self.world_mut().send_event(keyboard_event.clone());
|
||||
self.world_mut()
|
||||
.send_event(WindowEvent::KeyboardInput(keyboard_event));
|
||||
}
|
||||
@@ -440,6 +442,7 @@ impl KeyboardHandler for WaylandState {
|
||||
let active_window_entity = **self.world().resource::<ActiveWindow>();
|
||||
let keyboard_event =
|
||||
convert_keyboard_event(event, active_window_entity, ButtonState::Released);
|
||||
self.world_mut().send_event(keyboard_event.clone());
|
||||
self.world_mut()
|
||||
.send_event(WindowEvent::KeyboardInput(keyboard_event));
|
||||
}
|
||||
@@ -454,7 +457,6 @@ impl KeyboardHandler for WaylandState {
|
||||
_raw_modifiers: smithay_client_toolkit::seat::keyboard::RawModifiers,
|
||||
_layout: u32,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
delegate_keyboard!(WaylandState);
|
||||
|
||||
@@ -47,11 +47,11 @@ impl SeatHandler for WaylandState {
|
||||
capability: smithay_client_toolkit::seat::Capability,
|
||||
) {
|
||||
if capability == Capability::Keyboard {
|
||||
//let mut seat_state = self.world_mut().non_send_resource_mut::<SeatState>();
|
||||
//let wl_keyboard = seat_state
|
||||
// .get_keyboard(qh, &seat, None)
|
||||
// .expect("error while attaching keyboard!");
|
||||
//self.world_mut().insert_non_send_resource(wl_keyboard);
|
||||
let mut seat_state = self.world_mut().non_send_resource_mut::<SeatState>();
|
||||
let wl_keyboard = seat_state
|
||||
.get_keyboard(qh, &seat, None)
|
||||
.expect("error while attaching keyboard!");
|
||||
self.world_mut().insert_non_send_resource(wl_keyboard);
|
||||
info!("Keyboard Attached");
|
||||
}
|
||||
if capability == Capability::Pointer {
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ use smithay_client_toolkit::{
|
||||
use crate::{input_region, surface_handler::WaylandSurfaces, WaylandState};
|
||||
|
||||
#[derive(Component, Deref)]
|
||||
pub struct InputRegion(Rect);
|
||||
pub struct InputRegion(pub Rect);
|
||||
|
||||
pub struct InputRegionPlugin;
|
||||
impl Plugin for InputRegionPlugin {
|
||||
@@ -27,7 +27,7 @@ fn update_input_region(
|
||||
let region = Region::new(compositor.as_ref()).unwrap();
|
||||
region.add(
|
||||
input_region.min.x as i32,
|
||||
input_region.max.y as i32,
|
||||
input_region.min.y as i32,
|
||||
input_region.width() as i32,
|
||||
input_region.height() as i32,
|
||||
);
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
use bevy::{platform::collections::HashMap, prelude::*, ui::update};
|
||||
use smithay_client_toolkit::{
|
||||
delegate_layer,
|
||||
reexports::client::{globals::GlobalList, Proxy, QueueHandle},
|
||||
reexports::client::{globals::GlobalList, Connection, Proxy, QueueHandle},
|
||||
shell::{
|
||||
wlr_layer::{
|
||||
Anchor, KeyboardInteractivity, Layer, LayerShell, LayerShellHandler, LayerSurface,
|
||||
@@ -43,7 +43,7 @@ impl LayerShellWindow {
|
||||
.set_exclusive_zone(self.layer_shell_settings.exclusive_zone);
|
||||
|
||||
let (width, height) = self.layer_shell_settings.size;
|
||||
self.layer_surface.set_size(width, height);
|
||||
self.layer_surface.set_size(400, 400);
|
||||
|
||||
let (top, right, bottom, left) = self.layer_shell_settings.margin;
|
||||
self.layer_surface.set_margin(top, right, bottom, left);
|
||||
@@ -95,7 +95,7 @@ impl Default for LayerShellSettings {
|
||||
size: Default::default(),
|
||||
exclusive_zone: Default::default(),
|
||||
margin: Default::default(),
|
||||
keyboard_interactivity: Default::default(),
|
||||
keyboard_interactivity: KeyboardInteractivity::OnDemand,
|
||||
layer: Layer::Top,
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -60,11 +60,10 @@ pub fn runner(mut app: App, mut event_loop: EventLoop<'_, WaylandState>) -> AppE
|
||||
let mut state = WaylandState(app);
|
||||
loop {
|
||||
// TODO: Error handling
|
||||
let _ = event_loop.dispatch(None, &mut state);
|
||||
|
||||
if state.plugins_state() == PluginsState::Cleaned {
|
||||
state.update();
|
||||
}
|
||||
let _ = event_loop.dispatch(None, &mut state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user