mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Remove LoopData
The calloop Smithay update finally lets me do this.
This commit is contained in:
+42
-44
@@ -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)
|
||||
}
|
||||
UdevEvent::Removed { device_id } => {
|
||||
if !tty.session.is_active() {
|
||||
debug!("skipping UdevEvent::Removed as session is inactive");
|
||||
return;
|
||||
}
|
||||
|
||||
tty.device_removed(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;
|
||||
}
|
||||
|
||||
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}"),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user