Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9583a87f2f | |||
| 375b44beee |
10
src/main.rs
10
src/main.rs
@@ -8,15 +8,5 @@ mod graphics;
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut wl_client = WlClient::new()?;
|
||||
|
||||
wl_client.wl_display_get_registry()?;
|
||||
|
||||
loop {
|
||||
wl_client.read_event()?;
|
||||
|
||||
if false {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{error::Error, io::Write};
|
||||
use crate::wayland::{vec_utils::WlMessage, wl_client::WlClient};
|
||||
use std::{error::Error, io::Write, sync::atomic::Ordering};
|
||||
use crate::wayland::{surface::UnsetErr, vec_utils::WlMessage, wl_client::WlClient};
|
||||
|
||||
const NAMESPACE: &str = "chlorostart";
|
||||
const OVERLAY: u32 = 3;
|
||||
@@ -7,7 +7,11 @@ const EXCLUSIVE: u32 = 0; // exclusize keyboard focus
|
||||
|
||||
impl WlClient {
|
||||
pub fn layer_shell_get_layer_surface(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
let object: u32 = self.layer_shell_id.unwrap();
|
||||
// TODO: Make sure layer_surface_id isn't already set
|
||||
let object: u32 = self.layer_shell_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("layer_shell_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 0;
|
||||
let msg_size: u16 = 28 + (NAMESPACE.len()+1).next_multiple_of(4) as u16;
|
||||
let output: u32 = 0;
|
||||
@@ -19,15 +23,21 @@ impl WlClient {
|
||||
request.write_u16(&OPCODE, &mut offset);
|
||||
request.write_u16(&msg_size, &mut offset);
|
||||
|
||||
self.current_id += 1;
|
||||
request.write_u32(&self.current_id, &mut offset);
|
||||
self.layer_surface_id = Some(self.current_id);
|
||||
request.write_u32(&self.surface_id.unwrap(), &mut offset);
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
request.write_u32(¤t_id, &mut offset);
|
||||
|
||||
let surface_id = self.surface_id.load(Ordering::Relaxed);
|
||||
if surface_id == 0 {
|
||||
return Err(UnsetErr("surface_id".to_string()).into());
|
||||
}
|
||||
|
||||
request.write_u32(&surface_id, &mut offset);
|
||||
request.write_u32(&output, &mut offset);
|
||||
request.write_u32(&OVERLAY, &mut offset);
|
||||
request.write_string(&NAMESPACE.to_string(), &mut offset);
|
||||
|
||||
self.socket.write(&request)?;
|
||||
self.layer_surface_id.store(current_id, Ordering::Relaxed);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -41,7 +51,10 @@ impl WlClient {
|
||||
// TODO: Resize based on configure
|
||||
|
||||
// Ack configure
|
||||
let object = self.layer_surface_id.unwrap();
|
||||
let object = self.layer_surface_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("layer_surface_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 6;
|
||||
const MSG_SIZE: u16 = 12;
|
||||
|
||||
@@ -63,7 +76,10 @@ impl WlClient {
|
||||
}
|
||||
|
||||
pub fn layer_surface_set_size(&mut self, width: u32, height: u32) -> Result<(), Box<dyn Error>> {
|
||||
let object: u32 = self.layer_surface_id.unwrap();
|
||||
let object: u32 = self.layer_surface_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("layer_surface_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 0;
|
||||
const MSG_SIZE: u16 = 20;
|
||||
|
||||
@@ -83,7 +99,10 @@ impl WlClient {
|
||||
}
|
||||
|
||||
pub fn layer_surface_set_keyboard_interactivity(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
let object: u32 = self.layer_surface_id.unwrap();
|
||||
let object: u32 = self.layer_surface_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("layer_surface_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 4;
|
||||
const MSG_SIZE: u16 = 12;
|
||||
|
||||
|
||||
@@ -87,3 +87,6 @@ impl Drop for ShmPool {
|
||||
unsafe { munmap(self.addr, self.size); }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for ShmPool {}
|
||||
unsafe impl Sync for ShmPool {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{error::Error, io::Write};
|
||||
use std::{error::Error, io::Write, sync::atomic::Ordering};
|
||||
|
||||
use crate::wayland::{vec_utils::WlMessage, wl_client::WlClient};
|
||||
|
||||
@@ -16,11 +16,10 @@ impl fmt::Display for UnsetErr {
|
||||
|
||||
impl WlClient {
|
||||
pub fn wl_compositor_create_surface(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
if self.compositor_id.is_none() {
|
||||
let object = self.compositor_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("compositor_id".to_string()).into());
|
||||
}
|
||||
|
||||
let object = self.compositor_id.unwrap();
|
||||
const OPCODE: u16 = 0;
|
||||
const MSG_SIZE: u16 = 12;
|
||||
|
||||
@@ -31,24 +30,27 @@ impl WlClient {
|
||||
request.write_u16(&OPCODE, &mut offset);
|
||||
request.write_u16(&MSG_SIZE, &mut offset);
|
||||
|
||||
self.current_id += 1;
|
||||
request.write_u32(&self.current_id, &mut offset);
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
request.write_u32(¤t_id, &mut offset);
|
||||
|
||||
self.socket.write(&request)?;
|
||||
|
||||
self.surface_id = Some(self.current_id);
|
||||
self.surface_id.store(current_id, Ordering::Relaxed);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn wl_surface_attach(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
if self.surface_id.is_none() {
|
||||
return Err(Box::new(UnsetErr("surface_id".to_string())));
|
||||
let object = self.surface_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("surface_id".to_string()).into());
|
||||
}
|
||||
let object = self.surface_id.unwrap();
|
||||
const OPCODE: u16 = 1;
|
||||
const MSG_SIZE: u16 = 20;
|
||||
let buffer = self.buffer_id.unwrap();
|
||||
let buffer = self.buffer_id.load(Ordering::Relaxed);
|
||||
if buffer == 0 {
|
||||
return Err(UnsetErr("buffer_id".to_string()).into());
|
||||
}
|
||||
const X: u32 = 0;
|
||||
const Y: u32 = 0;
|
||||
|
||||
@@ -68,7 +70,10 @@ impl WlClient {
|
||||
}
|
||||
|
||||
pub fn wl_surface_commit(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
let object = self.surface_id.unwrap();
|
||||
let object = self.surface_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("surface_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 6;
|
||||
const MSG_SIZE: u16 = 8;
|
||||
|
||||
@@ -85,10 +90,10 @@ impl WlClient {
|
||||
}
|
||||
|
||||
pub fn xdg_wm_base_pong(&mut self, event: &Vec<u8>) -> Result<(), Box<dyn Error>> {
|
||||
if self.xdg_wm_base_id.is_none() {
|
||||
return Err(Box::new(UnsetErr("xdg_wm_base_id".to_string())));
|
||||
let object = self.xdg_wm_base_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("xdg_wm_base_id".to_string()).into());
|
||||
}
|
||||
let object = self.xdg_wm_base_id.unwrap();
|
||||
const OPCODE: u16 = 3;
|
||||
const MSG_SIZE: u16 = 12;
|
||||
let serial = u32::from_ne_bytes(event[0..4].try_into().unwrap());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{env::var, error::Error, fmt::Debug, io::Read, os::unix::net::UnixStream, u32};
|
||||
use std::{env::var, error::Error, fmt::Debug, io::Read, os::unix::net::UnixStream, sync::{atomic::{AtomicU32, Ordering}, Arc, Mutex}, thread, u32};
|
||||
|
||||
use crate::wayland::shm;
|
||||
|
||||
@@ -10,16 +10,16 @@ struct WlHeader {
|
||||
|
||||
pub struct WlClient {
|
||||
pub socket: UnixStream,
|
||||
pub current_id: u32,
|
||||
pub registry_id: Option<u32>,
|
||||
pub shm_id: Option<u32>,
|
||||
pub shm_pool: Option<shm::ShmPool>,
|
||||
pub buffer_id: Option<u32>,
|
||||
pub compositor_id: Option<u32>,
|
||||
pub surface_id: Option<u32>,
|
||||
pub xdg_wm_base_id: Option<u32>,
|
||||
pub layer_shell_id: Option<u32>,
|
||||
pub layer_surface_id: Option<u32>,
|
||||
pub current_id: AtomicU32,
|
||||
pub registry_id: AtomicU32,
|
||||
pub shm_id: AtomicU32,
|
||||
pub shm_pool: Arc<Mutex<Option<shm::ShmPool>>>,
|
||||
pub buffer_id: AtomicU32,
|
||||
pub compositor_id: AtomicU32,
|
||||
pub surface_id: AtomicU32,
|
||||
pub xdg_wm_base_id: AtomicU32,
|
||||
pub layer_shell_id: AtomicU32,
|
||||
pub layer_surface_id: AtomicU32,
|
||||
}
|
||||
|
||||
impl WlClient {
|
||||
@@ -30,21 +30,35 @@ impl WlClient {
|
||||
var("WAYLAND_DISPLAY")?
|
||||
))?;
|
||||
|
||||
let res = WlClient {
|
||||
let mut wl_client = WlClient {
|
||||
socket: sock,
|
||||
current_id: 1,
|
||||
registry_id: None,
|
||||
shm_id: None,
|
||||
shm_pool: None,
|
||||
buffer_id: None,
|
||||
compositor_id: None,
|
||||
surface_id: None,
|
||||
xdg_wm_base_id: None,
|
||||
layer_shell_id: None,
|
||||
layer_surface_id: None,
|
||||
current_id: AtomicU32::from(1),
|
||||
registry_id: AtomicU32::from(0),
|
||||
shm_id: AtomicU32::from(0),
|
||||
shm_pool: Arc::new(Mutex::new(None)),
|
||||
buffer_id: AtomicU32::from(0),
|
||||
compositor_id: AtomicU32::from(0),
|
||||
surface_id: AtomicU32::from(0),
|
||||
xdg_wm_base_id: AtomicU32::from(0),
|
||||
layer_shell_id: AtomicU32::from(0),
|
||||
layer_surface_id: AtomicU32::from(0),
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
let shm_pool = wl_client.shm_pool.clone();
|
||||
thread::spawn(move || {
|
||||
}).join();
|
||||
|
||||
wl_client.wl_display_get_registry()?;
|
||||
|
||||
loop {
|
||||
wl_client.read_event()?;
|
||||
|
||||
if false {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Ok(wl_client)
|
||||
}
|
||||
|
||||
pub fn read_event(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
@@ -62,27 +76,26 @@ impl WlClient {
|
||||
let mut event = vec![0u8; header.size as usize - 8];
|
||||
self.socket.read_exact(&mut event)?;
|
||||
|
||||
if header.object == self.registry_id.unwrap() && header.opcode == 0 { // wl_registry::global
|
||||
if header.object == self.registry_id.load(Ordering::Relaxed) && header.opcode == 0 { // wl_registry::global
|
||||
self.wl_registry_global(&event)?;
|
||||
}
|
||||
else if header.object == 1 && header.opcode == 0 { // wl_display::error
|
||||
else if header.object == self.registry_id.load(Ordering::Relaxed) && header.opcode == 0 { // wl_display::error
|
||||
WlClient::wl_display_error(&event);
|
||||
}
|
||||
else if self.shm_id.is_some() && header.object == self.shm_id.unwrap() && header.opcode == 0 { // wl_shm::format
|
||||
else if header.object == self.shm_id.load(Ordering::Relaxed) && header.opcode == 0 { // wl_shm::format
|
||||
WlClient::wl_shm_format(&event);
|
||||
}
|
||||
else if self.xdg_wm_base_id.is_some() && header.object == self.xdg_wm_base_id.unwrap() && header.opcode == 0 { // xdg_wm_base::ping
|
||||
else if header.object == self.xdg_wm_base_id.load(Ordering::Relaxed) && header.opcode == 0 { // xdg_wm_base::ping
|
||||
self.xdg_wm_base_pong(&event)?;
|
||||
}
|
||||
else if Some(header.object) == self.layer_surface_id && header.opcode == 0 { // zwlr_layer_surface::configure
|
||||
else if header.object == self.layer_surface_id.load(Ordering::Relaxed) && header.opcode == 0 { // zwlr_layer_surface::configure
|
||||
self.layer_surface_configure(&event)?;
|
||||
}
|
||||
else if Some(header.object) == self.surface_id && header.opcode == 2 { // wl_surface::preferred_buffer_scale
|
||||
else if header.object == self.surface_id.load(Ordering::Relaxed) && header.opcode == 2 { // wl_surface::preferred_buffer_scale
|
||||
println!("Preferred buffer scale: {}", i32::from_ne_bytes(event[0..4].try_into().unwrap()));
|
||||
}
|
||||
else if Some(header.object) == self.surface_id && header.opcode == 3 { // wl_surface::preferred_buffer_transform
|
||||
else if header.object == self.surface_id.load(Ordering::Relaxed) && header.opcode == 3 { // wl_surface::preferred_buffer_transform
|
||||
println!("Preferred buffer transform: {}", i32::from_ne_bytes(event[0..4].try_into().unwrap()));
|
||||
dbg!(self);
|
||||
}
|
||||
else {
|
||||
println!(
|
||||
@@ -96,30 +109,3 @@ impl WlClient {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for WlClient {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f,
|
||||
"WlClient {{
|
||||
current_id: {},
|
||||
registry_id: {},
|
||||
shm_id: {},
|
||||
buffer_id: {},
|
||||
compositor_id: {},
|
||||
surface_id: {},
|
||||
xdg_wm_base_id: {},
|
||||
layer_shell_id: {},
|
||||
layer_surface_id: {},
|
||||
}}",
|
||||
self.current_id,
|
||||
self.registry_id.unwrap_or(0),
|
||||
self.shm_id.unwrap_or(0),
|
||||
self.buffer_id.unwrap_or(0),
|
||||
self.compositor_id.unwrap_or(0),
|
||||
self.surface_id.unwrap_or(0),
|
||||
self.xdg_wm_base_id.unwrap_or(0),
|
||||
self.layer_shell_id.unwrap_or(0),
|
||||
self.layer_surface_id.unwrap_or(0),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
use crate::wayland::{surface::UnsetErr, vec_utils::WlMessage, wl_client::WlClient};
|
||||
use std::{io::Write, error::Error};
|
||||
use std::{error::Error, io::Write, sync::atomic::{AtomicU32, Ordering}};
|
||||
|
||||
impl WlClient {
|
||||
fn init_toplevel(&mut self) -> Result<(), Box<dyn Error>> {
|
||||
if self.shm_id.is_none() {
|
||||
if self.shm_id.load(Ordering::Relaxed) == 0 {
|
||||
return Err(Box::new(UnsetErr("shm_id".to_string())));
|
||||
}
|
||||
if self.compositor_id.is_none() {
|
||||
if self.compositor_id.load(Ordering::Relaxed) == 0 {
|
||||
return Err(Box::new(UnsetErr("compositor_id".to_string())));
|
||||
}
|
||||
if self.xdg_wm_base_id.is_none() {
|
||||
if self.xdg_wm_base_id.load(Ordering::Relaxed) == 0 {
|
||||
return Err(Box::new(UnsetErr("xdg_wm_base_id".to_string())));
|
||||
}
|
||||
if self.layer_shell_id.is_none() {
|
||||
if self.layer_shell_id.load(Ordering::Relaxed) == 0 {
|
||||
return Err(UnsetErr("layer_shell_id".to_string()).into());
|
||||
}
|
||||
println!("Initializing toplevel!");
|
||||
@@ -41,12 +41,11 @@ impl WlClient {
|
||||
request.write_u16(&OPCODE, &mut offset);
|
||||
request.write_u16(&MSG_SIZE, &mut offset);
|
||||
|
||||
self.current_id += 1;
|
||||
request.write_u32(&self.current_id, &mut offset);
|
||||
self.registry_id = Some(self.current_id);
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
request.write_u32(¤t_id, &mut offset);
|
||||
|
||||
let written = self.socket.write(&request)?;
|
||||
assert!(written == MSG_SIZE.into());
|
||||
self.socket.write(&request)?;
|
||||
self.registry_id.store(current_id, Ordering::Relaxed);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -68,50 +67,50 @@ impl WlClient {
|
||||
// TODO: Collapse these into one line (probably using a macro)
|
||||
|
||||
if interface == "wl_shm" {
|
||||
self.current_id += 1;
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
self.wl_registry_bind(
|
||||
&name,
|
||||
&interface,
|
||||
&version,
|
||||
&self.current_id.clone()
|
||||
¤t_id
|
||||
)?;
|
||||
self.shm_id = Some(self.current_id);
|
||||
self.shm_id.store(current_id, Ordering::Relaxed);
|
||||
self.init_toplevel().unwrap_or_else(|err| {eprintln!("{}", err)});
|
||||
}
|
||||
|
||||
if interface == "wl_compositor" {
|
||||
self.current_id += 1;
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
self.wl_registry_bind(
|
||||
&name,
|
||||
&interface,
|
||||
&version,
|
||||
&self.current_id.clone()
|
||||
¤t_id
|
||||
)?;
|
||||
self.compositor_id = Some(self.current_id);
|
||||
self.compositor_id.store(current_id, Ordering::Relaxed);
|
||||
self.init_toplevel().unwrap_or_else(|err| {eprintln!("{}", err)});
|
||||
}
|
||||
|
||||
if interface == "xdg_wm_base" {
|
||||
self.current_id += 1;
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
self.wl_registry_bind(
|
||||
&name,
|
||||
&interface,
|
||||
&version,
|
||||
&self.current_id.clone()
|
||||
¤t_id
|
||||
)?;
|
||||
self.xdg_wm_base_id = Some(self.current_id);
|
||||
self.xdg_wm_base_id.store(current_id, Ordering::Relaxed);
|
||||
self.init_toplevel().unwrap_or_else(|err| {eprintln!("{}", err)});
|
||||
}
|
||||
|
||||
if interface == "zwlr_layer_shell_v1" {
|
||||
self.current_id += 1;
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
self.wl_registry_bind(
|
||||
&name,
|
||||
&interface,
|
||||
&version,
|
||||
&self.current_id.clone()
|
||||
¤t_id
|
||||
)?;
|
||||
self.layer_shell_id = Some(self.current_id);
|
||||
self.layer_shell_id.store(current_id, Ordering::Relaxed);
|
||||
self.init_toplevel().unwrap_or_else(|err| {eprintln!("{}", err)});
|
||||
}
|
||||
|
||||
@@ -124,11 +123,11 @@ impl WlClient {
|
||||
interface: &String,
|
||||
version: &u32,
|
||||
id: &u32
|
||||
) -> Result<(), String> {
|
||||
let object: u32 = match self.registry_id {
|
||||
Some(id) => id,
|
||||
None => return Err(String::from("wl_registry_bind failed: wl_state.registry_id not set!"))
|
||||
};
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let object: u32 = self.registry_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("registry_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 0;
|
||||
|
||||
let req_size: u16 = 24 + ((interface.len() as u16+3) & (u16::MAX-3));
|
||||
@@ -144,14 +143,7 @@ impl WlClient {
|
||||
request.write_u32 (&version, &mut offset);
|
||||
request.write_u32 (&id, &mut offset);
|
||||
|
||||
match self.socket.write(&request) {
|
||||
Ok(bytes) => {
|
||||
assert!(bytes == req_size as usize)
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(err.to_string());
|
||||
}
|
||||
};
|
||||
self.socket.write(&request)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{error::Error, io::Write, os::unix::net::SocketAncillary, u8};
|
||||
use std::{error::Error, io::Write, os::unix::net::SocketAncillary, sync::atomic::Ordering, u8};
|
||||
use crate::wayland::{shm, surface::UnsetErr, vec_utils::WlMessage, wl_client::WlClient};
|
||||
|
||||
const STRIDE: usize = 4;
|
||||
@@ -10,19 +10,23 @@ 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, self.current_id)?);
|
||||
self.shm_pool.as_mut().unwrap().write(&vec![0xffff0000; width * height], 0);
|
||||
self.shm_pool.as_mut().unwrap().rectangle(50, 50, 50, 50, 0xff00ff00);
|
||||
self.shm_pool.as_mut().unwrap().circle(300, 300, 200, 0xff0000ff);
|
||||
self.shm_pool.as_mut().unwrap().rounded_rectangle(450, 400, 60, 40, 16, 0xffffff00);
|
||||
let mut shm_pool = self.shm_pool.lock().unwrap();
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
*shm_pool = Some(shm::ShmPool::new(width, height, current_id)?);
|
||||
shm_pool.as_mut().unwrap().write(&vec![0xffff0000; width * height], 0);
|
||||
shm_pool.as_mut().unwrap().rectangle(50, 50, 50, 50, 0xff00ff00);
|
||||
shm_pool.as_mut().unwrap().circle(300, 300, 200, 0xff0000ff);
|
||||
shm_pool.as_mut().unwrap().rounded_rectangle(450, 400, 60, 40, 16, 0xffffff00);
|
||||
|
||||
let object = self.shm_id.ok_or(UnsetErr("shm_id".to_string()))?;
|
||||
let object = self.shm_id.load(Ordering::Relaxed);
|
||||
if object == 0 {
|
||||
return Err(UnsetErr("shm_id".to_string()).into());
|
||||
}
|
||||
const OPCODE: u16 = 0;
|
||||
const REQ_SIZE: u16 = 16;
|
||||
let id = self.shm_pool.as_ref().unwrap().id;
|
||||
let fds = [self.shm_pool.as_ref().unwrap().fd];
|
||||
let shm_size = self.shm_pool.as_ref().unwrap().size;
|
||||
let id = shm_pool.as_ref().unwrap().id;
|
||||
let fds = [shm_pool.as_ref().unwrap().fd];
|
||||
let shm_size = shm_pool.as_ref().unwrap().size;
|
||||
|
||||
let mut request = vec![0u8; REQ_SIZE as usize];
|
||||
let mut offset: usize = 0;
|
||||
@@ -57,13 +61,13 @@ impl WlClient {
|
||||
width: u32,
|
||||
height: u32
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let object: u32 = self.shm_pool.as_ref().unwrap().id;
|
||||
let object: u32 = self.shm_pool.lock().unwrap().as_ref().unwrap().id;
|
||||
const REQ_SIZE: u16 = 32;
|
||||
const OPCODE: u16 = 0;
|
||||
|
||||
let stride: u32 = width * 4;
|
||||
self.current_id += 1;
|
||||
let id = self.current_id;
|
||||
let current_id = self.current_id.fetch_add(1, Ordering::Relaxed) + 1;
|
||||
let id = current_id;
|
||||
let format = 0;
|
||||
|
||||
let mut offset: usize = 0;
|
||||
@@ -82,7 +86,7 @@ impl WlClient {
|
||||
|
||||
self.socket.write(&request)?;
|
||||
|
||||
self.buffer_id = Some(self.current_id);
|
||||
self.buffer_id.store(current_id, Ordering::Relaxed);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user