autocommit 2022-04-27 20:37:49 CEST
This commit is contained in:
parent
57899b3f35
commit
324eb835bb
24 changed files with 478 additions and 68 deletions
|
|
@ -10,8 +10,8 @@ use {
|
|||
};
|
||||
|
||||
pub struct WlCallback {
|
||||
client: Rc<Client>,
|
||||
id: WlCallbackId,
|
||||
pub client: Rc<Client>,
|
||||
pub id: WlCallbackId,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use {
|
|||
cursor::CursorSurface, wl_subsurface::WlSubsurface, xdg_surface::XdgSurfaceError,
|
||||
zwlr_layer_surface_v1::ZwlrLayerSurfaceV1Error,
|
||||
},
|
||||
wp_presentation_feedback::WpPresentationFeedback,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -97,6 +98,7 @@ pub struct WlSurface {
|
|||
pub children: RefCell<Option<Box<ParentData>>>,
|
||||
ext: CloneCell<Rc<dyn SurfaceExt>>,
|
||||
pub frame_requests: RefCell<Vec<Rc<WlCallback>>>,
|
||||
pub presentation_feedback: RefCell<Vec<Rc<WpPresentationFeedback>>>,
|
||||
seat_state: NodeSeatState,
|
||||
toplevel: CloneCell<Option<Rc<dyn ToplevelNode>>>,
|
||||
cursors: SmallMap<SeatId, Rc<CursorSurface>, 1>,
|
||||
|
|
@ -181,6 +183,7 @@ struct PendingState {
|
|||
input_region: Cell<Option<Option<Rc<Region>>>>,
|
||||
frame_request: RefCell<Vec<Rc<WlCallback>>>,
|
||||
damage: Cell<bool>,
|
||||
presentation_feedback: RefCell<Vec<Rc<WpPresentationFeedback>>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -215,6 +218,7 @@ impl WlSurface {
|
|||
children: Default::default(),
|
||||
ext: CloneCell::new(client.state.none_surface_ext.clone()),
|
||||
frame_requests: Default::default(),
|
||||
presentation_feedback: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
toplevel: Default::default(),
|
||||
cursors: Default::default(),
|
||||
|
|
@ -236,6 +240,13 @@ impl WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add_presentation_feedback(&self, fb: &Rc<WpPresentationFeedback>) {
|
||||
self.pending
|
||||
.presentation_feedback
|
||||
.borrow_mut()
|
||||
.push(fb.clone());
|
||||
}
|
||||
|
||||
pub fn is_cursor(&self) -> bool {
|
||||
self.role.get() == SurfaceRole::Cursor
|
||||
}
|
||||
|
|
@ -497,6 +508,15 @@ impl WlSurface {
|
|||
let mut pfr = self.pending.frame_request.borrow_mut();
|
||||
self.frame_requests.borrow_mut().extend(pfr.drain(..));
|
||||
}
|
||||
{
|
||||
let mut fbs = self.presentation_feedback.borrow_mut();
|
||||
for fb in fbs.drain(..) {
|
||||
fb.send_discarded();
|
||||
let _ = self.client.remove_obj(&*fb);
|
||||
}
|
||||
let mut pfbs = self.pending.presentation_feedback.borrow_mut();
|
||||
mem::swap(fbs.deref_mut(), pfbs.deref_mut());
|
||||
}
|
||||
{
|
||||
if let Some(region) = self.pending.input_region.take() {
|
||||
self.input_region.set(region);
|
||||
|
|
|
|||
|
|
@ -328,21 +328,6 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn notify_parent(&self) {
|
||||
let parent = match self.toplevel_data.parent.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
let extents = self.xdg.extents.get();
|
||||
parent.clone().node_child_active_changed(
|
||||
self,
|
||||
self.toplevel_data.active_children.get() > 0,
|
||||
1,
|
||||
);
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
parent.node_child_title_changed(self, self.toplevel_data.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn map_floating(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>) {
|
||||
let (width, height) = self.toplevel_data.float_size(workspace);
|
||||
self.state
|
||||
|
|
@ -460,9 +445,6 @@ impl ToplevelNode for XdgToplevel {
|
|||
}
|
||||
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
let changed = {
|
||||
let mut states = self.states.borrow_mut();
|
||||
match active {
|
||||
|
|
@ -587,10 +569,8 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
}
|
||||
|
||||
fn extents_changed(&self) {
|
||||
self.notify_parent();
|
||||
if self.toplevel_data.parent.get().is_some() {
|
||||
self.state.tree_changed();
|
||||
}
|
||||
self.toplevel_data.pos.set(self.xdg.extents.get());
|
||||
self.tl_extents_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -307,7 +307,8 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
|
||||
fn extents_changed(&self) {
|
||||
self.tl_notify_parent();
|
||||
self.toplevel_data.pos.set(self.surface.extents.get());
|
||||
self.tl_extents_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -391,12 +392,6 @@ impl ToplevelNode for Xwindow {
|
|||
&& self.data.info.input_model.get() != XInputModel::None
|
||||
}
|
||||
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
if let Some(pn) = self.toplevel_data.parent.get() {
|
||||
pn.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn tl_on_activate(&self) {
|
||||
self.data
|
||||
.state
|
||||
|
|
|
|||
|
|
@ -307,6 +307,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
self.mapped.set(false);
|
||||
self.surface.destroy_node();
|
||||
self.seat_state.destroy_node(self);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
116
src/ifs/wp_presentation.rs
Normal file
116
src/ifs/wp_presentation.rs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
pub use crate::wire::{wp_presentation::*, WpPresentationId};
|
||||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::wp_presentation_feedback::WpPresentationFeedback,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
pub struct WpPresentationGlobal {
|
||||
pub name: GlobalName,
|
||||
}
|
||||
|
||||
impl WpPresentationGlobal {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: WpPresentationId,
|
||||
client: &Rc<Client>,
|
||||
_version: u32,
|
||||
) -> Result<(), WpPresentationError> {
|
||||
let obj = Rc::new(WpPresentation {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
obj.send_clock_id();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(WpPresentationGlobal, WpPresentation, WpPresentationError);
|
||||
|
||||
impl Global for WpPresentationGlobal {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(WpPresentationGlobal);
|
||||
|
||||
pub struct WpPresentation {
|
||||
pub id: WpPresentationId,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl WpPresentation {
|
||||
fn send_clock_id(&self) {
|
||||
self.client.event(ClockId {
|
||||
self_id: self.id,
|
||||
clk_id: c::CLOCK_MONOTONIC as _,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WpPresentationError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn feedback(&self, parser: MsgParser<'_, '_>) -> Result<(), WpPresentationError> {
|
||||
let req: Feedback = self.client.parse(self, parser)?;
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let fb = Rc::new(WpPresentationFeedback {
|
||||
id: req.callback,
|
||||
client: self.client.clone(),
|
||||
surface: surface.clone(),
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(self.client, fb);
|
||||
self.client.add_client_obj(&fb)?;
|
||||
surface.add_presentation_feedback(&fb);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base2! {
|
||||
WpPresentation;
|
||||
|
||||
DESTROY => destroy,
|
||||
FEEDBACK => feedback,
|
||||
}
|
||||
|
||||
impl Object for WpPresentation {
|
||||
fn num_requests(&self) -> u32 {
|
||||
FEEDBACK + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WpPresentation);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpPresentationError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WpPresentationError, MsgParserError);
|
||||
efrom!(WpPresentationError, ClientError);
|
||||
78
src/ifs/wp_presentation_feedback.rs
Normal file
78
src/ifs/wp_presentation_feedback.rs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
use {
|
||||
crate::{
|
||||
client::Client,
|
||||
ifs::{
|
||||
wl_output::{WlOutput, WlOutputGlobal},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
wire::{wp_presentation_feedback::*, WpPresentationFeedbackId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct WpPresentationFeedback {
|
||||
pub id: WpPresentationFeedbackId,
|
||||
pub client: Rc<Client>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
pub struct ExecutedPresentation {
|
||||
pub feedback: Rc<WpPresentationFeedback>,
|
||||
pub output: Rc<WlOutputGlobal>,
|
||||
pub tv_sec: u64,
|
||||
pub tv_nsec: u32,
|
||||
pub seq: u64,
|
||||
pub refresh: u32,
|
||||
}
|
||||
|
||||
pub const KIND_VSYNC: u32 = 0x1;
|
||||
#[allow(dead_code)]
|
||||
pub const KIND_HW_CLOCK: u32 = 0x2;
|
||||
pub const KIND_HW_COMPLETION: u32 = 0x4;
|
||||
#[allow(dead_code)]
|
||||
pub const KIND_ZERO_COPY: u32 = 0x8;
|
||||
|
||||
impl WpPresentationFeedback {
|
||||
pub fn send_sync_output(&self, output: &WlOutput) {
|
||||
self.client.event(SyncOutput {
|
||||
self_id: self.id,
|
||||
output: output.id,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn send_presented(&self, tv_sec: u64, tv_nsec: u32, refresh: u32, seq: u64, flags: u32) {
|
||||
self.client.event(Presented {
|
||||
self_id: self.id,
|
||||
tv_sec_hi: (tv_sec >> 32) as u32,
|
||||
tv_sec_lo: tv_sec as u32,
|
||||
tv_nsec,
|
||||
refresh,
|
||||
seq_hi: (seq >> 32) as u32,
|
||||
seq_lo: seq as u32,
|
||||
flags,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn send_discarded(&self) {
|
||||
self.client.event(Discarded { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
||||
object_base2! {
|
||||
WpPresentationFeedback;
|
||||
}
|
||||
|
||||
impl Object for WpPresentationFeedback {
|
||||
fn num_requests(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WpPresentationFeedback);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpPresentationFeedbackError {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue