mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-30 20:34:49 +01:00
Fix immediate crash on udev
This commit is contained in:
parent
5f8352452b
commit
e28998afe4
4 changed files with 622 additions and 435 deletions
|
@ -225,7 +225,13 @@ pub fn run_udev() -> Result<(), Box<dyn Error>> {
|
|||
pointer_images: Vec::new(),
|
||||
pointer_element: PointerElement::default(),
|
||||
};
|
||||
let mut state = State::init(
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
let mut state = State::<UdevData>::init(
|
||||
data,
|
||||
&mut display,
|
||||
event_loop.get_signal(),
|
||||
|
@ -236,6 +242,39 @@ pub fn run_udev() -> Result<(), Box<dyn Error>> {
|
|||
* Initialize the udev backend
|
||||
*/
|
||||
let udev_backend = UdevBackend::new(state.seat.name())?;
|
||||
|
||||
for (device_id, path) in udev_backend.device_list() {
|
||||
if let Err(err) = DrmNode::from_dev_id(device_id)
|
||||
.map_err(DeviceAddError::DrmNode)
|
||||
.and_then(|node| state.device_added(node, path))
|
||||
{
|
||||
tracing::error!("Skipping device {device_id}: {err}");
|
||||
}
|
||||
}
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(udev_backend, move |event, _, data| match event {
|
||||
UdevEvent::Added { device_id, path } => {
|
||||
if let Err(err) = DrmNode::from_dev_id(device_id)
|
||||
.map_err(DeviceAddError::DrmNode)
|
||||
.and_then(|node| data.state.device_added(node, &path))
|
||||
{
|
||||
tracing::error!("Skipping device {device_id}: {err}");
|
||||
}
|
||||
}
|
||||
UdevEvent::Changed { device_id } => {
|
||||
if let Ok(node) = DrmNode::from_dev_id(device_id) {
|
||||
data.state.device_changed(node)
|
||||
}
|
||||
}
|
||||
UdevEvent::Removed { device_id } => {
|
||||
if let Ok(node) = DrmNode::from_dev_id(device_id) {
|
||||
data.state.device_removed(node)
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
/*
|
||||
* Initialize libinput backend
|
||||
*/
|
||||
|
@ -299,14 +338,6 @@ pub fn run_udev() -> Result<(), Box<dyn Error>> {
|
|||
})
|
||||
.unwrap();
|
||||
|
||||
for (device_id, path) in udev_backend.device_list() {
|
||||
if let Err(err) = DrmNode::from_dev_id(device_id)
|
||||
.map_err(DeviceAddError::DrmNode)
|
||||
.and_then(|node| state.device_added(node, path))
|
||||
{
|
||||
tracing::error!("Skipping device {device_id}: {err}");
|
||||
}
|
||||
}
|
||||
state.shm_state.update_formats(
|
||||
state
|
||||
.backend_data
|
||||
|
@ -422,30 +453,6 @@ pub fn run_udev() -> Result<(), Box<dyn Error>> {
|
|||
});
|
||||
});
|
||||
|
||||
event_loop
|
||||
.handle()
|
||||
.insert_source(udev_backend, move |event, _, data| match event {
|
||||
UdevEvent::Added { device_id, path } => {
|
||||
if let Err(err) = DrmNode::from_dev_id(device_id)
|
||||
.map_err(DeviceAddError::DrmNode)
|
||||
.and_then(|node| data.state.device_added(node, &path))
|
||||
{
|
||||
tracing::error!("Skipping device {device_id}: {err}");
|
||||
}
|
||||
}
|
||||
UdevEvent::Changed { device_id } => {
|
||||
if let Ok(node) = DrmNode::from_dev_id(device_id) {
|
||||
data.state.device_changed(node)
|
||||
}
|
||||
}
|
||||
UdevEvent::Removed { device_id } => {
|
||||
if let Ok(node) = DrmNode::from_dev_id(device_id) {
|
||||
data.state.device_removed(node)
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
event_loop.run(
|
||||
Some(Duration::from_millis(6)),
|
||||
&mut CalloopData { state, display },
|
||||
|
@ -829,6 +836,8 @@ impl State<UdevData> {
|
|||
);
|
||||
let global = output.create_global::<State<UdevData>>(&self.backend_data.display_handle);
|
||||
|
||||
self.focus_state.focused_output = Some(output.clone());
|
||||
|
||||
let x = self.space.outputs().fold(0, |acc, o| {
|
||||
acc + self.space.output_geometry(o).unwrap().size.w
|
||||
});
|
||||
|
|
|
@ -177,7 +177,7 @@ pub fn run_winit() -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
};
|
||||
|
||||
let mut state = State::init(
|
||||
let mut state = State::<WinitData>::init(
|
||||
WinitData {
|
||||
backend: winit_backend,
|
||||
damage_tracker: OutputDamageTracker::from_output(&output),
|
||||
|
|
|
@ -245,6 +245,12 @@ impl<B: Backend> State<B> {
|
|||
.get(&(modifier_mask.into(), raw_sym))
|
||||
{
|
||||
return FilterResult::Intercept(*callback_id);
|
||||
} else if modifiers.ctrl
|
||||
&& modifiers.shift
|
||||
&& modifiers.alt
|
||||
&& keysym.modified_sym() == keysyms::KEY_Escape
|
||||
{
|
||||
return FilterResult::Intercept(CallbackId(999999));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,6 +273,9 @@ impl<B: Backend> State<B> {
|
|||
self.move_mode = move_mode;
|
||||
|
||||
if let Some(callback_id) = action {
|
||||
if callback_id.0 == 999999 {
|
||||
self.loop_signal.stop();
|
||||
}
|
||||
if let Some(stream) = self.api_state.stream.as_ref() {
|
||||
if let Err(err) = crate::api::send_to_client(
|
||||
&mut stream.lock().expect("Could not lock stream mutex"),
|
||||
|
|
971
src/state.rs
971
src/state.rs
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue