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

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

View file

@ -291,7 +291,7 @@ impl LatchListener for ExtImageCopyCaptureSessionV1 {
self.force_capture.set(true);
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,
ReleaseSync::Implicit,
self.client.state.color_manager.srgb_srgb(),
tl.tl_as_node(),
&*tl,
&self.client.state,
Some(tl.node_absolute_position()),
scale,

View file

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

View file

@ -420,8 +420,8 @@ impl WlSeatGlobal {
Some(cn) => cn,
_ => return,
};
let kb_foci = collect_kb_foci(tl.clone().tl_into_node());
cn.cnode_remove_child2(tl.tl_as_node(), true);
let kb_foci = collect_kb_foci(tl.clone());
cn.cnode_remove_child2(&*tl, true);
if !ws.visible.get() {
for focus in kb_foci {
old_ws.clone().node_do_focus(&focus, Direction::Unspecified);
@ -604,7 +604,7 @@ impl WlSeatGlobal {
};
if let Some(pn) = pn.node_into_containing_node() {
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(parent) = tl.tl_data().parent.get() {
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,
};
if !floating {
parent.cnode_remove_child2(tl.tl_as_node(), true);
parent.cnode_remove_child2(&*tl, true);
self.state.map_tiled(tl);
} 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);
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>) {
let node = match n.tl_focus_child() {
Some(n) => n,
_ => n.tl_into_node(),
_ => n,
};
self.focus_node(node);
}

View file

@ -1089,7 +1089,7 @@ impl WindowManagementGrabUsecase for MoveToplevelGrabPointerOwner {
) {
let (x, y) = seat.pointer_cursor.position();
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() {
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));
src_parent
.clone()
.cnode_replace_child(src.tl_as_node(), placeholder.clone());
.cnode_replace_child(&*src, placeholder.clone());
placeholder
};
let new_container = |workspace: &Rc<WorkspaceNode>| {
src_parent
.clone()
.cnode_remove_child2(src.tl_as_node(), true);
src_parent.clone().cnode_remove_child2(&*src, true);
let cn = ContainerNode::new(
&seat.state,
&workspace,
@ -1251,8 +1249,8 @@ impl UiDragUsecase for TileDragUsecase {
return;
};
let placeholder = detach();
dst_parent.cnode_replace_child(dst.tl_as_node(), src);
src_parent.cnode_replace_child(placeholder.tl_as_node(), dst);
dst_parent.cnode_replace_child(&*dst, src);
src_parent.cnode_replace_child(&*placeholder, dst);
}
TddType::Split {
node,
@ -1268,12 +1266,12 @@ impl UiDragUsecase for TileDragUsecase {
};
let placeholder = detach();
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 {
true => cn.add_child_before(node.tl_as_node(), src),
false => cn.add_child_after(node.tl_as_node(), src),
true => cn.add_child_before(&*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 {
container,
@ -1282,10 +1280,10 @@ impl UiDragUsecase for TileDragUsecase {
} => {
let placeholder = detach();
match before {
true => container.add_child_before(neighbor.tl_as_node(), src),
false => container.add_child_after(neighbor.tl_as_node(), src),
true => container.add_child_before(&*neighbor, 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 } => {
new_container(&output.ensure_workspace());
@ -1294,12 +1292,12 @@ impl UiDragUsecase for TileDragUsecase {
new_container(&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);
}
TddType::MoveToNewWorkspace { output } => {
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);
}
}

View file

@ -1656,7 +1656,7 @@ impl WlSurface {
pub fn request_activation(&self) {
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 {
fn send_current_configure(&self);
fn data(&self) -> &TrayItemData;
fn into_node(self: Rc<Self>) -> Rc<dyn Node>;
fn set_position(&self, abs_pos: Rect, rel_pos: Rect);
fn destroy_popups(&self);
fn destroy_node(&self);
@ -93,10 +92,6 @@ impl<T: TrayItem> DynTrayItem for T {
<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) {
let data = self.data();
data.surface

View file

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

View file

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