1
0
Fork 0
forked from wry/wry

all: use trait upcasting

This commit is contained in:
Julian Orth 2025-04-03 16:47:24 +02:00
parent f0caafc862
commit 09e5f89174
44 changed files with 90 additions and 269 deletions

View file

@ -39,13 +39,11 @@ linear_ids!(ConnectorIds, ConnectorId);
linear_ids!(InputDeviceIds, InputDeviceId); linear_ids!(InputDeviceIds, InputDeviceId);
linear_ids!(DrmDeviceIds, DrmDeviceId); linear_ids!(DrmDeviceIds, DrmDeviceId);
pub trait Backend { pub trait Backend: Any {
fn run(self: Rc<Self>) -> SpawnedFuture<Result<(), Box<dyn Error>>>; fn run(self: Rc<Self>) -> SpawnedFuture<Result<(), Box<dyn Error>>>;
fn clear(&self) { fn clear(&self) {
// nothing // nothing
} }
#[cfg_attr(not(feature = "it"), expect(dead_code))]
fn into_any(self: Rc<Self>) -> Rc<dyn Any>;
fn switch_to(&self, vtnr: u32) { fn switch_to(&self, vtnr: u32) {
let _ = vtnr; let _ = vtnr;

View file

@ -6,7 +6,7 @@ use {
}, },
video::drm::ConnectorType, video::drm::ConnectorType,
}, },
std::{any::Any, error::Error, rc::Rc}, std::{error::Error, rc::Rc},
}; };
pub struct DummyBackend; pub struct DummyBackend;
@ -15,10 +15,6 @@ impl Backend for DummyBackend {
fn run(self: Rc<Self>) -> SpawnedFuture<Result<(), Box<dyn Error>>> { fn run(self: Rc<Self>) -> SpawnedFuture<Result<(), Box<dyn Error>>> {
unreachable!(); unreachable!();
} }
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
} }
pub struct DummyOutput { pub struct DummyOutput {

View file

@ -52,7 +52,6 @@ use {
}, },
bstr::ByteSlice, bstr::ByteSlice,
std::{ std::{
any::Any,
cell::{Cell, RefCell}, cell::{Cell, RefCell},
error::Error, error::Error,
ffi::{CStr, CString}, ffi::{CStr, CString},
@ -233,10 +232,6 @@ impl Backend for MetalBackend {
} }
} }
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
fn switch_to(&self, vtnr: u32) { fn switch_to(&self, vtnr: u32) {
self.session.switch_to(vtnr, move |res| { self.session.switch_to(vtnr, move |res| {
if let Err(e) = res { if let Err(e) = res {

View file

@ -52,7 +52,6 @@ use {
}, },
jay_config::video::GfxApi, jay_config::video::GfxApi,
std::{ std::{
any::Any,
borrow::Cow, borrow::Cow,
cell::{Cell, RefCell}, cell::{Cell, RefCell},
collections::VecDeque, collections::VecDeque,
@ -251,10 +250,6 @@ impl Backend for XBackend {
Ok(()) Ok(())
}) })
} }
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
} }
pub struct XBackend { pub struct XBackend {

View file

@ -45,15 +45,13 @@ pub trait CpuWork: Send {
} }
} }
pub trait AsyncCpuWork { pub trait AsyncCpuWork: Any {
fn run( fn run(
self: Box<Self>, self: Box<Self>,
eng: &Rc<AsyncEngine>, eng: &Rc<AsyncEngine>,
ring: &Rc<IoUring>, ring: &Rc<IoUring>,
completion: WorkCompletion, completion: WorkCompletion,
) -> SpawnedFuture<CompletedWork>; ) -> SpawnedFuture<CompletedWork>;
fn into_any(self: Box<Self>) -> Box<dyn Any>;
} }
pub struct WorkCompletion { pub struct WorkCompletion {

View file

@ -89,7 +89,7 @@ impl CpuWork for ReadWriteWork {
} }
fn async_work_done(&mut self, work: Box<dyn AsyncCpuWork>) { fn async_work_done(&mut self, work: Box<dyn AsyncCpuWork>) {
let work = work.into_any().downcast().unwrap(); let work = (work as Box<dyn Any>).downcast().unwrap();
self.config = Some(work); self.config = Some(work);
} }
} }
@ -144,8 +144,4 @@ impl AsyncCpuWork for ReadWriteWorkConfig {
completion.complete(self) completion.complete(self)
}) })
} }
fn into_any(self: Box<Self>) -> Box<dyn Any> {
self
}
} }

View file

@ -71,10 +71,6 @@ impl AsyncCpuWork for AsyncWork {
completion.complete(self) completion.complete(self)
}) })
} }
fn into_any(self: Box<Self>) -> Box<dyn Any> {
self
}
} }
fn run(cancel: bool) { fn run(cancel: bool) {

View file

@ -335,8 +335,7 @@ impl CursorImageScaled {
extents: Rect::new_sized(-xhot, -yhot, width, height).unwrap(), extents: Rect::new_sized(-xhot, -yhot, width, height).unwrap(),
tex: ctx tex: ctx
.clone() .clone()
.shmem_texture(None, data, ARGB8888, width, height, width * 4, None)? .shmem_texture(None, data, ARGB8888, width, height, width * 4, None)?,
.into_texture(),
})) }))
} }
} }

View file

@ -292,9 +292,7 @@ pub enum ResetStatus {
Other(u32), Other(u32),
} }
pub trait GfxBlendBuffer: Debug { pub trait GfxBlendBuffer: Any + Debug {}
fn into_any(self: Rc<Self>) -> Rc<dyn Any>;
}
pub trait GfxFramebuffer: Debug { pub trait GfxFramebuffer: Debug {
fn physical_size(&self) -> (i32, i32); fn physical_size(&self) -> (i32, i32);
@ -321,7 +319,6 @@ pub trait GfxFramebuffer: Debug {
} }
pub trait GfxInternalFramebuffer: GfxFramebuffer { pub trait GfxInternalFramebuffer: GfxFramebuffer {
fn into_fb(self: Rc<Self>) -> Rc<dyn GfxFramebuffer>;
fn stride(&self) -> i32; fn stride(&self) -> i32;
fn staging_size(&self) -> usize; fn staging_size(&self) -> usize;
@ -645,17 +642,13 @@ pub trait GfxImage {
fn height(&self) -> i32; fn height(&self) -> i32;
} }
pub trait GfxTexture: Debug { pub trait GfxTexture: Any + Debug {
fn size(&self) -> (i32, i32); fn size(&self) -> (i32, i32);
fn as_any(&self) -> &dyn Any;
fn into_any(self: Rc<Self>) -> Rc<dyn Any>;
fn dmabuf(&self) -> Option<&DmaBuf>; fn dmabuf(&self) -> Option<&DmaBuf>;
fn format(&self) -> &'static Format; fn format(&self) -> &'static Format;
} }
pub trait ShmGfxTexture: GfxTexture { pub trait ShmGfxTexture: GfxTexture {}
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture>;
}
pub trait AsyncShmGfxTextureCallback { pub trait AsyncShmGfxTextureCallback {
fn completed(self: Rc<Self>, res: Result<(), GfxError>); fn completed(self: Rc<Self>, res: Result<(), GfxError>);
@ -667,9 +660,8 @@ bitflags! {
STAGING_DOWNLOAD = 1 << 1, STAGING_DOWNLOAD = 1 << 1,
} }
pub trait GfxStagingBuffer { pub trait GfxStagingBuffer: Any {
fn size(&self) -> usize; fn size(&self) -> usize;
fn into_any(self: Rc<Self>) -> Rc<dyn Any>;
} }
pub trait AsyncShmGfxTextureTransferCancellable { pub trait AsyncShmGfxTextureTransferCancellable {
@ -729,8 +721,6 @@ pub trait AsyncShmGfxTexture: GfxTexture {
height: i32, height: i32,
stride: i32, stride: i32,
) -> bool; ) -> bool;
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture>;
} }
pub trait GfxContext: Debug { pub trait GfxContext: Debug {
@ -792,10 +782,6 @@ pub trait GfxContext: Debug {
fn size(&self) -> usize { fn size(&self) -> usize {
self.0 self.0
} }
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
} }
Rc::new(Dummy(size)) Rc::new(Dummy(size))
} }

View file

@ -95,7 +95,7 @@ use {
}, },
isnt::std_1::vec::IsntVecExt, isnt::std_1::vec::IsntVecExt,
once_cell::sync::Lazy, once_cell::sync::Lazy,
std::{cell::RefCell, error::Error, rc::Rc, sync::Arc}, std::{any::Any, cell::RefCell, error::Error, rc::Rc, sync::Arc},
thiserror::Error, thiserror::Error,
}; };
@ -439,7 +439,7 @@ fn handle_explicit_sync(ctx: &GlRenderContext, img: Option<&Rc<EglImage>>, sync:
impl dyn GfxTexture { impl dyn GfxTexture {
fn as_gl(&self) -> &Texture { fn as_gl(&self) -> &Texture {
self.as_any() (self as &dyn Any)
.downcast_ref() .downcast_ref()
.expect("Non-gl texture passed into gl") .expect("Non-gl texture passed into gl")
} }

View file

@ -127,10 +127,6 @@ impl GfxFramebuffer for Framebuffer {
} }
impl GfxInternalFramebuffer for Framebuffer { impl GfxInternalFramebuffer for Framebuffer {
fn into_fb(self: Rc<Self>) -> Rc<dyn GfxFramebuffer> {
self
}
fn stride(&self) -> i32 { fn stride(&self) -> i32 {
self.gl.rb.stride self.gl.rb.stride
} }

View file

@ -18,7 +18,6 @@ use {
video::dmabuf::DmaBuf, video::dmabuf::DmaBuf,
}, },
std::{ std::{
any::Any,
cell::Cell, cell::Cell,
fmt::{Debug, Formatter}, fmt::{Debug, Formatter},
rc::Rc, rc::Rc,
@ -52,14 +51,6 @@ impl GfxTexture for Texture {
(self.width(), self.height()) (self.width(), self.height())
} }
fn as_any(&self) -> &dyn Any {
self
}
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
fn dmabuf(&self) -> Option<&DmaBuf> { fn dmabuf(&self) -> Option<&DmaBuf> {
self.gl.img.as_ref().map(|i| &i.dmabuf) self.gl.img.as_ref().map(|i| &i.dmabuf)
} }
@ -69,11 +60,7 @@ impl GfxTexture for Texture {
} }
} }
impl ShmGfxTexture for Texture { impl ShmGfxTexture for Texture {}
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
}
impl AsyncShmGfxTexture for Texture { impl AsyncShmGfxTexture for Texture {
fn async_upload( fn async_upload(
@ -136,8 +123,4 @@ impl AsyncShmGfxTexture for Texture {
&& height == self.gl.height && height == self.gl.height
&& stride == self.gl.stride && stride == self.gl.stride
} }
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
} }

View file

@ -28,7 +28,7 @@ use {
format::Format, format::Format,
gfx_api::{ gfx_api::{
AsyncShmGfxTexture, GfxBlendBuffer, GfxContext, GfxError, GfxFormat, GfxImage, AsyncShmGfxTexture, GfxBlendBuffer, GfxContext, GfxError, GfxFormat, GfxImage,
GfxInternalFramebuffer, GfxStagingBuffer, ResetStatus, STAGING_DOWNLOAD, GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture, ResetStatus, STAGING_DOWNLOAD,
STAGING_UPLOAD, ShmGfxTexture, StagingBufferUsecase, STAGING_UPLOAD, ShmGfxTexture, StagingBufferUsecase,
}, },
gfx_apis::vulkan::{ gfx_apis::vulkan::{
@ -272,7 +272,7 @@ impl GfxContext for Context {
damage: Option<&[Rect]>, damage: Option<&[Rect]>,
) -> Result<Rc<dyn ShmGfxTexture>, GfxError> { ) -> Result<Rc<dyn ShmGfxTexture>, GfxError> {
if let Some(old) = old { if let Some(old) = old {
let old = old.into_texture().into_vk(&self.0.device.device); let old = (old as Rc<dyn GfxTexture>).into_vk(&self.0.device.device);
let shm = match &old.ty { let shm = match &old.ty {
VulkanImageMemory::DmaBuf(_) => unreachable!(), VulkanImageMemory::DmaBuf(_) => unreachable!(),
VulkanImageMemory::Blend(_) => unreachable!(), VulkanImageMemory::Blend(_) => unreachable!(),

View file

@ -14,7 +14,7 @@ use {
ImageTiling, ImageType, ImageViewCreateInfo, ImageViewType, SampleCountFlags, SharingMode, ImageTiling, ImageType, ImageViewCreateInfo, ImageViewType, SampleCountFlags, SharingMode,
}, },
gpu_alloc::UsageFlags, gpu_alloc::UsageFlags,
std::{any::Any, cell::Cell, collections::hash_map::Entry, rc::Rc}, std::{cell::Cell, collections::hash_map::Entry, rc::Rc},
}; };
impl VulkanRenderer { impl VulkanRenderer {
@ -113,8 +113,4 @@ impl VulkanRenderer {
} }
} }
impl GfxBlendBuffer for VulkanImage { impl GfxBlendBuffer for VulkanImage {}
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
}

View file

@ -32,7 +32,6 @@ use {
}, },
gpu_alloc::UsageFlags, gpu_alloc::UsageFlags,
std::{ std::{
any::Any,
cell::Cell, cell::Cell,
fmt::{Debug, Formatter}, fmt::{Debug, Formatter},
mem, mem,
@ -591,10 +590,6 @@ impl GfxFramebuffer for VulkanImage {
} }
impl GfxInternalFramebuffer for VulkanImage { impl GfxInternalFramebuffer for VulkanImage {
fn into_fb(self: Rc<Self>) -> Rc<dyn GfxFramebuffer> {
self
}
fn stride(&self) -> i32 { fn stride(&self) -> i32 {
let VulkanImageMemory::Internal(shm) = &self.ty else { let VulkanImageMemory::Internal(shm) = &self.ty else {
unreachable!(); unreachable!();
@ -637,14 +632,6 @@ impl GfxTexture for VulkanImage {
(self.width as _, self.height as _) (self.width as _, self.height as _)
} }
fn as_any(&self) -> &dyn Any {
self
}
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
fn dmabuf(&self) -> Option<&DmaBuf> { fn dmabuf(&self) -> Option<&DmaBuf> {
match &self.ty { match &self.ty {
VulkanImageMemory::DmaBuf(b) => Some(&b.template.dmabuf), VulkanImageMemory::DmaBuf(b) => Some(&b.template.dmabuf),
@ -658,11 +645,7 @@ impl GfxTexture for VulkanImage {
} }
} }
impl ShmGfxTexture for VulkanImage { impl ShmGfxTexture for VulkanImage {}
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
}
impl AsyncShmGfxTexture for VulkanImage { impl AsyncShmGfxTexture for VulkanImage {
fn staging_size(&self) -> usize { fn staging_size(&self) -> usize {
@ -711,10 +694,6 @@ impl AsyncShmGfxTexture for VulkanImage {
&& self.height == height as u32 && self.height == height as u32
&& self.stride == stride as u32 && self.stride == stride as u32
} }
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
} }
impl AsyncShmGfxTextureTransferCancellable for VulkanImage { impl AsyncShmGfxTextureTransferCancellable for VulkanImage {

View file

@ -60,6 +60,7 @@ use {
jay_algorithms::rect::Tag, jay_algorithms::rect::Tag,
linearize::{Linearize, LinearizeExt, StaticMap, static_map}, linearize::{Linearize, LinearizeExt, StaticMap, static_map},
std::{ std::{
any::Any,
borrow::Cow, borrow::Cow,
cell::{Cell, RefCell}, cell::{Cell, RefCell},
collections::hash_map::Entry, collections::hash_map::Entry,
@ -1967,8 +1968,7 @@ impl VulkanImage {
impl dyn GfxTexture { impl dyn GfxTexture {
fn as_vk(&self, device: &Device) -> &VulkanImage { fn as_vk(&self, device: &Device) -> &VulkanImage {
let img: &VulkanImage = self let img: &VulkanImage = (self as &dyn Any)
.as_any()
.downcast_ref() .downcast_ref()
.expect("Non-vulkan texture passed into vulkan"); .expect("Non-vulkan texture passed into vulkan");
img.assert_device(device); img.assert_device(device);
@ -1976,8 +1976,7 @@ impl dyn GfxTexture {
} }
pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanImage> { pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanImage> {
let img: Rc<VulkanImage> = self let img: Rc<VulkanImage> = (self as Rc<dyn Any>)
.into_any()
.downcast() .downcast()
.expect("Non-vulkan texture passed into vulkan"); .expect("Non-vulkan texture passed into vulkan");
img.assert_device(device); img.assert_device(device);
@ -1987,8 +1986,7 @@ impl dyn GfxTexture {
impl dyn GfxBlendBuffer { impl dyn GfxBlendBuffer {
pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanImage> { pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanImage> {
let img: Rc<VulkanImage> = self let img: Rc<VulkanImage> = (self as Rc<dyn Any>)
.into_any()
.downcast() .downcast()
.expect("Non-vulkan blend buffer passed into vulkan"); .expect("Non-vulkan blend buffer passed into vulkan");
img.assert_device(device); img.assert_device(device);

View file

@ -178,10 +178,6 @@ impl GfxStagingBuffer for VulkanStagingShell {
fn size(&self) -> usize { fn size(&self) -> usize {
self.size as _ self.size as _
} }
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
} }
impl VulkanStagingShell { impl VulkanStagingShell {
@ -196,8 +192,7 @@ impl VulkanStagingShell {
impl dyn GfxStagingBuffer { impl dyn GfxStagingBuffer {
pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanStagingShell> { pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanStagingShell> {
let shell: Rc<VulkanStagingShell> = self let shell: Rc<VulkanStagingShell> = (self as Rc<dyn Any>)
.into_any()
.downcast() .downcast()
.expect("Non-vulkan staging buffer passed into vulkan"); .expect("Non-vulkan staging buffer passed into vulkan");
shell.assert_device(device); shell.assert_device(device);

View file

@ -138,11 +138,7 @@ impl ExtImageCopyCaptureFrameV1 {
Some(s) => s, Some(s) => s,
_ => ctx.create_staging_buffer(bridge.staging_size(), STAGING_DOWNLOAD), _ => ctx.create_staging_buffer(bridge.staging_size(), STAGING_DOWNLOAD),
}; };
let res = f( let res = f(bridge.clone(), AcquireSync::Unnecessary, ReleaseSync::None);
bridge.clone().into_fb(),
AcquireSync::Unnecessary,
ReleaseSync::None,
);
if let Err(e) = res { if let Err(e) = res {
log::error!("Could not copy frame to staging texture: {}", ErrorFmt(e)); log::error!("Could not copy frame to staging texture: {}", ErrorFmt(e));
return Err(FrameFailureReason::Unknown); return Err(FrameFailureReason::Unknown);

View file

@ -291,7 +291,7 @@ impl LatchListener for ExtImageCopyCaptureSessionV1 {
self.force_capture.set(true); self.force_capture.set(true);
return; return;
} }
frame.copy_node(on, tl.tl_as_node(), data.desired_pixel_size()); frame.copy_node(on, &*tl, data.desired_pixel_size());
} }
} }

View file

@ -195,7 +195,7 @@ impl JayScreencast {
AcquireSync::Implicit, AcquireSync::Implicit,
ReleaseSync::Implicit, ReleaseSync::Implicit,
self.client.state.color_manager.srgb_srgb(), self.client.state.color_manager.srgb_srgb(),
tl.tl_as_node(), &*tl,
&self.client.state, &self.client.state,
Some(tl.node_absolute_position()), Some(tl.node_absolute_position()),
scale, scale,

View file

@ -212,12 +212,9 @@ impl WlBuffer {
match &*self.storage.borrow() { match &*self.storage.borrow() {
None => None, None => None,
Some(s) => match s { Some(s) => match s {
WlBufferStorage::Shm { .. } => surface WlBufferStorage::Shm { .. } => {
.shm_textures surface.shm_textures.front().tex.get().map(|t| t as _)
.front() }
.tex
.get()
.map(|t| t.into_texture()),
WlBufferStorage::Dmabuf { tex, .. } => tex.clone(), WlBufferStorage::Dmabuf { tex, .. } => tex.clone(),
}, },
} }

View file

@ -420,8 +420,8 @@ impl WlSeatGlobal {
Some(cn) => cn, Some(cn) => cn,
_ => return, _ => return,
}; };
let kb_foci = collect_kb_foci(tl.clone().tl_into_node()); let kb_foci = collect_kb_foci(tl.clone());
cn.cnode_remove_child2(tl.tl_as_node(), true); cn.cnode_remove_child2(&*tl, true);
if !ws.visible.get() { if !ws.visible.get() {
for focus in kb_foci { for focus in kb_foci {
old_ws.clone().node_do_focus(&focus, Direction::Unspecified); old_ws.clone().node_do_focus(&focus, Direction::Unspecified);
@ -604,7 +604,7 @@ impl WlSeatGlobal {
}; };
if let Some(pn) = pn.node_into_containing_node() { if let Some(pn) = pn.node_into_containing_node() {
let cn = ContainerNode::new(&self.state, &ws, tl.clone(), axis); let cn = ContainerNode::new(&self.state, &ws, tl.clone(), axis);
pn.cnode_replace_child(tl.tl_as_node(), cn); pn.cnode_replace_child(&*tl, cn);
} }
} }
@ -612,7 +612,7 @@ impl WlSeatGlobal {
if let Some(tl) = self.keyboard_node.get().node_toplevel() { if let Some(tl) = self.keyboard_node.get().node_toplevel() {
if let Some(parent) = tl.tl_data().parent.get() { if let Some(parent) = tl.tl_data().parent.get() {
if let Some(tl) = parent.node_toplevel() { if let Some(tl) = parent.node_toplevel() {
self.focus_node(tl.tl_into_node()); self.focus_node(tl);
} }
} }
} }
@ -646,10 +646,10 @@ impl WlSeatGlobal {
_ => return, _ => return,
}; };
if !floating { if !floating {
parent.cnode_remove_child2(tl.tl_as_node(), true); parent.cnode_remove_child2(&*tl, true);
self.state.map_tiled(tl); self.state.map_tiled(tl);
} else if let Some(ws) = data.workspace.get() { } else if let Some(ws) = data.workspace.get() {
parent.cnode_remove_child2(tl.tl_as_node(), true); parent.cnode_remove_child2(&*tl, true);
let (width, height) = data.float_size(&ws); let (width, height) = data.float_size(&ws);
self.state.map_floating(tl, width, height, &ws, None); self.state.map_floating(tl, width, height, &ws, None);
} }

View file

@ -926,7 +926,7 @@ impl WlSeatGlobal {
pub fn focus_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) { pub fn focus_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
let node = match n.tl_focus_child() { let node = match n.tl_focus_child() {
Some(n) => n, Some(n) => n,
_ => n.tl_into_node(), _ => n,
}; };
self.focus_node(node); self.focus_node(node);
} }

View file

@ -1089,7 +1089,7 @@ impl WindowManagementGrabUsecase for MoveToplevelGrabPointerOwner {
) { ) {
let (x, y) = seat.pointer_cursor.position(); let (x, y) = seat.pointer_cursor.position();
let (x, y) = (x.round_down() - self.dx, y.round_down() - self.dy); let (x, y) = (x.round_down() - self.dx, y.round_down() - self.dy);
parent.cnode_set_child_position(tl.tl_as_node(), x, y); parent.cnode_set_child_position(&**tl, x, y);
} }
} }
@ -1144,7 +1144,7 @@ impl WindowManagementGrabUsecase for ResizeToplevelGrabPointerOwner {
} }
} }
if x1.is_some() || x2.is_some() || y1.is_some() || y2.is_some() { if x1.is_some() || x2.is_some() || y1.is_some() || y2.is_some() {
parent.cnode_resize_child(tl.tl_as_node(), x1, y1, x2, y2); parent.cnode_resize_child(&**tl, x1, y1, x2, y2);
} }
} }
} }
@ -1230,13 +1230,11 @@ impl UiDragUsecase for TileDragUsecase {
let placeholder = Rc::new_cyclic(|weak| PlaceholderNode::new_empty(&seat.state, weak)); let placeholder = Rc::new_cyclic(|weak| PlaceholderNode::new_empty(&seat.state, weak));
src_parent src_parent
.clone() .clone()
.cnode_replace_child(src.tl_as_node(), placeholder.clone()); .cnode_replace_child(&*src, placeholder.clone());
placeholder placeholder
}; };
let new_container = |workspace: &Rc<WorkspaceNode>| { let new_container = |workspace: &Rc<WorkspaceNode>| {
src_parent src_parent.clone().cnode_remove_child2(&*src, true);
.clone()
.cnode_remove_child2(src.tl_as_node(), true);
let cn = ContainerNode::new( let cn = ContainerNode::new(
&seat.state, &seat.state,
&workspace, &workspace,
@ -1251,8 +1249,8 @@ impl UiDragUsecase for TileDragUsecase {
return; return;
}; };
let placeholder = detach(); let placeholder = detach();
dst_parent.cnode_replace_child(dst.tl_as_node(), src); dst_parent.cnode_replace_child(&*dst, src);
src_parent.cnode_replace_child(placeholder.tl_as_node(), dst); src_parent.cnode_replace_child(&*placeholder, dst);
} }
TddType::Split { TddType::Split {
node, node,
@ -1268,12 +1266,12 @@ impl UiDragUsecase for TileDragUsecase {
}; };
let placeholder = detach(); let placeholder = detach();
let cn = ContainerNode::new(&seat.state, &ws, node.clone(), split); let cn = ContainerNode::new(&seat.state, &ws, node.clone(), split);
pn.cnode_replace_child(node.tl_as_node(), cn.clone()); pn.cnode_replace_child(&*node, cn.clone());
match before { match before {
true => cn.add_child_before(node.tl_as_node(), src), true => cn.add_child_before(&*node, src),
false => cn.add_child_after(node.tl_as_node(), src), false => cn.add_child_after(&*node, src),
} }
src_parent.cnode_remove_child(placeholder.tl_as_node()); src_parent.cnode_remove_child(&*placeholder);
} }
TddType::Insert { TddType::Insert {
container, container,
@ -1282,10 +1280,10 @@ impl UiDragUsecase for TileDragUsecase {
} => { } => {
let placeholder = detach(); let placeholder = detach();
match before { match before {
true => container.add_child_before(neighbor.tl_as_node(), src), true => container.add_child_before(&*neighbor, src),
false => container.add_child_after(neighbor.tl_as_node(), src), false => container.add_child_after(&*neighbor, src),
}; };
src_parent.cnode_remove_child(placeholder.tl_as_node()); src_parent.cnode_remove_child(&*placeholder);
} }
TddType::NewWorkspace { output } => { TddType::NewWorkspace { output } => {
new_container(&output.ensure_workspace()); new_container(&output.ensure_workspace());
@ -1294,12 +1292,12 @@ impl UiDragUsecase for TileDragUsecase {
new_container(&workspace); new_container(&workspace);
} }
TddType::MoveToWorkspace { workspace } => { TddType::MoveToWorkspace { workspace } => {
src_parent.cnode_remove_child(src.tl_as_node()); src_parent.cnode_remove_child(&*src);
seat.state.map_tiled_on(src, &workspace); seat.state.map_tiled_on(src, &workspace);
} }
TddType::MoveToNewWorkspace { output } => { TddType::MoveToNewWorkspace { output } => {
let ws = output.generate_workspace(); let ws = output.generate_workspace();
src_parent.cnode_remove_child(src.tl_as_node()); src_parent.cnode_remove_child(&*src);
seat.state.map_tiled_on(src, &ws); seat.state.map_tiled_on(src, &ws);
} }
} }

View file

@ -1656,7 +1656,7 @@ impl WlSurface {
pub fn request_activation(&self) { pub fn request_activation(&self) {
if let Some(tl) = self.toplevel.get() { if let Some(tl) = self.toplevel.get() {
tl.tl_data().request_attention(tl.tl_as_node()); tl.tl_data().request_attention(&*tl);
} }
} }

View file

@ -77,7 +77,6 @@ impl TrayItemData {
pub trait DynTrayItem: Node { pub trait DynTrayItem: Node {
fn send_current_configure(&self); fn send_current_configure(&self);
fn data(&self) -> &TrayItemData; fn data(&self) -> &TrayItemData;
fn into_node(self: Rc<Self>) -> Rc<dyn Node>;
fn set_position(&self, abs_pos: Rect, rel_pos: Rect); fn set_position(&self, abs_pos: Rect, rel_pos: Rect);
fn destroy_popups(&self); fn destroy_popups(&self);
fn destroy_node(&self); fn destroy_node(&self);
@ -93,10 +92,6 @@ impl<T: TrayItem> DynTrayItem for T {
<Self as TrayItem>::data(self) <Self as TrayItem>::data(self)
} }
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
self
}
fn set_position(&self, abs_pos: Rect, rel_pos: Rect) { fn set_position(&self, abs_pos: Rect, rel_pos: Rect) {
let data = self.data(); let data = self.data();
data.surface data.surface

View file

@ -488,8 +488,6 @@ impl ToplevelNodeBase for Xwindow {
} }
impl StackedNode for Xwindow { impl StackedNode for Xwindow {
stacked_node_impl!();
fn stacked_set_visible(&self, visible: bool) { fn stacked_set_visible(&self, visible: bool) {
self.damage_override_redirect(); self.damage_override_redirect();
self.tl_set_visible(visible); self.tl_set_visible(visible);

View file

@ -356,8 +356,6 @@ impl Node for XdgPopup {
} }
impl StackedNode for XdgPopup { impl StackedNode for XdgPopup {
stacked_node_impl!();
fn stacked_prepare_set_visible(&self) { fn stacked_prepare_set_visible(&self) {
self.set_visible_prepared.set(true); self.set_visible_prepared.set(true);
} }

View file

@ -16,7 +16,7 @@ use {
log::Level, log::Level,
parking_lot::Mutex, parking_lot::Mutex,
std::{ std::{
cell::Cell, collections::VecDeque, future::pending, pin::Pin, rc::Rc, sync::Arc, any::Any, cell::Cell, collections::VecDeque, future::pending, pin::Pin, rc::Rc, sync::Arc,
time::SystemTime, time::SystemTime,
}, },
uapi::c, uapi::c,
@ -132,7 +132,7 @@ fn run_test(it_run: &ItRun, test: &'static dyn TestCase, cfg: Rc<TestConfig>) {
sun_path[path.len()] = 0; sun_path[path.len()] = 0;
addr addr
}; };
let backend: Rc<TestBackend> = state.backend.get().into_any().downcast().unwrap(); let backend: Rc<TestBackend> = (state.backend.get() as Rc<dyn Any>).downcast().unwrap();
let testrun = Rc::new(TestRun { let testrun = Rc::new(TestRun {
state: state.clone(), state: state.clone(),
backend, backend,

View file

@ -30,7 +30,7 @@ use {
}, },
}, },
bstr::ByteSlice, bstr::ByteSlice,
std::{any::Any, cell::Cell, error::Error, io, os::unix::ffi::OsStrExt, pin::Pin, rc::Rc}, std::{cell::Cell, error::Error, io, os::unix::ffi::OsStrExt, pin::Pin, rc::Rc},
thiserror::Error, thiserror::Error,
uapi::c, uapi::c,
}; };
@ -287,10 +287,6 @@ impl Backend for TestBackend {
}) })
} }
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
fn switch_to(&self, vtnr: u32) { fn switch_to(&self, vtnr: u32) {
let _ = vtnr; let _ = vtnr;
} }

View file

@ -278,14 +278,6 @@ impl GfxTexture for TestGfxImage {
} }
} }
fn as_any(&self) -> &dyn Any {
self
}
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
fn dmabuf(&self) -> Option<&DmaBuf> { fn dmabuf(&self) -> Option<&DmaBuf> {
match self { match self {
TestGfxImage::Shm(_) => None, TestGfxImage::Shm(_) => None,
@ -298,11 +290,7 @@ impl GfxTexture for TestGfxImage {
} }
} }
impl ShmGfxTexture for TestGfxImage { impl ShmGfxTexture for TestGfxImage {}
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
}
impl AsyncShmGfxTexture for TestGfxImage { impl AsyncShmGfxTexture for TestGfxImage {
fn async_upload( fn async_upload(
@ -344,10 +332,6 @@ impl AsyncShmGfxTexture for TestGfxImage {
}; };
shm.format == format && shm.width == width && shm.height == height && shm.stride == stride shm.format == format && shm.width == width && shm.height == height && shm.stride == stride
} }
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
} }
impl GfxImage for TestGfxImage { impl GfxImage for TestGfxImage {
@ -573,10 +557,6 @@ impl GfxFramebuffer for TestGfxFb {
} }
impl GfxInternalFramebuffer for TestGfxFb { impl GfxInternalFramebuffer for TestGfxFb {
fn into_fb(self: Rc<Self>) -> Rc<dyn GfxFramebuffer> {
self
}
fn stride(&self) -> i32 { fn stride(&self) -> i32 {
let TestGfxImage::Shm(shm) = &*self.img else { let TestGfxImage::Shm(shm) = &*self.img else {
unreachable!(); unreachable!();
@ -604,7 +584,7 @@ impl GfxInternalFramebuffer for TestGfxFb {
impl dyn GfxTexture { impl dyn GfxTexture {
fn as_native(&self) -> &TestGfxImage { fn as_native(&self) -> &TestGfxImage {
self.as_any() (self as &dyn Any)
.downcast_ref() .downcast_ref()
.expect("Non-test texture passed into vulkan") .expect("Non-test texture passed into vulkan")
} }

View file

@ -1,6 +1,6 @@
use { use {
crate::{it::test_error::TestError, object::Object}, crate::{it::test_error::TestError, object::Object},
std::rc::Rc, std::{any::Any, rc::Rc},
}; };
pub trait TestObjectExt { pub trait TestObjectExt {
@ -9,7 +9,7 @@ pub trait TestObjectExt {
impl TestObjectExt for dyn Object { impl TestObjectExt for dyn Object {
fn downcast<T: 'static>(self: Rc<Self>) -> Result<Rc<T>, TestError> { fn downcast<T: 'static>(self: Rc<Self>) -> Result<Rc<T>, TestError> {
match self.into_any().downcast() { match (self as Rc<dyn Any>).downcast() {
Ok(t) => Ok(t), Ok(t) => Ok(t),
_ => bail!("Object has an incompatible type id"), _ => bail!("Object has an incompatible type id"),
} }

View file

@ -49,10 +49,6 @@ macro_rules! object_base {
$version $version
} }
fn into_any($self: std::rc::Rc<Self>) -> std::rc::Rc<dyn std::any::Any> {
$self
}
fn handle_request( fn handle_request(
$self: std::rc::Rc<Self>, $self: std::rc::Rc<Self>,
client: &crate::client::Client, client: &crate::client::Client,
@ -458,14 +454,6 @@ macro_rules! fatal {
}} }}
} }
macro_rules! stacked_node_impl {
() => {
fn stacked_into_node(self: Rc<Self>) -> Rc<dyn Node> {
self
}
};
}
macro_rules! bitflags { macro_rules! bitflags {
($name:ident: $rep:ty; $($var:ident = $val:expr,)*) => { ($name:ident: $rep:ty; $($var:ident = $val:expr,)*) => {
#[derive(Copy, Clone, Eq, PartialEq, Default)] #[derive(Copy, Clone, Eq, PartialEq, Default)]

View file

@ -36,11 +36,9 @@ impl Display for ObjectId {
} }
} }
pub trait ObjectBase { pub trait ObjectBase: Any {
fn id(&self) -> ObjectId; fn id(&self) -> ObjectId;
fn version(&self) -> Version; fn version(&self) -> Version;
#[cfg_attr(not(feature = "it"), expect(dead_code))]
fn into_any(self: Rc<Self>) -> Rc<dyn Any>;
fn handle_request( fn handle_request(
self: Rc<Self>, self: Rc<Self>,
client: &Client, client: &Client,

View file

@ -98,5 +98,5 @@ pub fn render(
None, None,
) )
.ok() .ok()
.map(|t| (t.into_texture(), measurement)) .map(|t| (t as _, measurement))
} }

View file

@ -80,7 +80,7 @@ impl Renderer<'_> {
let srgb_srgb = self.state.color_manager.srgb_srgb(); let srgb_srgb = self.state.color_manager.srgb_srgb();
let srgb = &srgb_srgb.linear; let srgb = &srgb_srgb.linear;
if let Some(fs) = fullscreen { if let Some(fs) = fullscreen {
fs.tl_as_node().node_render(self, x, y, None); fs.node_render(self, x, y, None);
} else { } else {
render_layer!(output.layers[0]); render_layer!(output.layers[0]);
render_layer!(output.layers[1]); render_layer!(output.layers[1]);

View file

@ -678,7 +678,7 @@ impl State {
.get() .get()
.and_then(|n| n.node_into_container()); .and_then(|n| n.node_into_container());
if let Some(lap) = lap { if let Some(lap) = lap {
lap.add_child_after(la.tl_as_node(), node); lap.add_child_after(&*la, node);
} else { } else {
c.append_child(node); c.append_child(node);
} }
@ -1120,7 +1120,7 @@ impl State {
acquire_sync, acquire_sync,
ReleaseSync::None, ReleaseSync::None,
src_cd, src_cd,
&fb.clone().into_fb(), &(fb.clone() as Rc<dyn GfxFramebuffer>),
AcquireSync::Unnecessary, AcquireSync::Unnecessary,
ReleaseSync::None, ReleaseSync::None,
transform, transform,

View file

@ -383,12 +383,7 @@ impl TextTexture {
} }
pub fn texture(&self) -> Option<Rc<dyn GfxTexture>> { pub fn texture(&self) -> Option<Rc<dyn GfxTexture>> {
self.data self.data.textures.front().tex.get().map(|t| t as _)
.textures
.front()
.tex
.get()
.map(|t| t.into_texture())
} }
fn apply_config(&self, on_completed: Rc<dyn OnCompleted>, config: Config<'_>) { fn apply_config(&self, on_completed: Rc<dyn OnCompleted>, config: Config<'_>) {

View file

@ -856,7 +856,7 @@ impl ContainerNode {
return; return;
} }
if !preserve_focus { if !preserve_focus {
let seats = collect_kb_foci(mc.node.clone().tl_into_node()); let seats = collect_kb_foci(mc.node.clone());
mc.node.tl_set_visible(false); mc.node.tl_set_visible(false);
for seat in seats { for seat in seats {
child child
@ -898,7 +898,7 @@ impl ContainerNode {
let mut seats = SmallVec::<[_; 3]>::new(); let mut seats = SmallVec::<[_; 3]>::new();
for other in self.children.iter() { for other in self.children.iter() {
if other.node.node_id() != child_id { if other.node.node_id() != child_id {
collect_kb_foci2(other.node.clone().tl_into_node(), &mut seats); collect_kb_foci2(other.node.clone(), &mut seats);
other.node.tl_set_visible(false); other.node.tl_set_visible(false);
} }
} }
@ -996,9 +996,7 @@ impl ContainerNode {
// CASE 1: This is the only child of the container. Replace the container by the child. // CASE 1: This is the only child of the container. Replace the container by the child.
if self.num_children.get() == 1 { if self.num_children.get() == 1 {
if let Some(parent) = self.toplevel_data.parent.get() { if let Some(parent) = self.toplevel_data.parent.get() {
if !self.toplevel_data.is_fullscreen.get() if !self.toplevel_data.is_fullscreen.get() && parent.cnode_accepts_child(&*child) {
&& parent.cnode_accepts_child(child.tl_as_node())
{
parent.cnode_replace_child(self.deref(), child.clone()); parent.cnode_replace_child(self.deref(), child.clone());
} }
} }
@ -1019,13 +1017,13 @@ impl ContainerNode {
}; };
if let Some(neighbor) = neighbor { if let Some(neighbor) = neighbor {
if let Some(cn) = neighbor.node.clone().node_into_container() { if let Some(cn) = neighbor.node.clone().node_into_container() {
if cn.cnode_accepts_child(child.tl_as_node()) { if cn.cnode_accepts_child(&*child) {
if let Some(mc) = self.mono_child.get() { if let Some(mc) = self.mono_child.get() {
if mc.node.node_id() == child.node_id() { if mc.node.node_id() == child.node_id() {
self.activate_child2(&neighbor, true); self.activate_child2(&neighbor, true);
} }
} }
self.cnode_remove_child2(child.tl_as_node(), true); self.cnode_remove_child2(&*child, true);
cn.insert_child(child, direction); cn.insert_child(child, direction);
return; return;
} }
@ -1053,7 +1051,7 @@ impl ContainerNode {
Some(p) => p, Some(p) => p,
_ => return, _ => return,
}; };
self.cnode_remove_child2(child.tl_as_node(), true); self.cnode_remove_child2(&*child, true);
match prev { match prev {
true => parent.add_child_before(&*neighbor, child.clone()), true => parent.add_child_before(&*neighbor, child.clone()),
false => parent.add_child_after(&*neighbor, child.clone()), false => parent.add_child_after(&*neighbor, child.clone()),
@ -1567,7 +1565,7 @@ impl Node for ContainerNode {
if content.contains(x, y) { if content.contains(x, y) {
let (x, y) = content.translate(x, y); let (x, y) = content.translate(x, y);
tree.push(FoundNode { tree.push(FoundNode {
node: child.node.clone().tl_into_node(), node: child.node.clone(),
x, x,
y, y,
}); });

View file

@ -614,7 +614,7 @@ impl Node for FloatNode {
let x = x - bw; let x = x - bw;
let y = y - bw - th - 1; let y = y - bw - th - 1;
tree.push(FoundNode { tree.push(FoundNode {
node: child.clone().tl_into_node(), node: child.clone(),
x, x,
y, y,
}); });
@ -833,8 +833,6 @@ impl ContainingNode for FloatNode {
} }
impl StackedNode for FloatNode { impl StackedNode for FloatNode {
stacked_node_impl!();
fn stacked_set_visible(&self, visible: bool) { fn stacked_set_visible(&self, visible: bool) {
if self.visible.replace(visible) != visible { if self.visible.replace(visible) != visible {
self.state.damage(self.position.get()); self.state.damage(self.position.get());

View file

@ -881,7 +881,7 @@ impl OutputNode {
let (x, y) = ext.translate(x_abs, y_abs); let (x, y) = ext.translate(x_abs, y_abs);
let idx = tree.len(); let idx = tree.len();
tree.push(FoundNode { tree.push(FoundNode {
node: stacked.deref().clone().stacked_into_node(), node: stacked.deref().clone(),
x, x,
y, y,
}); });
@ -1401,11 +1401,11 @@ impl Node for OutputNode {
} }
if let Some(fs) = fullscreen { if let Some(fs) = fullscreen {
tree.push(FoundNode { tree.push(FoundNode {
node: fs.clone().tl_into_node(), node: fs.clone(),
x, x,
y, y,
}); });
fs.tl_as_node().node_find_tree_at(x, y, tree, usecase) fs.node_find_tree_at(x, y, tree, usecase)
} else { } else {
let mut search_layers = true; let mut search_layers = true;
let non_exclusive_rect = self.non_exclusive_rect_rel.get(); let non_exclusive_rect = self.non_exclusive_rect_rel.get();
@ -1419,7 +1419,7 @@ impl Node for OutputNode {
if pos.contains(x, y) { if pos.contains(x, y) {
let (x, y) = pos.translate(x, y); let (x, y) = pos.translate(x, y);
tree.push(FoundNode { tree.push(FoundNode {
node: item.deref().clone().into_node(), node: item.deref().clone(),
x, x,
y, y,
}); });

View file

@ -1,7 +1,6 @@
use {crate::tree::Node, std::rc::Rc}; use crate::tree::Node;
pub trait StackedNode: Node { pub trait StackedNode: Node {
fn stacked_into_node(self: Rc<Self>) -> Rc<dyn Node>;
fn stacked_prepare_set_visible(&self) { fn stacked_prepare_set_visible(&self) {
// nothing // nothing
} }

View file

@ -40,9 +40,6 @@ use {
tree_id!(ToplevelNodeId); tree_id!(ToplevelNodeId);
pub trait ToplevelNode: ToplevelNodeBase { pub trait ToplevelNode: ToplevelNodeBase {
fn tl_as_node(&self) -> &dyn Node;
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node>;
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
fn tl_surface_active_changed(&self, active: bool); fn tl_surface_active_changed(&self, active: bool);
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool); fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool);
fn tl_title_changed(&self); fn tl_title_changed(&self);
@ -56,18 +53,6 @@ pub trait ToplevelNode: ToplevelNodeBase {
} }
impl<T: ToplevelNodeBase> ToplevelNode for T { impl<T: ToplevelNodeBase> ToplevelNode for T {
fn tl_as_node(&self) -> &dyn Node {
self
}
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node> {
self
}
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
self
}
fn tl_surface_active_changed(&self, active: bool) { fn tl_surface_active_changed(&self, active: bool) {
let data = self.tl_data(); let data = self.tl_data();
data.update_active(self, || { data.update_active(self, || {
@ -79,10 +64,10 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
let data = self.tl_data(); let data = self.tl_data();
if fullscreen { if fullscreen {
if let Some(ws) = data.workspace.get() { if let Some(ws) = data.workspace.get() {
data.set_fullscreen2(&data.state, self.clone().tl_into_dyn(), &ws); data.set_fullscreen2(&data.state, self.clone(), &ws);
} }
} else { } else {
data.unset_fullscreen(&data.state, self.clone().tl_into_dyn()); data.unset_fullscreen(&data.state, self.clone());
} }
} }
@ -323,7 +308,7 @@ impl ToplevelData {
if active_old != active_new { if active_old != active_new {
tl.tl_set_active(active_new); tl.tl_set_active(active_new);
if let Some(parent) = self.parent.get() { if let Some(parent) = self.parent.get() {
parent.node_child_active_changed(tl.tl_as_node(), active_new, 1); parent.node_child_active_changed(tl, active_new, 1);
} }
} }
} }
@ -480,14 +465,14 @@ impl ToplevelData {
} }
let placeholder = let placeholder =
Rc::new_cyclic(|weak| PlaceholderNode::new_for(state, node.clone(), weak)); Rc::new_cyclic(|weak| PlaceholderNode::new_for(state, node.clone(), weak));
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone()); parent.cnode_replace_child(&*node, placeholder.clone());
let mut kb_foci = Default::default(); let mut kb_foci = Default::default();
if ws.visible.get() { if ws.visible.get() {
if let Some(container) = ws.container.get() { if let Some(container) = ws.container.get() {
kb_foci = collect_kb_foci(container); kb_foci = collect_kb_foci(container);
} }
for stacked in ws.stacked.iter() { for stacked in ws.stacked.iter() {
collect_kb_foci2(stacked.deref().clone().stacked_into_node(), &mut kb_foci); collect_kb_foci2(stacked.deref().clone(), &mut kb_foci);
} }
} }
*data = Some(FullscreenedData { *data = Some(FullscreenedData {
@ -501,9 +486,7 @@ impl ToplevelData {
node.clone() node.clone()
.tl_change_extents(&ws.output.get().global.pos.get()); .tl_change_extents(&ws.output.get().global.pos.get());
for seat in kb_foci { for seat in kb_foci {
node.clone() node.clone().node_do_focus(&seat, Direction::Unspecified);
.tl_into_node()
.node_do_focus(&seat, Direction::Unspecified);
} }
} }
@ -527,7 +510,7 @@ impl ToplevelData {
); );
return; return;
} }
Some(f) if f.tl_as_node().node_id() != node.tl_as_node().node_id() => { Some(f) if f.node_id() != node.node_id() => {
log::error!( log::error!(
"Node is supposed to be fullscreened on a workspace but the workspace has a different node attached." "Node is supposed to be fullscreened on a workspace but the workspace has a different node attached."
); );
@ -542,12 +525,10 @@ impl ToplevelData {
} }
let parent = fd.placeholder.tl_data().parent.get().unwrap(); let parent = fd.placeholder.tl_data().parent.get().unwrap();
parent.cnode_replace_child(fd.placeholder.deref(), node.clone()); parent.cnode_replace_child(fd.placeholder.deref(), node.clone());
if node.tl_as_node().node_visible() { if node.node_visible() {
let kb_foci = collect_kb_foci(fd.placeholder.clone()); let kb_foci = collect_kb_foci(fd.placeholder.clone());
for seat in kb_foci { for seat in kb_foci {
node.clone() node.clone().node_do_focus(&seat, Direction::Unspecified);
.tl_into_node()
.node_do_focus(&seat, Direction::Unspecified);
} }
} }
fd.placeholder fd.placeholder

View file

@ -277,7 +277,7 @@ impl Node for WorkspaceNode {
visitor.visit_container(&c); visitor.visit_container(&c);
} }
if let Some(fs) = self.fullscreen.get() { if let Some(fs) = self.fullscreen.get() {
fs.tl_into_node().node_visit(visitor); fs.node_visit(visitor);
} }
} }
@ -291,7 +291,7 @@ impl Node for WorkspaceNode {
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) { fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
if let Some(fs) = self.fullscreen.get() { if let Some(fs) = self.fullscreen.get() {
fs.tl_into_node().node_do_focus(seat, direction); fs.node_do_focus(seat, direction);
} else if let Some(container) = self.container.get() { } else if let Some(container) = self.container.get() {
container.node_do_focus(seat, direction); container.node_do_focus(seat, direction);
} else if let Some(float) = self } else if let Some(float) = self
@ -359,7 +359,7 @@ impl ContainingNode for WorkspaceNode {
fn cnode_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn ToplevelNode>) { fn cnode_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn ToplevelNode>) {
if let Some(container) = self.container.get() { if let Some(container) = self.container.get() {
if container.node_id() == old.node_id() { if container.node_id() == old.node_id() {
let new = match new.tl_into_node().node_into_container() { let new = match new.node_into_container() {
Some(c) => c, Some(c) => c,
_ => { _ => {
log::error!("cnode_replace_child called with non-container new"); log::error!("cnode_replace_child called with non-container new");
@ -383,7 +383,7 @@ impl ContainingNode for WorkspaceNode {
} }
} }
if let Some(fs) = self.fullscreen.get() { if let Some(fs) = self.fullscreen.get() {
if fs.tl_as_node().node_id() == child.node_id() { if fs.node_id() == child.node_id() {
self.remove_fullscreen_node(); self.remove_fullscreen_node();
return; return;
} }