refactor: minor mathes refactor
parent
130059b979
commit
5cdf4d5af9
|
@ -66,20 +66,14 @@ impl EventLoopHandler {
|
|||
state: &Rc<RefCell<WindowState>>,
|
||||
window: &Rc<FemtoVGWindow>,
|
||||
) -> Result<()> {
|
||||
connection
|
||||
.flush()
|
||||
.map_err(|e| anyhow!("Failed to flush connection: {}", e))?;
|
||||
connection.flush()?;
|
||||
|
||||
let mut event_queue = wayland_queue.borrow_mut();
|
||||
if let Some(guard) = event_queue.prepare_read() {
|
||||
guard
|
||||
.read()
|
||||
.map_err(|e| anyhow!("Failed to read Wayland events: {}", e))?;
|
||||
guard.read()?;
|
||||
}
|
||||
|
||||
event_queue
|
||||
.blocking_dispatch(&mut state.borrow_mut())
|
||||
.map_err(|e| anyhow!("Failed to dispatch Wayland events: {}", e))?;
|
||||
event_queue.blocking_dispatch(&mut state.borrow_mut())?;
|
||||
|
||||
slint::platform::update_timers_and_animations();
|
||||
window.render_frame_if_dirty();
|
||||
|
|
|
@ -138,11 +138,10 @@ impl WindowingSystemBuilder {
|
|||
}
|
||||
|
||||
pub fn build(self) -> Result<WindowingSystem> {
|
||||
if self.config.component_definition.is_none() {
|
||||
return Err(anyhow::anyhow!("Slint component not set"));
|
||||
match self.config.component_definition {
|
||||
Some(_) => WindowingSystem::new(self.config),
|
||||
None => Err(anyhow::anyhow!("Slint component not set")),
|
||||
}
|
||||
|
||||
WindowingSystem::new(self.config)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,18 +270,18 @@ impl WindowingSystem {
|
|||
let mut state = self.state.borrow_mut();
|
||||
self.event_queue
|
||||
.borrow_mut()
|
||||
.blocking_dispatch(&mut state)
|
||||
.context("Failed to dispatch events")?;
|
||||
.blocking_dispatch(&mut state)?;
|
||||
info!("Blocking dispatch completed");
|
||||
|
||||
let size = state.output_size();
|
||||
if size.width > 1 && size.height > 1 {
|
||||
match (size.width, size.height) {
|
||||
(w, h) if w > 1 && h > 1 => {
|
||||
info!("Configured output size: {:?}", size);
|
||||
} else {
|
||||
return Err(anyhow::anyhow!("Invalid output size: {:?}", size));
|
||||
}
|
||||
debug!("Surface configuration complete");
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(anyhow::anyhow!("Invalid output size: {:?}", size)),
|
||||
}
|
||||
}
|
||||
|
||||
fn initialize_renderer_and_ui(&mut self) -> Result<()> {
|
||||
let renderer = self.create_renderer()?;
|
||||
|
|
|
@ -143,21 +143,17 @@ impl Dispatch<WlPointer, ()> for WindowState {
|
|||
state: button_state,
|
||||
..
|
||||
} => {
|
||||
let is_press =
|
||||
matches!(button_state, WEnum::Value(wl_pointer::ButtonState::Pressed));
|
||||
let current_position = state.current_pointer_position();
|
||||
if let Some(window) = state.window() {
|
||||
let event = if is_press {
|
||||
WindowEvent::PointerPressed {
|
||||
let event = match button_state {
|
||||
WEnum::Value(wl_pointer::ButtonState::Pressed) => WindowEvent::PointerPressed {
|
||||
button: PointerEventButton::Left,
|
||||
position: current_position,
|
||||
}
|
||||
} else {
|
||||
WindowEvent::PointerReleased {
|
||||
position: state.current_pointer_position(),
|
||||
},
|
||||
_ => WindowEvent::PointerReleased {
|
||||
button: PointerEventButton::Left,
|
||||
position: current_position,
|
||||
}
|
||||
position: state.current_pointer_position(),
|
||||
},
|
||||
};
|
||||
if let Some(window) = state.window() {
|
||||
window.dispatch_event(event);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue