bugfix: mouse events were not being registered.

- Mouse events and Window Events should be sent seperately, they were
being sent only as WindowEvents which made bevy not react to mouse
events.
This commit is contained in:
Naman Agrawal
2025-08-22 16:03:10 +05:30
parent b368d43531
commit e98d52a57f
2 changed files with 23 additions and 5 deletions
+22 -3
View File
@@ -7,9 +7,7 @@ use bevy::{
window::{CursorEntered, CursorLeft, CursorMoved, Window, WindowEvent}, window::{CursorEntered, CursorLeft, CursorMoved, Window, WindowEvent},
}; };
use smithay_client_toolkit::{ use smithay_client_toolkit::{
delegate_pointer, delegate_pointer, reexports::client::Proxy, seat::pointer::PointerHandler,
reexports::{client::Proxy, csd_frame::WindowState},
seat::pointer::PointerHandler,
}; };
use crate::{surface_handler::WaylandSurfaces, WaylandState}; use crate::{surface_handler::WaylandSurfaces, WaylandState};
@@ -101,6 +99,27 @@ impl PointerHandler for WaylandState {
.into(), .into(),
}; };
let window_event: WindowEvent = pointer_event; let window_event: WindowEvent = pointer_event;
match window_event.clone() {
WindowEvent::CursorEntered(e) => {
self.world_mut().send_event(e);
}
WindowEvent::CursorLeft(e) => {
self.world_mut().send_event(e);
}
WindowEvent::CursorMoved(e) => {
self.world_mut().send_event(e);
}
WindowEvent::MouseButtonInput(e) => {
self.world_mut().send_event(e);
}
WindowEvent::MouseMotion(e) => {
self.world_mut().send_event(e);
}
WindowEvent::MouseWheel(e) => {
self.world_mut().send_event(e);
}
_ => {}
}
self.world_mut().send_event::<WindowEvent>(window_event); self.world_mut().send_event::<WindowEvent>(window_event);
} }
} }
+1 -2
View File
@@ -1,12 +1,11 @@
use bevy::{app::PluginsState, prelude::*}; use bevy::{app::PluginsState, prelude::*};
use smithay_client_toolkit::{ use smithay_client_toolkit::{
delegate_registry, delegate_registry,
globals::ProvidesBoundGlobal,
output::OutputState, output::OutputState,
reexports::{ reexports::{
calloop::EventLoop, calloop::EventLoop,
calloop_wayland_source::WaylandSource, calloop_wayland_source::WaylandSource,
client::{globals::registry_queue_init, protocol::wl_compositor::WlCompositor, Connection}, client::{globals::registry_queue_init, Connection},
}, },
registry::{ProvidesRegistryState, RegistryState}, registry::{ProvidesRegistryState, RegistryState},
registry_handlers, registry_handlers,