Add login1 LidClosed monitoring

This commit is contained in:
Ivan Molodetskikh
2025-10-18 09:13:41 +03:00
parent a4f5c90cf0
commit 8c8447918f
3 changed files with 135 additions and 0 deletions
+12
View File
@@ -120,6 +120,8 @@ use crate::cursor::{CursorManager, CursorTextureCache, RenderCursor, XCursor};
#[cfg(feature = "dbus")]
use crate::dbus::freedesktop_locale1::Locale1ToNiri;
#[cfg(feature = "dbus")]
use crate::dbus::freedesktop_login1::Login1ToNiri;
#[cfg(feature = "dbus")]
use crate::dbus::gnome_shell_introspect::{self, IntrospectToNiri, NiriToIntrospect};
#[cfg(feature = "dbus")]
use crate::dbus::gnome_shell_screenshot::{NiriToScreenshot, ScreenshotToNiri};
@@ -726,6 +728,8 @@ impl State {
self.niri.notified_activity_this_iteration = false;
}
// We monitor both libinput and logind: libinput is always there (including without DBus), but
// it misses some switch events (e.g. after unsuspend) on some systems.
pub fn set_lid_closed(&mut self, is_closed: bool) {
if self.niri.is_lid_closed == is_closed {
return;
@@ -2298,6 +2302,14 @@ impl State {
}
}
#[cfg(feature = "dbus")]
pub fn on_login1_msg(&mut self, msg: Login1ToNiri) {
let Login1ToNiri::LidClosedChanged(is_closed) = msg;
trace!("login1 lid {}", if is_closed { "closed" } else { "opened" });
self.set_lid_closed(is_closed);
}
#[cfg(feature = "dbus")]
pub fn on_locale1_msg(&mut self, msg: Locale1ToNiri) {
let Locale1ToNiri::XkbChanged(xkb) = msg;