aboutsummaryrefslogtreecommitdiff
path: root/src/handlers
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-02-08 13:51:54 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-02-09 15:50:40 +0400
commitb9116c579a6e99cae5393912fc9ed28674f5d3e5 (patch)
tree9b2a165b839154cca60f2efd626c26dd6b3a9d71 /src/handlers
parentd8dcadc5b279c11e8cb8d1b0b064cc2b62c04099 (diff)
downloadniri-b9116c579a6e99cae5393912fc9ed28674f5d3e5.tar.gz
niri-b9116c579a6e99cae5393912fc9ed28674f5d3e5.tar.bz2
niri-b9116c579a6e99cae5393912fc9ed28674f5d3e5.zip
Implement idle-notify and idle-inhibit
Diffstat (limited to 'src/handlers')
-rw-r--r--src/handlers/compositor.rs12
-rw-r--r--src/handlers/mod.rs29
2 files changed, 35 insertions, 6 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs
index 5522e48d..fba025e8 100644
--- a/src/handlers/compositor.rs
+++ b/src/handlers/compositor.rs
@@ -97,7 +97,11 @@ impl CompositorHandler for State {
// This is a root surface commit. It might have mapped a previously-unmapped toplevel.
if let Entry::Occupied(entry) = self.niri.unmapped_windows.entry(surface.clone()) {
let is_mapped =
- with_renderer_surface_state(surface, |state| state.buffer().is_some());
+ with_renderer_surface_state(surface, |state| state.buffer().is_some())
+ .unwrap_or_else(|| {
+ error!("no renderer surface state even though we use commit handler");
+ false
+ });
if is_mapped {
// The toplevel got mapped.
@@ -140,7 +144,11 @@ impl CompositorHandler for State {
// This is a commit of a previously-mapped toplevel.
let is_mapped =
- with_renderer_surface_state(surface, |state| state.buffer().is_some());
+ with_renderer_surface_state(surface, |state| state.buffer().is_some())
+ .unwrap_or_else(|| {
+ error!("no renderer surface state even though we use commit handler");
+ false
+ });
if !is_mapped {
// The toplevel got unmapped.
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index 07fb1a64..f11ff4d6 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -22,6 +22,8 @@ use smithay::reexports::wayland_server::Resource;
use smithay::utils::{Logical, Rectangle, Size};
use smithay::wayland::compositor::{send_surface_state, with_states};
use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportNotifier};
+use smithay::wayland::idle_inhibit::IdleInhibitHandler;
+use smithay::wayland::idle_notify::{IdleNotifierHandler, IdleNotifierState};
use smithay::wayland::input_method::{InputMethodHandler, PopupSurface};
use smithay::wayland::output::OutputHandler;
use smithay::wayland::pointer_constraints::PointerConstraintsHandler;
@@ -42,10 +44,11 @@ use smithay::wayland::session_lock::{
};
use smithay::{
delegate_cursor_shape, delegate_data_control, delegate_data_device, delegate_dmabuf,
- delegate_input_method_manager, delegate_output, delegate_pointer_constraints,
- delegate_pointer_gestures, delegate_presentation, delegate_primary_selection,
- delegate_relative_pointer, delegate_seat, delegate_security_context, delegate_session_lock,
- delegate_tablet_manager, delegate_text_input_manager, delegate_virtual_keyboard_manager,
+ delegate_idle_inhibit, delegate_idle_notify, delegate_input_method_manager, delegate_output,
+ delegate_pointer_constraints, delegate_pointer_gestures, delegate_presentation,
+ delegate_primary_selection, delegate_relative_pointer, delegate_seat,
+ delegate_security_context, delegate_session_lock, delegate_tablet_manager,
+ delegate_text_input_manager, delegate_virtual_keyboard_manager,
};
use crate::delegate_foreign_toplevel;
@@ -300,6 +303,24 @@ impl SecurityContextHandler for State {
}
delegate_security_context!(State);
+impl IdleNotifierHandler for State {
+ fn idle_notifier_state(&mut self) -> &mut IdleNotifierState<Self> {
+ &mut self.niri.idle_notifier_state
+ }
+}
+delegate_idle_notify!(State);
+
+impl IdleInhibitHandler for State {
+ fn inhibit(&mut self, surface: WlSurface) {
+ self.niri.idle_inhibiting_surfaces.insert(surface);
+ }
+
+ fn uninhibit(&mut self, surface: WlSurface) {
+ self.niri.idle_inhibiting_surfaces.remove(&surface);
+ }
+}
+delegate_idle_inhibit!(State);
+
impl ForeignToplevelHandler for State {
fn foreign_toplevel_manager_state(&mut self) -> &mut ForeignToplevelManagerState {
&mut self.niri.foreign_toplevel_state