wl_usr: refactor interfaces
This commit is contained in:
parent
4b3d3a50cd
commit
56290d5547
12 changed files with 121 additions and 82 deletions
|
|
@ -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<UsrCon>,
|
||||
state: Rc<PortalState>,
|
||||
registry: Rc<UsrWlRegistry>,
|
||||
globals: RefCell<AHashMap<String, Vec<(u32, u32)>>>,
|
||||
globals: RefCell<AHashMap<String, Vec<(GlobalName, u32)>>>,
|
||||
}
|
||||
|
||||
shared_ids!(PortalDisplayId);
|
||||
|
|
@ -80,8 +81,8 @@ pub struct PortalDisplay {
|
|||
pub vp: Rc<UsrWpViewporter>,
|
||||
pub render_ctx: CloneCell<Option<Rc<PortalServerRenderCtx>>>,
|
||||
|
||||
pub outputs: CopyHashMap<u32, Rc<PortalOutput>>,
|
||||
pub seats: CopyHashMap<u32, Rc<PortalSeat>>,
|
||||
pub outputs: CopyHashMap<GlobalName, Rc<PortalOutput>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<PortalSeat>>,
|
||||
pub workspaces: CopyHashMap<u32, Rc<UsrJayWorkspace>>,
|
||||
|
||||
pub windows: CopyHashMap<WlSurfaceId, Rc<WindowData>>,
|
||||
|
|
@ -89,14 +90,14 @@ pub struct PortalDisplay {
|
|||
}
|
||||
|
||||
pub struct PortalOutput {
|
||||
pub global_id: u32,
|
||||
pub global_id: GlobalName,
|
||||
pub dpy: Rc<PortalDisplay>,
|
||||
pub wl: Rc<UsrWlOutput>,
|
||||
pub jay: Rc<UsrJayOutput>,
|
||||
}
|
||||
|
||||
pub struct PortalSeat {
|
||||
pub global_id: u32,
|
||||
pub global_id: GlobalName,
|
||||
pub dpy: Rc<PortalDisplay>,
|
||||
pub wl: Rc<UsrWlSeat>,
|
||||
pub jay_pointer: Rc<UsrJayPointer>,
|
||||
|
|
@ -128,32 +129,32 @@ impl UsrWlSeatOwner for PortalSeat {
|
|||
}
|
||||
|
||||
impl UsrWlPointerOwner for PortalSeat {
|
||||
fn enter(&self, ev: &wl_pointer::Enter) {
|
||||
fn enter(self: Rc<Self>, 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<Self>, _ev: &wl_pointer::Leave) {
|
||||
self.pointer_focus.take();
|
||||
}
|
||||
|
||||
fn motion(&self, ev: &wl_pointer::Motion) {
|
||||
fn motion(self: Rc<Self>, 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<Self>, 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<Self>, name: u32, interface: &str, version: u32) {
|
||||
fn global(self: Rc<Self>, 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<Self>, name: u32, interface: &str, version: u32) {
|
||||
fn global(self: Rc<Self>, 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<PortalDisplayPrelude>) {
|
|||
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<PortalDisplayPrelude>) {
|
|||
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<PortalDisplayPrelude>) {
|
|||
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<PortalDisplayPrelude>) {
|
|||
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<PortalDisplayPrelude>) {
|
|||
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<PortalDisplayPrelude>) {
|
|||
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<PortalDisplayPrelude>) {
|
|||
log::info!("Display {} initialized", dpy.id);
|
||||
}
|
||||
|
||||
fn add_seat(dpy: &Rc<PortalDisplay>, name: u32, version: u32) {
|
||||
fn add_seat(dpy: &Rc<PortalDisplay>, 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<PortalDisplay>, 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<PortalDisplay>, name: u32, version: u32) {
|
|||
dpy.seats.set(name, js);
|
||||
}
|
||||
|
||||
fn add_output(dpy: &Rc<PortalDisplay>, name: u32, version: u32) {
|
||||
fn add_output(dpy: &Rc<PortalDisplay>, 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<PortalDisplay>, 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,
|
||||
|
|
|
|||
|
|
@ -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<PortalSession>,
|
||||
dpy: Rc<PortalDisplay>,
|
||||
surfaces: CopyHashMap<u32, Rc<SelectionGuiSurface>>,
|
||||
surfaces: CopyHashMap<GlobalName, Rc<SelectionGuiSurface>>,
|
||||
}
|
||||
|
||||
pub struct SelectionGuiSurface {
|
||||
|
|
|
|||
|
|
@ -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<PortalSession>,
|
||||
dpy: Rc<PortalDisplay>,
|
||||
surfaces: CopyHashMap<u32, Rc<SelectionGuiSurface>>,
|
||||
surfaces: CopyHashMap<GlobalName, Rc<SelectionGuiSurface>>,
|
||||
}
|
||||
|
||||
pub struct SelectionGuiSurface {
|
||||
|
|
@ -254,7 +255,7 @@ impl UsrJaySelectToplevelOwner for SelectingWindowScreencast {
|
|||
}
|
||||
|
||||
impl UsrJaySelectWorkspaceOwner for SelectingWorkspaceScreencast {
|
||||
fn done(&self, output: u32, ws: Option<Rc<UsrJayWorkspace>>) {
|
||||
fn done(&self, output: GlobalName, ws: Option<Rc<UsrJayWorkspace>>) {
|
||||
let Some(ws) = ws else {
|
||||
log::info!("User has aborted the selection");
|
||||
self.core.session.kill();
|
||||
|
|
|
|||
|
|
@ -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<f32>,
|
||||
pub tex_off_y: Cell<f32>,
|
||||
pub hover: RefCell<AHashSet<u32>>,
|
||||
pub hover: RefCell<AHashSet<GlobalName>>,
|
||||
pub padding: Cell<f32>,
|
||||
pub border: Cell<f32>,
|
||||
pub border_color: Cell<Color>,
|
||||
|
|
@ -504,7 +506,7 @@ pub struct WindowData {
|
|||
pub width: Cell<i32>,
|
||||
pub height: Cell<i32>,
|
||||
pub owner: CloneCell<Option<Rc<dyn WindowDataOwner>>>,
|
||||
pub seats: CopyHashMap<u32, Rc<GuiWindowSeatState>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<GuiWindowSeatState>>,
|
||||
}
|
||||
|
||||
#[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>) {
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue