Skip to content

Commit

Permalink
Remove function from shared API
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduerr committed Jun 3, 2024
1 parent 7fbfbcf commit 0670351
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
20 changes: 0 additions & 20 deletions wayland-backend/src/client_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use std::{
#[cfg(doc)]
use std::io::ErrorKind::WouldBlock;

use wayland_sys::client::wl_proxy;

use crate::protocol::{Interface, Message, ObjectInfo};

use super::client_impl;
Expand Down Expand Up @@ -288,24 +286,6 @@ impl Backend {
pub fn dispatch_inner_queue(&self) -> Result<usize, WaylandError> {
self.backend.dispatch_inner_queue()
}

/// Take over handling for a proxy created by a third party.
///
/// Returns `None` on the Rust backend.
///
/// # Safety
///
/// There must never be more than one party managing an object. This is only
/// safe to call when a third party is transferring ownership of the proxy.
#[inline]
pub unsafe fn manage_object(
&self,
interface: &'static Interface,
proxy: *mut wl_proxy,
data: Option<Arc<dyn ObjectData>>,
) -> Option<ObjectId> {
unsafe { self.backend.manage_object(interface, proxy, data) }
}
}

/// Guard for synchronizing event reading across multiple threads
Expand Down
11 changes: 0 additions & 11 deletions wayland-backend/src/rs/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::{
},
};
use smallvec::SmallVec;
use wayland_sys::client::wl_proxy;

use super::{
client::*,
Expand Down Expand Up @@ -511,16 +510,6 @@ impl InnerBackend {
pub fn dispatch_inner_queue(&self) -> Result<usize, WaylandError> {
Ok(0)
}

// Importing external objects is only possible with the system backend.
pub unsafe fn manage_object(
&self,
_interface: &'static Interface,
_proxy: *mut wl_proxy,
_data: Option<Arc<dyn ObjectData>>,
) -> Option<ObjectId> {
None
}
}

impl ProtocolState {
Expand Down
6 changes: 3 additions & 3 deletions wayland-backend/src/sys/client_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ impl InnerBackend {
// initialize the proxy
let child_id = if let Some((child_interface, _)) = child_spec {
drop(guard);
unsafe { self.manage_object(&child_interface, ret, data).unwrap() }
unsafe { self.manage_object(&child_interface, ret, data) }
} else {
Self::null_id()
};
Expand Down Expand Up @@ -775,7 +775,7 @@ impl InnerBackend {
interface: &'static Interface,
proxy: *mut wl_proxy,
data: Option<Arc<dyn ObjectData>>,
) -> Option<ObjectId> {
) -> ObjectId {
let mut guard = self.lock_state();

let alive = Arc::new(AtomicBool::new(true));
Expand Down Expand Up @@ -813,7 +813,7 @@ impl InnerBackend {
);
}

Some(object_id)
object_id
}
}

Expand Down
23 changes: 22 additions & 1 deletion wayland-backend/src/sys/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
//! Implementations of the Wayland backends using the system `libwayland`

use crate::protocol::ArgumentType;
use std::sync::Arc;

use wayland_sys::client::wl_proxy;
use wayland_sys::common::{wl_argument, wl_array};

use crate::client::{ObjectData, ObjectId};
use crate::protocol::{ArgumentType, Interface};

#[cfg(any(test, feature = "client_system"))]
mod client_impl;
#[cfg(any(test, feature = "server_system"))]
Expand Down Expand Up @@ -90,6 +95,22 @@ impl client::Backend {
pub fn display_ptr(&self) -> *mut wayland_sys::client::wl_display {
self.backend.display_ptr()
}

/// Take over handling for a proxy created by a third party.
///
/// # Safety
///
/// There must never be more than one party managing an object. This is only
/// safe to call when a third party is transferring ownership of the proxy.
#[inline]
pub unsafe fn manage_object(
&self,
interface: &'static Interface,
proxy: *mut wl_proxy,
data: Option<Arc<dyn ObjectData>>,
) -> ObjectId {
unsafe { self.backend.manage_object(interface, proxy, data) }
}
}

// SAFETY:
Expand Down

0 comments on commit 0670351

Please sign in to comment.