Set shm pool size based on layer surface width and height
This commit is contained in:
@@ -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<dyn Error>> {
|
||||
@@ -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;
|
||||
|
||||
@@ -89,4 +89,3 @@ impl WlClient {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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<u8>) {
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user