From 28a8a9ace2804bd5e9c9c9d74761d5f0b4034f98 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 23 Aug 2024 18:51:47 +0300 Subject: Register deadline timer for closing transaction --- src/handlers/compositor.rs | 8 +++++++- src/handlers/xdg_shell.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index 9614883d..ebc4a984 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -219,9 +219,15 @@ impl CompositorHandler for State { id: u64::from(id.get()), }); - self.niri.layout.remove_window(&window, transaction); + self.niri.layout.remove_window(&window, transaction.clone()); self.add_default_dmabuf_pre_commit_hook(surface); + // If this is the only instance, then this transaction will complete + // immediately, so no need to set the timer. + if !transaction.is_last() { + transaction.register_deadline_timer(&self.niri.event_loop); + } + if was_active { self.maybe_warp_cursor_to_focus(); } diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index b77f566e..b7d267dd 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -498,9 +498,15 @@ impl XdgShellHandler for State { let active_window = self.niri.layout.active_window().map(|(m, _)| &m.window); let was_active = active_window == Some(&window); - self.niri.layout.remove_window(&window, transaction); + self.niri.layout.remove_window(&window, transaction.clone()); self.add_default_dmabuf_pre_commit_hook(surface.wl_surface()); + // If this is the only instance, then this transaction will complete immediately, so no + // need to set the timer. + if !transaction.is_last() { + transaction.register_deadline_timer(&self.niri.event_loop); + } + if was_active { self.maybe_warp_cursor_to_focus(); } -- cgit