aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/compositor.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-07 19:44:40 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-10 14:49:38 +0400
commitad3c3f8cefd38d2bf26b466d8e34eccde3bca443 (patch)
tree5783df13fa895bb6a8244556fb31b6504312b82b /src/handlers/compositor.rs
downloadniri-ad3c3f8cefd38d2bf26b466d8e34eccde3bca443.tar.gz
niri-ad3c3f8cefd38d2bf26b466d8e34eccde3bca443.tar.bz2
niri-ad3c3f8cefd38d2bf26b466d8e34eccde3bca443.zip
Init from smallvil
Diffstat (limited to 'src/handlers/compositor.rs')
-rw-r--r--src/handlers/compositor.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs
new file mode 100644
index 00000000..fcb0dc02
--- /dev/null
+++ b/src/handlers/compositor.rs
@@ -0,0 +1,57 @@
+use crate::{grabs::resize_grab, state::ClientState, Smallvil};
+use smithay::{
+ backend::renderer::utils::on_commit_buffer_handler,
+ delegate_compositor, delegate_shm,
+ reexports::wayland_server::{
+ protocol::{wl_buffer, wl_surface::WlSurface},
+ Client,
+ },
+ wayland::{
+ buffer::BufferHandler,
+ compositor::{
+ get_parent, is_sync_subsurface, CompositorClientState, CompositorHandler, CompositorState,
+ },
+ shm::{ShmHandler, ShmState},
+ },
+};
+
+use super::xdg_shell;
+
+impl CompositorHandler for Smallvil {
+ fn compositor_state(&mut self) -> &mut CompositorState {
+ &mut self.compositor_state
+ }
+
+ fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState {
+ &client.get_data::<ClientState>().unwrap().compositor_state
+ }
+
+ fn commit(&mut self, surface: &WlSurface) {
+ on_commit_buffer_handler::<Self>(surface);
+ if !is_sync_subsurface(surface) {
+ let mut root = surface.clone();
+ while let Some(parent) = get_parent(&root) {
+ root = parent;
+ }
+ if let Some(window) = self.space.elements().find(|w| w.toplevel().wl_surface() == &root) {
+ window.on_commit();
+ }
+ };
+
+ xdg_shell::handle_commit(&self.space, surface);
+ resize_grab::handle_commit(&mut self.space, surface);
+ }
+}
+
+impl BufferHandler for Smallvil {
+ fn buffer_destroyed(&mut self, _buffer: &wl_buffer::WlBuffer) {}
+}
+
+impl ShmHandler for Smallvil {
+ fn shm_state(&self) -> &ShmState {
+ &self.shm_state
+ }
+}
+
+delegate_compositor!(Smallvil);
+delegate_shm!(Smallvil);