diff --git a/src/handlers.rs b/src/handlers.rs index 7de199c..84a554c 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -10,8 +10,8 @@ use std::{mem, os::fd::OwnedFd, sync::Arc}; use smithay::{ backend::renderer::utils::{self, with_renderer_surface_state}, delegate_compositor, delegate_data_control, delegate_data_device, delegate_fractional_scale, - delegate_layer_shell, delegate_output, delegate_pointer_constraints, delegate_presentation, - delegate_primary_selection, delegate_relative_pointer, delegate_seat, + delegate_idle_notify, delegate_layer_shell, delegate_output, delegate_pointer_constraints, + delegate_presentation, delegate_primary_selection, delegate_relative_pointer, delegate_seat, delegate_security_context, delegate_shm, delegate_viewporter, delegate_xwayland_shell, desktop::{ self, find_popup_root_surface, get_popup_toplevel_coords, layer_map_for_output, PopupKind, @@ -42,6 +42,7 @@ use smithay::{ }, dmabuf, fractional_scale::{self, FractionalScaleHandler}, + idle_notify::{IdleNotifierHandler, IdleNotifierState}, output::OutputHandler, pointer_constraints::{with_pointer_constraint, PointerConstraintsHandler}, seat::WaylandFocus, @@ -917,6 +918,13 @@ impl XWaylandShellHandler for State { } delegate_xwayland_shell!(State); +impl IdleNotifierHandler for State { + fn idle_notifier_state(&mut self) -> &mut IdleNotifierState { + &mut self.pinnacle.idle_notifier_state + } +} +delegate_idle_notify!(State); + impl Pinnacle { fn position_popup(&self, popup: &PopupSurface) { trace!("State::position_popup"); diff --git a/src/input.rs b/src/input.rs index b4aed4d..6fe8c5f 100644 --- a/src/input.rs +++ b/src/input.rs @@ -400,6 +400,10 @@ impl State { } fn keyboard(&mut self, event: I::KeyboardKeyEvent) { + self.pinnacle + .idle_notifier_state + .notify_activity(&self.pinnacle.seat); + let serial = SERIAL_COUNTER.next_serial(); let time = event.time_msec(); let press_state = event.state(); @@ -616,6 +620,10 @@ impl State { } fn pointer_button(&mut self, event: I::PointerButtonEvent) { + self.pinnacle + .idle_notifier_state + .notify_activity(&self.pinnacle.seat); + let Some(pointer) = self.pinnacle.seat.get_pointer() else { return; }; @@ -699,6 +707,10 @@ impl State { } fn pointer_axis(&mut self, event: I::PointerAxisEvent) { + self.pinnacle + .idle_notifier_state + .notify_activity(&self.pinnacle.seat); + let source = event.source(); let horizontal_amount = event @@ -747,6 +759,10 @@ impl State { /// This *should* only be generated on the winit backend. /// Unless there's a case where it's generated on udev that I'm unaware of. fn pointer_motion_absolute(&mut self, event: I::PointerMotionAbsoluteEvent) { + self.pinnacle + .idle_notifier_state + .notify_activity(&self.pinnacle.seat); + let Some(pointer) = self.pinnacle.seat.get_pointer() else { error!("Pointer motion absolute received with no pointer on seat"); return; @@ -795,6 +811,10 @@ impl State { } fn pointer_motion(&mut self, event: I::PointerMotionEvent) { + self.pinnacle + .idle_notifier_state + .notify_activity(&self.pinnacle.seat); + let Some(pointer) = self.pinnacle.seat.get_pointer() else { error!("Pointer motion received with no pointer on seat"); return; diff --git a/src/state.rs b/src/state.rs index ebfa8a0..3dc6d32 100644 --- a/src/state.rs +++ b/src/state.rs @@ -34,6 +34,7 @@ use smithay::{ compositor::{self, CompositorClientState, CompositorState}, dmabuf::DmabufFeedback, fractional_scale::FractionalScaleManagerState, + idle_notify::IdleNotifierState, output::OutputManagerState, pointer_constraints::PointerConstraintsState, relative_pointer::RelativePointerManagerState, @@ -99,6 +100,7 @@ pub struct Pinnacle { pub foreign_toplevel_manager_state: ForeignToplevelManagerState, pub session_lock_manager_state: SessionLockManagerState, pub xwayland_shell_state: XWaylandShellState, + pub idle_notifier_state: IdleNotifierState, pub lock_state: LockState, @@ -241,7 +243,7 @@ impl Pinnacle { let pinnacle = Pinnacle { loop_signal, - loop_handle, + loop_handle: loop_handle.clone(), display_handle: display_handle.clone(), clock: Clock::::new(), compositor_state: CompositorState::new::(&display_handle), @@ -287,6 +289,7 @@ impl Pinnacle { filter_restricted_client, ), xwayland_shell_state: XWaylandShellState::new::(&display_handle), + idle_notifier_state: IdleNotifierState::new(&display_handle, loop_handle), lock_state: LockState::default(),