refactor: remove unused event bus

This commit is contained in:
drendog 2025-11-14 22:42:57 +01:00
parent af67a7ffb0
commit 911f801ece
Signed by: dwenya
GPG key ID: 8DD77074645332D0
4 changed files with 0 additions and 78 deletions

View file

@ -1,31 +0,0 @@
use super::window_events::WindowStateEvent;
use std::cell::RefCell;
use std::rc::Rc;
type EventHandlerFn = Box<dyn Fn(&WindowStateEvent)>;
#[derive(Clone)]
pub struct EventBus {
handlers: Rc<RefCell<Vec<EventHandlerFn>>>,
}
impl Default for EventBus {
fn default() -> Self {
Self::new()
}
}
impl EventBus {
pub fn new() -> Self {
Self {
handlers: Rc::new(RefCell::new(Vec::new())),
}
}
pub fn publish(&self, event: &WindowStateEvent) {
let handlers = self.handlers.borrow();
for handler in handlers.iter() {
handler(event);
}
}
}

View file

@ -1,8 +1,6 @@
use crate::rendering::femtovg::main_window::FemtoVGWindow;
use crate::wayland::surfaces::display_metrics::SharedDisplayMetrics;
use crate::wayland::surfaces::event_bus::EventBus;
use crate::wayland::surfaces::popup_manager::{ActiveWindow, PopupManager};
use crate::wayland::surfaces::window_events::{ScaleSource, WindowStateEvent};
use slint::platform::{WindowAdapter, WindowEvent};
use slint::{LogicalPosition, PhysicalSize};
use std::cell::Cell;
@ -40,7 +38,6 @@ pub struct EventContext {
main_window: Rc<FemtoVGWindow>,
main_surface_id: ObjectId,
popup_manager: Option<Rc<PopupManager>>,
event_bus: EventBus,
display_metrics: SharedDisplayMetrics,
current_pointer_position: LogicalPosition,
last_pointer_serial: u32,
@ -58,7 +55,6 @@ impl EventContext {
main_window,
main_surface_id,
popup_manager: None,
event_bus: EventBus::new(),
display_metrics,
current_pointer_position: LogicalPosition::new(0.0, 0.0),
last_pointer_serial: 0,
@ -68,8 +64,6 @@ impl EventContext {
pub fn set_popup_manager(&mut self, popup_manager: Rc<PopupManager>) {
self.popup_manager = Some(popup_manager);
self.event_bus
.publish(&WindowStateEvent::PopupConfigurationChanged);
}
pub const fn popup_manager(&self) -> Option<&Rc<PopupManager>> {
@ -92,12 +86,6 @@ impl EventContext {
popup_manager.update_scale_factor(new_scale_factor);
}
self.event_bus
.publish(&WindowStateEvent::ScaleFactorChanged {
new_scale: new_scale_factor,
source: ScaleSource::FractionalScale,
});
new_scale_factor
}
@ -119,12 +107,6 @@ impl EventContext {
)
};
self.current_pointer_position = logical_position;
self.event_bus
.publish(&WindowStateEvent::PointerPositionChanged {
physical_x,
physical_y,
});
}
pub const fn last_pointer_serial(&self) -> u32 {
@ -136,9 +118,6 @@ impl EventContext {
if let Some(ref shared_serial) = self.shared_pointer_serial {
shared_serial.update(serial);
}
self.event_bus
.publish(&WindowStateEvent::PointerSerialUpdated { serial });
}
pub fn set_shared_pointer_serial(&mut self, shared_serial: Rc<SharedPointerSerial>) {
@ -165,9 +144,6 @@ impl EventContext {
if let Some(popup_manager) = &self.popup_manager {
popup_manager.update_output_size(output_size);
}
self.event_bus
.publish(&WindowStateEvent::OutputSizeChanged { output_size });
}
pub fn update_scale_for_fractional_scale_object(

View file

@ -1,7 +1,6 @@
pub mod component_state;
pub mod dimensions;
pub mod display_metrics;
pub mod event_bus;
pub mod event_context;
pub mod layer_surface;
pub mod popup_manager;
@ -9,5 +8,4 @@ pub mod popup_surface;
pub mod rendering_state;
pub mod surface_builder;
pub mod surface_state;
pub mod window_events;
pub mod window_renderer;

View file

@ -1,21 +0,0 @@
use slint::PhysicalSize;
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum WindowStateEvent {
ScaleFactorChanged { new_scale: f32, source: ScaleSource },
OutputSizeChanged { output_size: PhysicalSize },
PointerPositionChanged { physical_x: f64, physical_y: f64 },
PointerSerialUpdated { serial: u32 },
PopupConfigurationChanged,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Copy)]
pub enum ScaleSource {
FractionalScale,
}