From 56290d5547f0f4b24044010918573b90f299c151 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sun, 22 Feb 2026 00:14:19 +0100 Subject: [PATCH] wl_usr: refactor interfaces --- src/portal/ptl_display.rs | 51 ++++++++++--------- .../ptl_remote_desktop/remote_desktop_gui.rs | 3 +- src/portal/ptl_screencast/screencast_gui.rs | 5 +- src/portal/ptr_gui.rs | 25 +++++---- src/wl_usr.rs | 29 +++++++++-- .../usr_ifs/usr_jay_select_workspace.rs | 9 ++-- src/wl_usr/usr_ifs/usr_jay_workspace.rs | 5 +- .../usr_ifs/usr_jay_workspace_watcher.rs | 5 +- src/wl_usr/usr_ifs/usr_wl_callback.rs | 30 +++++++---- src/wl_usr/usr_ifs/usr_wl_pointer.rs | 16 +++--- src/wl_usr/usr_ifs/usr_wl_registry.rs | 15 +++--- src/wl_usr/usr_ifs/usr_wl_surface.rs | 10 ++-- 12 files changed, 121 insertions(+), 82 deletions(-) diff --git a/src/portal/ptl_display.rs b/src/portal/ptl_display.rs index a0223a40..d85bc4ae 100644 --- a/src/portal/ptl_display.rs +++ b/src/portal/ptl_display.rs @@ -2,6 +2,7 @@ use { crate::{ gfx_api::{GfxApi, GfxFormat, cross_intersect_formats}, gfx_apis::create_gfx_context, + globals::GlobalName, ifs::wl_seat::POINTER, object::Version, portal::{ @@ -60,7 +61,7 @@ struct PortalDisplayPrelude { con: Rc, state: Rc, registry: Rc, - globals: RefCell>>, + globals: RefCell>>, } shared_ids!(PortalDisplayId); @@ -80,8 +81,8 @@ pub struct PortalDisplay { pub vp: Rc, pub render_ctx: CloneCell>>, - pub outputs: CopyHashMap>, - pub seats: CopyHashMap>, + pub outputs: CopyHashMap>, + pub seats: CopyHashMap>, pub workspaces: CopyHashMap>, pub windows: CopyHashMap>, @@ -89,14 +90,14 @@ pub struct PortalDisplay { } pub struct PortalOutput { - pub global_id: u32, + pub global_id: GlobalName, pub dpy: Rc, pub wl: Rc, pub jay: Rc, } pub struct PortalSeat { - pub global_id: u32, + pub global_id: GlobalName, pub dpy: Rc, pub wl: Rc, pub jay_pointer: Rc, @@ -128,32 +129,32 @@ impl UsrWlSeatOwner for PortalSeat { } impl UsrWlPointerOwner for PortalSeat { - fn enter(&self, ev: &wl_pointer::Enter) { + fn enter(self: Rc, ev: &wl_pointer::Enter) { if let Some(window) = self.dpy.windows.get(&ev.surface) { self.pointer_focus.set(Some(window.clone())); - window.motion(self, ev.surface_x, ev.surface_y, true); + window.motion(&self, ev.surface_x, ev.surface_y, true); } } - fn leave(&self, _ev: &wl_pointer::Leave) { + fn leave(self: Rc, _ev: &wl_pointer::Leave) { self.pointer_focus.take(); } - fn motion(&self, ev: &wl_pointer::Motion) { + fn motion(self: Rc, ev: &wl_pointer::Motion) { if let Some(window) = self.pointer_focus.get() { - window.motion(self, ev.surface_x, ev.surface_y, false); + window.motion(&self, ev.surface_x, ev.surface_y, false); } } - fn button(&self, ev: &wl_pointer::Button) { + fn button(self: Rc, ev: &wl_pointer::Button) { if let Some(window) = self.pointer_focus.get() { - window.button(self, ev.button, ev.state); + window.button(&self, ev.button, ev.state); } } } impl UsrWlRegistryOwner for PortalDisplayPrelude { - fn global(self: Rc, name: u32, interface: &str, version: u32) { + fn global(self: Rc, name: GlobalName, interface: &str, version: u32) { self.globals .borrow_mut() .entry(interface.to_string()) @@ -237,7 +238,7 @@ impl UsrConOwner for PortalDisplay { } impl UsrWlRegistryOwner for PortalDisplay { - fn global(self: Rc, name: u32, interface: &str, version: u32) { + fn global(self: Rc, name: GlobalName, interface: &str, version: u32) { if interface == WlOutput.name() { add_output(&self, name, version); } else if interface == WlSeat.name() { @@ -250,7 +251,7 @@ impl UsrWlRegistryOwner for PortalDisplay { version: Version(version.min(5)), }); self.con.add_object(ls.clone()); - self.registry.request_bind(name, ls.version.0, ls.deref()); + self.registry.bind(name, ls.deref()); self.dmabuf.set(Some(ls)); } } @@ -353,7 +354,7 @@ fn finish_display_connect(dpy: Rc) { version: Version(version.min(12)), }); dpy.con.add_object(jc.clone()); - dpy.registry.request_bind(name, jc.version.0, jc.deref()); + dpy.registry.bind(name, jc.deref()); jc_opt = Some(jc); } else if interface == WpFractionalScaleManagerV1.name() { let ls = Rc::new(UsrWpFractionalScaleManager { @@ -362,7 +363,7 @@ fn finish_display_connect(dpy: Rc) { version: Version(version.min(1)), }); dpy.con.add_object(ls.clone()); - dpy.registry.request_bind(name, ls.version.0, ls.deref()); + dpy.registry.bind(name, ls.deref()); fsm_opt = Some(ls); } else if interface == ZwlrLayerShellV1.name() { let ls = Rc::new(UsrWlrLayerShell { @@ -371,7 +372,7 @@ fn finish_display_connect(dpy: Rc) { version: Version(version.min(5)), }); dpy.con.add_object(ls.clone()); - dpy.registry.request_bind(name, ls.version.0, ls.deref()); + dpy.registry.bind(name, ls.deref()); ls_opt = Some(ls); } else if interface == WpViewporter.name() { let ls = Rc::new(UsrWpViewporter { @@ -380,7 +381,7 @@ fn finish_display_connect(dpy: Rc) { version: Version(version.min(1)), }); dpy.con.add_object(ls.clone()); - dpy.registry.request_bind(name, ls.version.0, ls.deref()); + dpy.registry.bind(name, ls.deref()); vp_opt = Some(ls); } else if interface == WlCompositor.name() { let ls = Rc::new(UsrWlCompositor { @@ -389,7 +390,7 @@ fn finish_display_connect(dpy: Rc) { version: Version(version.min(6)), }); dpy.con.add_object(ls.clone()); - dpy.registry.request_bind(name, ls.version.0, ls.deref()); + dpy.registry.bind(name, ls.deref()); comp_opt = Some(ls); } else if interface == ZwpLinuxDmabufV1.name() { let ls = Rc::new(UsrLinuxDmabuf { @@ -399,7 +400,7 @@ fn finish_display_connect(dpy: Rc) { version: Version(version.min(5)), }); dpy.con.add_object(ls.clone()); - dpy.registry.request_bind(name, ls.version.0, ls.deref()); + dpy.registry.bind(name, ls.deref()); dmabuf_opt = Some(ls); } else if interface == WlOutput.name() { outputs.push((name, version)); @@ -465,7 +466,7 @@ fn finish_display_connect(dpy: Rc) { log::info!("Display {} initialized", dpy.id); } -fn add_seat(dpy: &Rc, name: u32, version: u32) { +fn add_seat(dpy: &Rc, name: GlobalName, version: u32) { let wl = Rc::new(UsrWlSeat { id: dpy.con.id(), con: dpy.con.clone(), @@ -473,7 +474,7 @@ fn add_seat(dpy: &Rc, name: u32, version: u32) { version: Version(version.min(9)), }); dpy.con.add_object(wl.clone()); - dpy.registry.request_bind(name, wl.version.0, wl.deref()); + dpy.registry.bind(name, wl.deref()); let jay_pointer = dpy.jc.get_pointer(&wl); let js = Rc::new(PortalSeat { global_id: name, @@ -489,7 +490,7 @@ fn add_seat(dpy: &Rc, name: u32, version: u32) { dpy.seats.set(name, js); } -fn add_output(dpy: &Rc, name: u32, version: u32) { +fn add_output(dpy: &Rc, name: GlobalName, version: u32) { let wl = Rc::new(UsrWlOutput { id: dpy.con.id(), con: dpy.con.clone(), @@ -498,7 +499,7 @@ fn add_output(dpy: &Rc, name: u32, version: u32) { name: Default::default(), }); dpy.con.add_object(wl.clone()); - dpy.registry.request_bind(name, wl.version.0, wl.deref()); + dpy.registry.bind(name, wl.deref()); let jo = dpy.jc.get_output(&wl); let po = Rc::new(PortalOutput { global_id: name, diff --git a/src/portal/ptl_remote_desktop/remote_desktop_gui.rs b/src/portal/ptl_remote_desktop/remote_desktop_gui.rs index 0da1db0e..f9b52189 100644 --- a/src/portal/ptl_remote_desktop/remote_desktop_gui.rs +++ b/src/portal/ptl_remote_desktop/remote_desktop_gui.rs @@ -1,5 +1,6 @@ use { crate::{ + globals::GlobalName, ifs::wl_seat::{BTN_LEFT, wl_pointer::PRESSED}, portal::{ ptl_display::{PortalDisplay, PortalOutput, PortalSeat}, @@ -21,7 +22,7 @@ const V_MARGIN: f32 = 20.0; pub struct SelectionGui { remote_desktop_session: Rc, dpy: Rc, - surfaces: CopyHashMap>, + surfaces: CopyHashMap>, } pub struct SelectionGuiSurface { diff --git a/src/portal/ptl_screencast/screencast_gui.rs b/src/portal/ptl_screencast/screencast_gui.rs index 20ae0dff..d792f233 100644 --- a/src/portal/ptl_screencast/screencast_gui.rs +++ b/src/portal/ptl_screencast/screencast_gui.rs @@ -1,5 +1,6 @@ use { crate::{ + globals::GlobalName, ifs::wl_seat::{BTN_LEFT, wl_pointer::PRESSED}, portal::{ ptl_display::{PortalDisplay, PortalOutput, PortalSeat}, @@ -29,7 +30,7 @@ const V_MARGIN: f32 = 20.0; pub struct SelectionGui { screencast_session: Rc, dpy: Rc, - surfaces: CopyHashMap>, + surfaces: CopyHashMap>, } pub struct SelectionGuiSurface { @@ -254,7 +255,7 @@ impl UsrJaySelectToplevelOwner for SelectingWindowScreencast { } impl UsrJaySelectWorkspaceOwner for SelectingWorkspaceScreencast { - fn done(&self, output: u32, ws: Option>) { + fn done(&self, output: GlobalName, ws: Option>) { let Some(ws) = ws else { log::info!("User has aborted the selection"); self.core.session.kill(); diff --git a/src/portal/ptr_gui.rs b/src/portal/ptr_gui.rs index 7f01fc4e..4962bca8 100644 --- a/src/portal/ptr_gui.rs +++ b/src/portal/ptr_gui.rs @@ -10,6 +10,7 @@ use { AcquireSync, AlphaMode, GfxContext, GfxFramebuffer, GfxTexture, ReleaseSync, needs_render_usage, }, + globals::GlobalName, ifs::zwlr_layer_shell_v1::OVERLAY, portal::{ ptl_display::{PortalDisplay, PortalOutput, PortalSeat}, @@ -29,6 +30,7 @@ use { wl_usr::usr_ifs::{ usr_linux_buffer_params::{UsrLinuxBufferParams, UsrLinuxBufferParamsOwner}, usr_wl_buffer::{UsrWlBuffer, UsrWlBufferOwner}, + usr_wl_callback::UsrWlCallbackOwner, usr_wl_surface::UsrWlSurface, usr_wlr_layer_surface::{UsrWlrLayerSurface, UsrWlrLayerSurfaceOwner}, usr_wp_fractional_scale::{UsrWpFractionalScale, UsrWpFractionalScaleOwner}, @@ -116,7 +118,7 @@ pub struct Button { pub data: GuiElementData, pub tex_off_x: Cell, pub tex_off_y: Cell, - pub hover: RefCell>, + pub hover: RefCell>, pub padding: Cell, pub border: Cell, pub border_color: Cell, @@ -504,7 +506,7 @@ pub struct WindowData { pub width: Cell, pub height: Cell, pub owner: CloneCell>>, - pub seats: CopyHashMap>, + pub seats: CopyHashMap>, } #[derive(Default)] @@ -666,15 +668,7 @@ impl WindowData { self.frame_missed.set(false); - self.surface.frame({ - let slf = self.clone(); - move || { - slf.have_frame.set(true); - if slf.frame_missed.get() { - slf.schedule_render(); - } - } - }); + self.surface.frame().owner.set(Some(self.clone())); self.have_frame.set(false); buf.free.set(false); @@ -901,6 +895,15 @@ impl UsrWpFractionalScaleOwner for WindowData { } } +impl UsrWlCallbackOwner for WindowData { + fn done(self: Rc) { + self.have_frame.set(true); + if self.frame_missed.get() { + self.schedule_render(); + } + } +} + impl UsrWlrLayerSurfaceOwner for OverlayWindow { fn configure(&self, _ev: &Configure) { self.data.schedule_render(); diff --git a/src/wl_usr.rs b/src/wl_usr.rs index 35f76b93..dcaa79bf 100644 --- a/src/wl_usr.rs +++ b/src/wl_usr.rs @@ -40,7 +40,7 @@ use { rc::Rc, }, thiserror::Error, - uapi::c, + uapi::{OwnedFd, c}, }; #[derive(Debug, Error)] @@ -119,6 +119,24 @@ impl UsrCon { if let Err(e) = ring.connect(&socket, &addr).await { return Err(UsrConError::Connect(e)); } + Ok(Self::from_socket( + ring, + wheel, + eng, + dma_buf_ids, + &socket, + server_id, + )) + } + + pub fn from_socket( + ring: &Rc, + wheel: &Rc, + eng: &Rc, + dma_buf_ids: &Rc, + socket: &Rc, + server_id: u32, + ) -> Rc { let mut obj_ids = Bitfield::default(); obj_ids.take(0); obj_ids.take(1); @@ -150,7 +168,7 @@ impl UsrCon { "wl_usr incoming", Incoming { con: slf.clone(), - buf: BufFdIn::new(&socket, &slf.ring), + buf: BufFdIn::new(socket, &slf.ring), data: vec![], } .run(), @@ -161,13 +179,13 @@ impl UsrCon { "wl_usr outgoing", Outgoing { con: slf.clone(), - buf: BufFdOut::new(&socket, &slf.ring), + buf: BufFdOut::new(socket, &slf.ring), buffers: Default::default(), } .run(), ), )); - Ok(slf) + slf } pub fn kill(&self) { @@ -224,7 +242,8 @@ impl UsrCon { where F: FnOnce() + 'static, { - let callback = Rc::new(UsrWlCallback::new(self, handler)); + let callback = Rc::new(UsrWlCallback::new(self)); + callback.owner.set(Some(Rc::new(Cell::new(Some(handler))))); self.request(wl_display::Sync { self_id: WL_DISPLAY_ID, callback: callback.id, diff --git a/src/wl_usr/usr_ifs/usr_jay_select_workspace.rs b/src/wl_usr/usr_ifs/usr_jay_select_workspace.rs index f7ea6fa8..03592c4c 100644 --- a/src/wl_usr/usr_ifs/usr_jay_select_workspace.rs +++ b/src/wl_usr/usr_ifs/usr_jay_select_workspace.rs @@ -1,5 +1,6 @@ use { crate::{ + globals::GlobalName, object::Version, utils::clonecell::CloneCell, wire::{JaySelectWorkspaceId, jay_select_workspace::*}, @@ -9,7 +10,7 @@ use { usr_object::UsrObject, }, }, - std::{convert::Infallible, rc::Rc}, + std::{cell::Cell, convert::Infallible, rc::Rc}, }; pub struct UsrJaySelectWorkspace { @@ -20,7 +21,7 @@ pub struct UsrJaySelectWorkspace { } pub trait UsrJaySelectWorkspaceOwner { - fn done(&self, output: u32, ws: Option>); + fn done(&self, output: GlobalName, ws: Option>); } impl JaySelectWorkspaceEventHandler for UsrJaySelectWorkspace { @@ -28,7 +29,7 @@ impl JaySelectWorkspaceEventHandler for UsrJaySelectWorkspace { fn cancelled(&self, _ev: Cancelled, _slf: &Rc) -> Result<(), Self::Error> { if let Some(owner) = self.owner.get() { - owner.done(0, None); + owner.done(GlobalName::from_raw(0), None); } self.con.remove_obj(self); Ok(()) @@ -41,7 +42,7 @@ impl JaySelectWorkspaceEventHandler for UsrJaySelectWorkspace { owner: Default::default(), version: self.version, linear_id: Default::default(), - output: Default::default(), + output: Cell::new(GlobalName::from_raw(0)), name: Default::default(), }); self.con.add_object(tl.clone()); diff --git a/src/wl_usr/usr_ifs/usr_jay_workspace.rs b/src/wl_usr/usr_ifs/usr_jay_workspace.rs index d1f3ca7b..dfaf0562 100644 --- a/src/wl_usr/usr_ifs/usr_jay_workspace.rs +++ b/src/wl_usr/usr_ifs/usr_jay_workspace.rs @@ -1,5 +1,6 @@ use { crate::{ + globals::GlobalName, object::Version, utils::clonecell::CloneCell, wire::{JayWorkspaceId, jay_workspace::*}, @@ -18,7 +19,7 @@ pub struct UsrJayWorkspace { pub owner: CloneCell>>, pub version: Version, pub linear_id: Cell, - pub output: Cell, + pub output: Cell, pub name: RefCell>, } @@ -68,7 +69,7 @@ impl JayWorkspaceEventHandler for UsrJayWorkspace { } fn output(&self, ev: Output, _slf: &Rc) -> Result<(), Self::Error> { - self.output.set(ev.global_name); + self.output.set(GlobalName::from_raw(ev.global_name)); if let Some(owner) = self.owner.get() { owner.output(&ev); } diff --git a/src/wl_usr/usr_ifs/usr_jay_workspace_watcher.rs b/src/wl_usr/usr_ifs/usr_jay_workspace_watcher.rs index 186a4579..62036874 100644 --- a/src/wl_usr/usr_ifs/usr_jay_workspace_watcher.rs +++ b/src/wl_usr/usr_ifs/usr_jay_workspace_watcher.rs @@ -1,11 +1,12 @@ use { crate::{ + globals::GlobalName, object::Version, utils::clonecell::CloneCell, wire::{JayWorkspaceWatcherId, jay_workspace_watcher::*}, wl_usr::{UsrCon, usr_ifs::usr_jay_workspace::UsrJayWorkspace, usr_object::UsrObject}, }, - std::{convert::Infallible, ops::Deref, rc::Rc}, + std::{cell::Cell, convert::Infallible, ops::Deref, rc::Rc}, }; pub struct UsrJayWorkspaceWatcher { @@ -32,7 +33,7 @@ impl JayWorkspaceWatcherEventHandler for UsrJayWorkspaceWatcher { owner: Default::default(), version: self.version, linear_id: Default::default(), - output: Default::default(), + output: Cell::new(GlobalName::from_raw(0)), name: Default::default(), }); self.con.add_object(jw.clone()); diff --git a/src/wl_usr/usr_ifs/usr_wl_callback.rs b/src/wl_usr/usr_ifs/usr_wl_callback.rs index eaa4e5fd..2afba91b 100644 --- a/src/wl_usr/usr_ifs/usr_wl_callback.rs +++ b/src/wl_usr/usr_ifs/usr_wl_callback.rs @@ -10,19 +10,31 @@ use { pub struct UsrWlCallback { pub id: WlCallbackId, pub con: Rc, - pub handler: Cell>>, + pub owner: Cell>>, pub version: Version, } +pub trait UsrWlCallbackOwner { + fn done(self: Rc); +} + +impl UsrWlCallbackOwner for Cell> +where + T: FnOnce() + 'static, +{ + fn done(self: Rc) { + if let Some(slf) = self.take() { + slf(); + } + } +} + impl UsrWlCallback { - pub fn new(con: &Rc, handler: F) -> Self - where - F: FnOnce() + 'static, - { + pub fn new(con: &Rc) -> Self { Self { id: con.id(), con: con.clone(), - handler: Cell::new(Some(Box::new(handler))), + owner: Default::default(), version: Version(1), } } @@ -32,8 +44,8 @@ impl WlCallbackEventHandler for UsrWlCallback { type Error = Infallible; fn done(&self, _ev: Done, _slf: &Rc) -> Result<(), Self::Error> { - if let Some(handler) = self.handler.take() { - handler(); + if let Some(handler) = self.owner.take() { + handler.done(); } self.con.remove_obj(self); Ok(()) @@ -51,6 +63,6 @@ impl UsrObject for UsrWlCallback { } fn break_loops(&self) { - self.handler.take(); + self.owner.take(); } } diff --git a/src/wl_usr/usr_ifs/usr_wl_pointer.rs b/src/wl_usr/usr_ifs/usr_wl_pointer.rs index d4220d97..c8dcf486 100644 --- a/src/wl_usr/usr_ifs/usr_wl_pointer.rs +++ b/src/wl_usr/usr_ifs/usr_wl_pointer.rs @@ -3,7 +3,7 @@ use { ifs::wl_seat::wl_pointer::PendingScroll, object::Version, utils::clonecell::CloneCell, - wire::{WlPointerId, wl_pointer::*}, + wire::{WlPointerId, WlSurfaceId, wl_pointer::*}, wl_usr::{UsrCon, usr_ifs::usr_wl_surface::UsrWlSurface, usr_object::UsrObject}, }, std::{cell::Cell, convert::Infallible, rc::Rc}, @@ -19,34 +19,34 @@ pub struct UsrWlPointer { } pub trait UsrWlPointerOwner { - fn enter(&self, ev: &Enter) { + fn enter(self: Rc, ev: &Enter) { let _ = ev; } - fn leave(&self, ev: &Leave) { + fn leave(self: Rc, ev: &Leave) { let _ = ev; } - fn motion(&self, ev: &Motion) { + fn motion(self: Rc, ev: &Motion) { let _ = ev; } - fn button(&self, ev: &Button) { + fn button(self: Rc, ev: &Button) { let _ = ev; } - fn scroll(&self, ps: &PendingScroll) { + fn scroll(self: Rc, ps: &PendingScroll) { let _ = ps; } } impl UsrWlPointer { #[expect(dead_code)] - pub fn set_cursor(&self, serial: u32, cursor: &UsrWlSurface, hot_x: i32, hot_y: i32) { + pub fn set_cursor(&self, serial: u32, cursor: Option<&UsrWlSurface>, hot_x: i32, hot_y: i32) { self.con.request(SetCursor { self_id: self.id, serial, - surface: cursor.id, + surface: cursor.map(|c| c.id).unwrap_or(WlSurfaceId::NONE), hotspot_x: hot_x, hotspot_y: hot_y, }); diff --git a/src/wl_usr/usr_ifs/usr_wl_registry.rs b/src/wl_usr/usr_ifs/usr_wl_registry.rs index 223800c6..b7d9585b 100644 --- a/src/wl_usr/usr_ifs/usr_wl_registry.rs +++ b/src/wl_usr/usr_ifs/usr_wl_registry.rs @@ -1,5 +1,6 @@ use { crate::{ + globals::GlobalName, object::Version, utils::clonecell::CloneCell, wire::{WlRegistryId, wl_registry::*}, @@ -16,24 +17,24 @@ pub struct UsrWlRegistry { } pub trait UsrWlRegistryOwner { - fn global(self: Rc, name: u32, interface: &str, version: u32) { + fn global(self: Rc, name: GlobalName, interface: &str, version: u32) { let _ = name; let _ = interface; let _ = version; } - fn global_remove(&self, name: u32) { + fn global_remove(&self, name: GlobalName) { let _ = name; } } impl UsrWlRegistry { - pub fn request_bind(&self, name: u32, version: u32, obj: &dyn UsrObject) { + pub fn bind(&self, name: GlobalName, obj: &dyn UsrObject) { self.con.request(Bind { self_id: self.id, - name, + name: name.raw(), interface: obj.interface().name(), - version, + version: obj.version().0, id: obj.id(), }); } @@ -44,14 +45,14 @@ impl WlRegistryEventHandler for UsrWlRegistry { fn global(&self, ev: Global<'_>, _slf: &Rc) -> Result<(), Self::Error> { if let Some(owner) = self.owner.get() { - owner.global(ev.name, ev.interface, ev.version); + owner.global(GlobalName::from_raw(ev.name), ev.interface, ev.version); } Ok(()) } fn global_remove(&self, ev: GlobalRemove, _slf: &Rc) -> Result<(), Self::Error> { if let Some(owner) = self.owner.get() { - owner.global_remove(ev.name); + owner.global_remove(GlobalName::from_raw(ev.name)); } Ok(()) } diff --git a/src/wl_usr/usr_ifs/usr_wl_surface.rs b/src/wl_usr/usr_ifs/usr_wl_surface.rs index 070bc298..397c0cd7 100644 --- a/src/wl_usr/usr_ifs/usr_wl_surface.rs +++ b/src/wl_usr/usr_ifs/usr_wl_surface.rs @@ -37,16 +37,14 @@ impl UsrWlSurface { }); } - pub fn frame(&self, f: F) - where - F: FnOnce() + 'static, - { - let cb = Rc::new(UsrWlCallback::new(&self.con, f)); + pub fn frame(&self) -> Rc { + let cb = Rc::new(UsrWlCallback::new(&self.con)); self.con.request(Frame { self_id: self.id, callback: cb.id, }); - self.con.add_object(cb); + self.con.add_object(cb.clone()); + cb } pub fn commit(&self) {