Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Removed InternalLayerSurfaceState
Browse files Browse the repository at this point in the history
  • Loading branch information
Timidger committed Jun 8, 2018
1 parent 959e9cc commit 3c5c5a4
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/types/shell/layer_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ use errors::{HandleErr, HandleResult};

use {SurfaceHandle, OutputHandle};

/// Used to reconstruct `LayerSurfaceHandle`s from raw pointers.
struct InternalLayerSurfaceState {
handle: Weak<Cell<bool>>
}

#[derive(Debug)]
pub struct LayerSurface {
liveliness: Rc<Cell<bool>>,
Expand Down Expand Up @@ -117,8 +112,6 @@ impl LayerSurface {
panic!("Layer surface had a null output")
}
let liveliness = Rc::new(Cell::new(false));
let state = Box::new(InternalLayerSurfaceState { handle: Rc::downgrade(&liveliness) });
(*layer_surface).data = Box::into_raw(state) as *mut _;
LayerSurface { liveliness,
layer_surface }
}
Expand Down Expand Up @@ -282,9 +275,6 @@ impl Drop for LayerSurface {
fn drop(&mut self) {
if Rc::strong_count(&self.liveliness) == 1 {
wlr_log!(L_DEBUG, "Dropped Layer Shell Surface {:p}", self.layer_surface);
unsafe {
let _ = Box::from_raw((*self.layer_surface).data as *mut InternalLayerSurfaceState);
}
let weak_count = Rc::weak_count(&self.liveliness);
if weak_count > 0 {
wlr_log!(L_DEBUG,
Expand All @@ -308,17 +298,6 @@ impl LayerSurfaceHandle {
}
}

/// Creates a LayerSurfaceHandle from the raw pointer, using the saved
/// user data to recreate the memory model.
pub(crate) unsafe fn from_ptr(layer_surface: *mut wlr_layer_surface) -> Self {
let data = (*layer_surface).data as *mut InternalLayerSurfaceState;
if data.is_null() {
panic!("Layer surface has not been setup properly!");
}
let handle = (*data).handle.clone();
LayerSurfaceHandle { handle, layer_surface }
}

/// Upgrades the wayland shell handle to a reference to the backing `LayerSurface`.
///
/// # Unsafety
Expand Down

0 comments on commit 3c5c5a4

Please sign in to comment.