diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-24 17:30:06 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-26 13:45:03 +0400 |
| commit | cd4f7c0378e7ce3ed14a1d1b1a1146c7a7ef33bf (patch) | |
| tree | e1f594fbcb7e747aee8bcd4dba5170b32212ae66 /src/backend/tty.rs | |
| parent | c422fdab0fd19f61ee5ad73a46312d4284641f3c (diff) | |
| download | niri-cd4f7c0378e7ce3ed14a1d1b1a1146c7a7ef33bf.tar.gz niri-cd4f7c0378e7ce3ed14a1d1b1a1146c7a7ef33bf.tar.bz2 niri-cd4f7c0378e7ce3ed14a1d1b1a1146c7a7ef33bf.zip | |
Remove LoopData
The calloop Smithay update finally lets me do this.
Diffstat (limited to 'src/backend/tty.rs')
| -rw-r--r-- | src/backend/tty.rs | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs index bce16ff0..c9ba9b6a 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -39,7 +39,7 @@ use smithay_drm_extras::edid::EdidInfo; use crate::config::Config; use crate::niri::{OutputRenderElements, State}; use crate::utils::get_monotonic_time; -use crate::{LoopData, Niri}; +use crate::Niri; const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.]; const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888]; @@ -47,7 +47,7 @@ const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888] pub struct Tty { config: Rc<RefCell<Config>>, session: LibSeatSession, - udev_dispatcher: Dispatcher<'static, UdevBackend, LoopData>, + udev_dispatcher: Dispatcher<'static, UdevBackend, State>, primary_gpu_path: PathBuf, output_device: Option<OutputDevice>, connectors: Arc<Mutex<HashMap<String, Output>>>, @@ -94,45 +94,44 @@ struct Surface { } impl Tty { - pub fn new(config: Rc<RefCell<Config>>, event_loop: LoopHandle<'static, LoopData>) -> Self { + pub fn new(config: Rc<RefCell<Config>>, event_loop: LoopHandle<'static, State>) -> Self { let (session, notifier) = LibSeatSession::new().unwrap(); let seat_name = session.seat(); let udev_backend = UdevBackend::new(session.seat()).unwrap(); - let udev_dispatcher = - Dispatcher::new(udev_backend, move |event, _, data: &mut LoopData| { - let tty = data.state.backend.tty(); - let niri = &mut data.state.niri; + let udev_dispatcher = Dispatcher::new(udev_backend, move |event, _, state: &mut State| { + let tty = state.backend.tty(); + let niri = &mut state.niri; - match event { - UdevEvent::Added { device_id, path } => { - if !tty.session.is_active() { - debug!("skipping UdevEvent::Added as session is inactive"); - return; - } - - if let Err(err) = tty.device_added(device_id, &path, niri) { - warn!("error adding device: {err:?}"); - } + match event { + UdevEvent::Added { device_id, path } => { + if !tty.session.is_active() { + debug!("skipping UdevEvent::Added as session is inactive"); + return; } - UdevEvent::Changed { device_id } => { - if !tty.session.is_active() { - debug!("skipping UdevEvent::Changed as session is inactive"); - return; - } - tty.device_changed(device_id, niri) + if let Err(err) = tty.device_added(device_id, &path, niri) { + warn!("error adding device: {err:?}"); + } + } + UdevEvent::Changed { device_id } => { + if !tty.session.is_active() { + debug!("skipping UdevEvent::Changed as session is inactive"); + return; } - UdevEvent::Removed { device_id } => { - if !tty.session.is_active() { - debug!("skipping UdevEvent::Removed as session is inactive"); - return; - } - tty.device_removed(device_id, niri) + tty.device_changed(device_id, niri) + } + UdevEvent::Removed { device_id } => { + if !tty.session.is_active() { + debug!("skipping UdevEvent::Removed as session is inactive"); + return; } + + tty.device_removed(device_id, niri) } - }); + } + }); event_loop .register_dispatcher(udev_dispatcher.clone()) .unwrap(); @@ -142,17 +141,17 @@ impl Tty { let input_backend = LibinputInputBackend::new(libinput.clone()); event_loop - .insert_source(input_backend, |mut event, _, data| { - data.state.process_libinput_event(&mut event); - data.state.process_input_event(event); + .insert_source(input_backend, |mut event, _, state| { + state.process_libinput_event(&mut event); + state.process_input_event(event); }) .unwrap(); let udev_dispatcher_c = udev_dispatcher.clone(); event_loop - .insert_source(notifier, move |event, _, data| { - let tty = data.state.backend.tty(); - let niri = &mut data.state.niri; + .insert_source(notifier, move |event, _, state| { + let tty = state.backend.tty(); + let niri = &mut state.niri; match event { SessionEvent::PauseSession => { @@ -303,8 +302,8 @@ impl Tty { let token = niri .event_loop - .insert_source(drm_notifier, move |event, metadata, data| { - let tty = data.state.backend.tty(); + .insert_source(drm_notifier, move |event, metadata, state| { + let tty = state.backend.tty(); match event { DrmEvent::VBlank(crtc) => { let now = get_monotonic_time(); @@ -349,8 +348,7 @@ impl Tty { .unwrap() .message(&message, 0); - let output = data - .state + let output = state .niri .global_space .outputs() @@ -360,7 +358,7 @@ impl Tty { }) .unwrap() .clone(); - let output_state = data.state.niri.output_state.get_mut(&output).unwrap(); + let output_state = state.niri.output_state.get_mut(&output).unwrap(); // Mark the last frame as submitted. match surface.compositor.frame_submitted() { @@ -398,7 +396,7 @@ impl Tty { output_state.waiting_for_vblank = false; output_state.frame_clock.presented(presentation_time); - data.state.niri.queue_redraw(output); + state.niri.queue_redraw(output); } DrmEvent::Error(error) => error!("DRM error: {error}"), }; |
