feat: support idle notification and inhibition

This commit is contained in:
Samuel Onoja committed 2026-09-25 00:48:06 +01:00
1 parent e57d355db2
commit 37eb7cb9e9
4 files changed
+56 -2

No files matched your search

+12
View File
@@ -56,6 +56,18 @@ impl CompositorHandler for Ferese {
xdg_shell::handle_commit(&mut self.popups, &mut self.space, surface);
crate::backends::direct::render_all(self);
}
fn destroyed(&mut self, surface: &WlSurface) {
if self.idle_inhibitors.remove(surface).is_some() {
self.idle_notifier_state
.set_is_inhibited(!self.idle_inhibitors.is_empty());
}
if matches!(&self.cursor_status, smithay::input::pointer::CursorImageStatus::Surface(cursor) if cursor == surface)
{
self.cursor_status = smithay::input::pointer::CursorImageStatus::default_named();
crate::backends::direct::render_all(self);
}
}
}
impl BufferHandler for Ferese {
+29
View File
@@ -13,6 +13,8 @@ use smithay::{
wayland::{
compositor::{TraversalAction, with_states, with_surface_tree_downward},
fractional_scale::{FractionalScaleHandler, with_fractional_scale},
idle_inhibit::IdleInhibitHandler,
idle_notify::{IdleNotifierHandler, IdleNotifierState},
output::OutputHandler,
pointer_constraints::{
PointerConstraint, PointerConstraintsHandler, with_pointer_constraint,
@@ -73,6 +75,31 @@ impl FractionalScaleHandler for Ferese {
}
}
impl IdleNotifierHandler for Ferese {
fn idle_notifier_state(&mut self) -> &mut IdleNotifierState<Self> {
&mut self.idle_notifier_state
}
}
impl IdleInhibitHandler for Ferese {
fn inhibit(&mut self, surface: WlSurface) {
let count = self.idle_inhibitors.entry(surface).or_default();
*count = count.saturating_add(1);
self.idle_notifier_state.set_is_inhibited(true);
}
fn uninhibit(&mut self, surface: WlSurface) {
if let Some(count) = self.idle_inhibitors.get_mut(&surface) {
*count = count.saturating_sub(1);
if *count == 0 {
self.idle_inhibitors.remove(&surface);
}
}
self.idle_notifier_state
.set_is_inhibited(!self.idle_inhibitors.is_empty());
}
}
impl Ferese {
pub fn update_fractional_scale(&self, scale: f64) {
for window in self.space.elements() {
@@ -160,6 +187,8 @@ impl XdgForeignHandler for Ferese {
smithay::delegate_compositor!(Ferese);
smithay::delegate_data_device!(Ferese);
smithay::delegate_fractional_scale!(Ferese);
smithay::delegate_idle_inhibit!(Ferese);
smithay::delegate_idle_notify!(Ferese);
smithay::delegate_layer_shell!(Ferese);
smithay::delegate_output!(Ferese);
smithay::delegate_pointer_constraints!(Ferese);