fix(wayland): manually remove objects from connection on destroy
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -100,7 +100,8 @@ impl WlBuffer for Buffer {
|
||||
type Connection = crate::wayland::Client;
|
||||
|
||||
/// https://wayland.app/protocols/wayland#wl_buffer:request:destroy
|
||||
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn destroy(&self, client: &mut Client, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
client.remove(self.id);
|
||||
tracing::info!("Destroying buffer {:?}", self.id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::surface::WL_SURFACE_REGISTRY;
|
||||
use crate::wayland::{WaylandResult, WaylandError};
|
||||
use crate::wayland::{WaylandError, WaylandResult};
|
||||
use crate::wayland::{core::surface::Surface, util::ClientExt};
|
||||
use waynest::ObjectId;
|
||||
use waynest_protocols::server::core::wayland::wl_surface::WlSurface;
|
||||
@@ -35,14 +35,16 @@ impl WlCompositor for Compositor {
|
||||
_sender_id: ObjectId,
|
||||
id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.insert(id, Region::default());
|
||||
client.insert(id, Region { id });
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, RequestDispatcher, Default)]
|
||||
#[derive(Debug, RequestDispatcher)]
|
||||
#[waynest(error = WaylandError)]
|
||||
pub struct Region {}
|
||||
pub struct Region {
|
||||
id: ObjectId,
|
||||
}
|
||||
impl WlRegion for Region {
|
||||
type Connection = crate::wayland::Client;
|
||||
|
||||
@@ -73,7 +75,12 @@ impl WlRegion for Region {
|
||||
}
|
||||
|
||||
/// https://wayland.app/protocols/wayland#wl_region:request:destroy
|
||||
async fn destroy(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn destroy(
|
||||
&self,
|
||||
client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.remove(self.id);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ impl WlDataDeviceManager for DataDeviceManager {
|
||||
_sender_id: ObjectId,
|
||||
id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.insert(id, DataSource);
|
||||
client.insert(id, DataSource { id });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ impl WlDataDeviceManager for DataDeviceManager {
|
||||
|
||||
#[derive(Debug, waynest_server::RequestDispatcher)]
|
||||
#[waynest(error = crate::wayland::WaylandError)]
|
||||
pub struct DataSource;
|
||||
pub struct DataSource {
|
||||
id: ObjectId,
|
||||
}
|
||||
impl WlDataSource for DataSource {
|
||||
type Connection = Client;
|
||||
|
||||
@@ -60,7 +62,12 @@ impl WlDataSource for DataSource {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn destroy(
|
||||
&self,
|
||||
client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.remove(self.id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -102,14 +109,20 @@ impl WlDataDevice for DataDevice {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn release(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn release(
|
||||
&self,
|
||||
_client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, waynest_server::RequestDispatcher)]
|
||||
#[waynest(error = crate::wayland::WaylandError)]
|
||||
pub struct DataOffer;
|
||||
pub struct DataOffer {
|
||||
id: ObjectId,
|
||||
}
|
||||
impl WlDataOffer for DataOffer {
|
||||
type Connection = Client;
|
||||
|
||||
@@ -133,11 +146,20 @@ impl WlDataOffer for DataOffer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn destroy(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn destroy(
|
||||
&self,
|
||||
client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.remove(self.id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn finish(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn finish(
|
||||
&self,
|
||||
_client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,11 @@ pub use waynest_protocols::server::core::wayland::wl_shm::*;
|
||||
#[waynest(error = crate::wayland::WaylandError)]
|
||||
pub struct Shm;
|
||||
impl Shm {
|
||||
pub async fn advertise_formats(&self, client: &mut Client, sender_id: ObjectId) -> WaylandResult<()> {
|
||||
pub async fn advertise_formats(
|
||||
&self,
|
||||
client: &mut Client,
|
||||
sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
self.format(client, sender_id, Format::Argb8888).await?;
|
||||
self.format(client, sender_id, Format::Xrgb8888).await?;
|
||||
|
||||
@@ -26,13 +30,17 @@ impl WlShm for Shm {
|
||||
fd: OwnedFd,
|
||||
size: i32,
|
||||
) -> WaylandResult<()> {
|
||||
client.insert(pool_id, ShmPool::new(fd, size)?);
|
||||
client.insert(pool_id, ShmPool::new(fd, size, pool_id)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// https://wayland.app/protocols/wayland#wl_shm:request:release
|
||||
async fn release(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn release(
|
||||
&self,
|
||||
_client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ pub use waynest_protocols::server::core::wayland::wl_shm_pool::*;
|
||||
#[waynest(error = crate::wayland::WaylandError)]
|
||||
pub struct ShmPool {
|
||||
inner: Mutex<memmap2::MmapMut>,
|
||||
id: ObjectId,
|
||||
}
|
||||
|
||||
impl ShmPool {
|
||||
#[tracing::instrument(level = "debug", skip_all)]
|
||||
pub fn new(fd: OwnedFd, size: i32) -> WaylandResult<Self> {
|
||||
pub fn new(fd: OwnedFd, size: i32, id: ObjectId) -> WaylandResult<Self> {
|
||||
let map = unsafe {
|
||||
MmapOptions::new()
|
||||
.len(size as usize)
|
||||
@@ -27,6 +28,7 @@ impl ShmPool {
|
||||
|
||||
Ok(Self {
|
||||
inner: Mutex::new(map),
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,7 +81,12 @@ impl WlShmPool for ShmPool {
|
||||
|
||||
/// https://wayland.app/protocols/wayland#wl_shm_pool:request:destroy
|
||||
#[tracing::instrument(level = "debug", skip_all)]
|
||||
async fn destroy(&self, _client: &mut Self::Connection, _sender_id: ObjectId) -> WaylandResult<()> {
|
||||
async fn destroy(
|
||||
&self,
|
||||
client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.remove(self.id);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,9 +490,10 @@ impl WlSurface for Surface {
|
||||
#[tracing::instrument(level = "debug", skip_all)]
|
||||
async fn destroy(
|
||||
&self,
|
||||
_client: &mut Self::Connection,
|
||||
client: &mut Self::Connection,
|
||||
_sender_id: ObjectId,
|
||||
) -> WaylandResult<()> {
|
||||
client.remove(self.id);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user