diff --git a/src/layer_shell.rs b/src/layer_shell.rs index 6954e62..edb3f98 100644 --- a/src/layer_shell.rs +++ b/src/layer_shell.rs @@ -3,6 +3,8 @@ use crate::{surface::UnsetErr, vec_utils::WlMessage, WlClient}; const NAMESPACE: &str = "chlorostart"; const OVERLAY: u32 = 3; +const STRIDE: usize = 4; +const EXCLUSIVE: u32 = 1; // exclusize keyboard focus impl WlClient { pub fn layer_shell_get_layer_surface(&mut self) -> Result<(), Box> { @@ -85,7 +87,6 @@ impl WlClient { let object: u32 = self.layer_surface_id.unwrap(); const OPCODE: u16 = 4; const MSG_SIZE: u16 = 12; - const EXCLUSIVE: u32 = 1; // exclusize keyboard focus let mut request = vec![0u8; MSG_SIZE as usize]; let mut offset: usize = 0; diff --git a/src/wl_client.rs b/src/wl_client.rs index 86a15fc..670a609 100644 --- a/src/wl_client.rs +++ b/src/wl_client.rs @@ -89,4 +89,3 @@ impl WlClient { Ok(()) } } - diff --git a/src/wl_registry.rs b/src/wl_registry.rs index 2affd81..77fd4ee 100644 --- a/src/wl_registry.rs +++ b/src/wl_registry.rs @@ -19,14 +19,12 @@ impl WlClient { self.wl_compositor_create_surface()?; self.layer_shell_get_layer_surface()?; - self.layer_surface_set_size(200, 200)?; + self.layer_surface_set_size(800, 800)?; self.layer_surface_set_keyboard_interactivity()?; self.wl_surface_commit()?; - self.wl_shm_create_pool()?; - self.wl_shm_pool_create_buffer(0, 200, 200)?; - // self.wl_surface_attach()?; - // self.wl_surface_commit()?; + self.wl_shm_create_pool(800, 800)?; + self.wl_shm_pool_create_buffer(0, 800, 800)?; Ok(()) } diff --git a/src/wl_shm.rs b/src/wl_shm.rs index 5299a0f..e824806 100644 --- a/src/wl_shm.rs +++ b/src/wl_shm.rs @@ -1,15 +1,17 @@ use std::{io::Write, error::Error, os::unix::net::SocketAncillary}; use crate::{WlClient, vec_utils::WlMessage, shm}; +const STRIDE: usize = 4; + impl WlClient { pub fn wl_shm_format(event: &Vec) { let mut offset = 0; println!("Received pixel format: {:x}", event.read_u32(&mut offset)); } - pub fn wl_shm_create_pool(&mut self) -> Result<(), String> { + pub fn wl_shm_create_pool(&mut self, width: usize, height: usize) -> Result<(), String> { self.current_id += 1; - self.shm_pool = Some(match shm::ShmPool::new(4096, self.current_id) { + self.shm_pool = Some(match shm::ShmPool::new(width * height * STRIDE, self.current_id) { Ok(val) => val, Err(err) => { return Err(err.to_string());