Move all wayland files into wayland namespace

This commit is contained in:
2025-04-26 02:14:08 -07:00
parent 0244bba6e7
commit 1e5be37996
9 changed files with 16 additions and 30 deletions

View File

@@ -1,14 +1,8 @@
#![feature(unix_socket_ancillary_data)]
use std::error::Error;
mod wl_client;
mod wl_registry;
mod wl_shm;
mod vec_utils;
mod shm;
mod surface;
mod layer_shell;
use wl_client::WlClient;
mod wayland;
use wayland::wl_client::WlClient;
fn main() -> Result<(), Box<dyn Error>> {
let mut wl_client = WlClient::new()?;

View File

@@ -1,9 +1,8 @@
use std::{error::Error, io::Write};
use crate::{surface::UnsetErr, vec_utils::WlMessage, WlClient};
use crate::wayland::{vec_utils::WlMessage, wl_client::WlClient};
const NAMESPACE: &str = "chlorostart";
const OVERLAY: u32 = 3;
const STRIDE: usize = 4;
const EXCLUSIVE: u32 = 0; // exclusize keyboard focus
impl WlClient {

8
src/wayland/mod.rs Normal file
View File

@@ -0,0 +1,8 @@
pub mod layer_shell;
pub mod surface;
pub mod wl_client;
pub mod wl_shm;
pub mod vec_utils;
pub mod shm;
pub mod wl_registry;

View File

@@ -1,6 +1,6 @@
use std::{error::Error, io::Write};
use crate::{vec_utils::WlMessage, WlClient};
use crate::wayland::{vec_utils::WlMessage, wl_client::WlClient};
use std::fmt;

View File

@@ -1,6 +1,6 @@
use std::{env::var, error::Error, fmt::Debug, io::Read, os::unix::net::UnixStream, u32};
use crate::{shm, vec_utils::WlMessage};
use crate::wayland::shm;
struct WlHeader {
object: u32,
@@ -8,15 +8,6 @@ struct WlHeader {
size: u16,
}
pub mod color {
pub const WHITE: u32 = 0xffffffff;
pub const BLACK: u32 = 0xff000000;
pub const RED: u32 = 0xffff0000;
pub const GREEN: u32 = 0xff00ff00;
pub const BLUE: u32 = 0xff0000ff;
pub const SAPPHIRE: u32 = 0xff74c7ec;
}
pub struct WlClient {
pub socket: UnixStream,
pub current_id: u32,

View File

@@ -1,4 +1,4 @@
use crate::{surface::UnsetErr, vec_utils::WlMessage, WlClient};
use crate::wayland::{surface::UnsetErr, vec_utils::WlMessage, wl_client::WlClient};
use std::{io::Write, error::Error};
impl WlClient {

View File

@@ -1,5 +1,5 @@
use std::{error::Error, io::Write, os::unix::net::SocketAncillary, u8};
use crate::{shm, surface::UnsetErr, vec_utils::WlMessage, wl_client::color, WlClient};
use crate::wayland::{shm, surface::UnsetErr, vec_utils::WlMessage, wl_client::WlClient};
const STRIDE: usize = 4;
@@ -12,13 +12,7 @@ impl WlClient {
pub fn wl_shm_create_pool(&mut self, width: usize, height: usize) -> Result<(), Box<dyn Error>> {
self.current_id += 1;
self.shm_pool = Some(shm::ShmPool::new(width * height * STRIDE, self.current_id)?);
self.shm_pool.as_mut().unwrap().write(&vec![color::RED; width * height/6], 0)?;
self.shm_pool.as_mut().unwrap().write(&vec![color::GREEN; width * height/6], (width*height*1/6) as isize)?;
self.shm_pool.as_mut().unwrap().write(&vec![color::BLUE; width * height/6], (width*height*2/6) as isize)?;
self.shm_pool.as_mut().unwrap().write(&vec![color::WHITE; width * height/6], (width*height*3/6) as isize)?;
self.shm_pool.as_mut().unwrap().write(&vec![color::BLACK; width * height/6], (width*height*4/6) as isize)?;
self.shm_pool.as_mut().unwrap().write(&vec![color::SAPPHIRE;width * height/6], (width*height*5/6) as isize)?;
self.shm_pool.as_mut().unwrap().write(&vec![0xffff0000; width * height], 0)?;
let object = self.shm_id.ok_or(UnsetErr("shm_id".to_string()))?;
const OPCODE: u16 = 0;