add config options for waking dpms on mouse and keyboard interaction
This commit is contained in:
parent
2167484861
commit
eece44a59c
12 changed files with 116 additions and 9 deletions
21
src/state.rs
21
src/state.rs
|
|
@ -342,10 +342,13 @@ pub struct IdleState {
|
|||
pub change: AsyncEvent,
|
||||
pub timeout: Cell<Duration>,
|
||||
pub grace_period: Cell<Duration>,
|
||||
pub key_press_enables_dpms: Cell<bool>,
|
||||
pub mouse_move_enables_dpms: Cell<bool>,
|
||||
pub timeout_changed: Cell<bool>,
|
||||
pub inhibitors: CopyHashMap<IdleInhibitorId, Rc<ZwpIdleInhibitorV1>>,
|
||||
pub inhibitors_changed: Cell<bool>,
|
||||
pub backend_idle: Cell<bool>,
|
||||
pub dpms_off_by_command: Cell<bool>,
|
||||
pub inhibited_idle_notifications:
|
||||
CopyHashMap<(ClientId, ExtIdleNotificationV1Id), Rc<ExtIdleNotificationV1>>,
|
||||
pub in_grace_period: Cell<bool>,
|
||||
|
|
@ -975,7 +978,14 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn input_occurred(&self) {
|
||||
pub fn input_occurred(self: &Rc<Self>, key_press: bool, mouse_move: bool) {
|
||||
if self.idle.dpms_off_by_command.get() {
|
||||
let enable_dpms = key_press && self.idle.key_press_enables_dpms.get()
|
||||
|| mouse_move && self.idle.mouse_move_enables_dpms.get();
|
||||
if enable_dpms && let Err(e) = self.set_dpms_active(true) {
|
||||
log::error!("Could not enable DPMS after input: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
if !self.idle.input.replace(true) {
|
||||
self.idle.change.trigger();
|
||||
}
|
||||
|
|
@ -1420,6 +1430,15 @@ impl State {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_dpms_active(
|
||||
self: &Rc<Self>,
|
||||
active: bool,
|
||||
) -> Result<(), BackendConnectorTransactionError> {
|
||||
self.set_connectors_active(active)?;
|
||||
self.idle.dpms_off_by_command.set(!active);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn root_visible(&self) -> bool {
|
||||
!self.idle.backend_idle.get()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue