wire: generate trait for request handling
This commit is contained in:
parent
e3a1a0b30f
commit
acb391335b
102 changed files with 1632 additions and 2086 deletions
|
|
@ -7,13 +7,10 @@ use {
|
|||
wl_surface::{SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
rect::Rect,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
numcell::NumCell,
|
||||
},
|
||||
utils::numcell::NumCell,
|
||||
wire::{ext_session_lock_surface_v1::*, ExtSessionLockSurfaceV1Id, WlSurfaceId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -29,6 +26,7 @@ pub struct ExtSessionLockSurfaceV1 {
|
|||
pub serial: NumCell<u32>,
|
||||
pub output: Option<Rc<OutputNode>>,
|
||||
pub seat_state: NodeSeatState,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl ExtSessionLockSurfaceV1 {
|
||||
|
|
@ -56,20 +54,24 @@ impl ExtSessionLockSurfaceV1 {
|
|||
height: height as _,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), ExtSessionLockSurfaceV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, msg)?;
|
||||
impl ExtSessionLockSurfaceV1RequestHandler for ExtSessionLockSurfaceV1 {
|
||||
type Error = ExtSessionLockSurfaceV1Error;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.destroy_node();
|
||||
self.surface.unset_ext();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ack_configure(&self, msg: MsgParser<'_, '_>) -> Result<(), ExtSessionLockSurfaceV1Error> {
|
||||
let _req: AckConfigure = self.client.parse(self, msg)?;
|
||||
fn ack_configure(&self, _req: AckConfigure, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtSessionLockSurfaceV1 {
|
||||
pub fn destroy_node(&self) {
|
||||
if let Some(output) = &self.output {
|
||||
if let Some(ls) = output.lock_surface.get() {
|
||||
|
|
@ -131,9 +133,7 @@ impl Node for ExtSessionLockSurfaceV1 {
|
|||
|
||||
object_base! {
|
||||
self = ExtSessionLockSurfaceV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
ACK_CONFIGURE => ack_configure,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ExtSessionLockSurfaceV1 {
|
||||
|
|
@ -146,8 +146,6 @@ simple_add_obj!(ExtSessionLockSurfaceV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ExtSessionLockSurfaceV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
|
|
@ -155,5 +153,4 @@ pub enum ExtSessionLockSurfaceV1Error {
|
|||
#[error("Surface {0} cannot be turned into an ext_session_lock_surface because it already has an attached ext_session_lock_surface")]
|
||||
AlreadyAttached(WlSurfaceId),
|
||||
}
|
||||
efrom!(ExtSessionLockSurfaceV1Error, MsgParserError);
|
||||
efrom!(ExtSessionLockSurfaceV1Error, ClientError);
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ use {
|
|||
SurfaceRole, WlSurface, WlSurfaceError, WlSurfaceId,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
object::{Object, Version},
|
||||
rect::Rect,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
linkedlist::{LinkedNode, NodeRef},
|
||||
numcell::NumCell,
|
||||
|
|
@ -20,7 +19,6 @@ use {
|
|||
cell::{Cell, RefCell, RefMut},
|
||||
collections::hash_map::OccupiedEntry,
|
||||
mem,
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
|
|
@ -46,6 +44,7 @@ pub struct WlSubsurface {
|
|||
depth: NumCell<u32>,
|
||||
pub tracker: Tracker<Self>,
|
||||
had_buffer: Cell<bool>,
|
||||
version: Version,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -92,7 +91,12 @@ fn update_children_attach(surface: &WlSubsurface) -> Result<(), WlSubsurfaceErro
|
|||
}
|
||||
|
||||
impl WlSubsurface {
|
||||
pub fn new(id: WlSubsurfaceId, surface: &Rc<WlSurface>, parent: &Rc<WlSurface>) -> Self {
|
||||
pub fn new(
|
||||
id: WlSubsurfaceId,
|
||||
surface: &Rc<WlSurface>,
|
||||
parent: &Rc<WlSurface>,
|
||||
version: Version,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
unique_id: surface.client.state.subsurface_ids.next(),
|
||||
|
|
@ -106,6 +110,7 @@ impl WlSubsurface {
|
|||
depth: NumCell::new(1),
|
||||
tracker: Default::default(),
|
||||
had_buffer: Cell::new(false),
|
||||
version,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,45 +175,6 @@ impl WlSubsurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> {
|
||||
let _req: Destroy = self.surface.client.parse(self, parser)?;
|
||||
self.surface.unset_ext();
|
||||
self.parent.consume_pending_child(self.unique_id, |oe| {
|
||||
let oe = oe.remove();
|
||||
if let Some(mut state) = oe.pending.state {
|
||||
self.surface.apply_state(&mut state)?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
*self.node.borrow_mut() = None;
|
||||
self.latest_node.take();
|
||||
{
|
||||
let mut children = self.parent.children.borrow_mut();
|
||||
if let Some(children) = &mut *children {
|
||||
children.subsurfaces.remove(&self.surface.id);
|
||||
}
|
||||
}
|
||||
if !self.surface.extents.get().is_empty() {
|
||||
let mut parent_opt = Some(self.parent.clone());
|
||||
while let Some(parent) = parent_opt.take() {
|
||||
if !parent.need_extents_update.get() {
|
||||
break;
|
||||
}
|
||||
parent.calculate_extents();
|
||||
parent_opt = parent.ext.get().subsurface_parent();
|
||||
}
|
||||
}
|
||||
self.surface.client.remove_obj(self)?;
|
||||
self.surface.destroy_node();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_position(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> {
|
||||
let req: SetPosition = self.surface.client.parse(&**self, parser)?;
|
||||
self.pending().position = Some((req.x, req.y));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn place(self: &Rc<Self>, sibling: WlSurfaceId, above: bool) -> Result<(), WlSubsurfaceError> {
|
||||
if sibling == self.surface.id {
|
||||
return Err(WlSubsurfaceError::AboveSelf(sibling));
|
||||
|
|
@ -244,18 +210,6 @@ impl WlSubsurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn place_above(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> {
|
||||
let req: PlaceAbove = self.surface.client.parse(self.deref(), parser)?;
|
||||
self.place(req.sibling, true)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn place_below(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> {
|
||||
let req: PlaceBelow = self.surface.client.parse(self.deref(), parser)?;
|
||||
self.place(req.sibling, false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sync(&self) -> bool {
|
||||
self.sync_requested.get() || self.sync_ancestor.get()
|
||||
}
|
||||
|
|
@ -298,15 +252,64 @@ impl WlSubsurface {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn set_sync(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> {
|
||||
let _req: SetSync = self.surface.client.parse(self, parser)?;
|
||||
impl WlSubsurfaceRequestHandler for WlSubsurface {
|
||||
type Error = WlSubsurfaceError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.surface.unset_ext();
|
||||
self.parent.consume_pending_child(self.unique_id, |oe| {
|
||||
let oe = oe.remove();
|
||||
if let Some(mut state) = oe.pending.state {
|
||||
self.surface.apply_state(&mut state)?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
*self.node.borrow_mut() = None;
|
||||
self.latest_node.take();
|
||||
{
|
||||
let mut children = self.parent.children.borrow_mut();
|
||||
if let Some(children) = &mut *children {
|
||||
children.subsurfaces.remove(&self.surface.id);
|
||||
}
|
||||
}
|
||||
if !self.surface.extents.get().is_empty() {
|
||||
let mut parent_opt = Some(self.parent.clone());
|
||||
while let Some(parent) = parent_opt.take() {
|
||||
if !parent.need_extents_update.get() {
|
||||
break;
|
||||
}
|
||||
parent.calculate_extents();
|
||||
parent_opt = parent.ext.get().subsurface_parent();
|
||||
}
|
||||
}
|
||||
self.surface.client.remove_obj(self)?;
|
||||
self.surface.destroy_node();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_position(&self, req: SetPosition, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
slf.pending().position = Some((req.x, req.y));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn place_above(&self, req: PlaceAbove, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
slf.place(req.sibling, true)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn place_below(&self, req: PlaceBelow, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
slf.place(req.sibling, false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_sync(&self, _req: SetSync, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.update_sync(true)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_desync(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSubsurfaceError> {
|
||||
let _req: SetDesync = self.surface.client.parse(self, parser)?;
|
||||
fn set_desync(&self, _req: SetDesync, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.update_sync(false)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -314,13 +317,7 @@ impl WlSubsurface {
|
|||
|
||||
object_base! {
|
||||
self = WlSubsurface;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_POSITION => set_position,
|
||||
PLACE_ABOVE => place_above,
|
||||
PLACE_BELOW => place_below,
|
||||
SET_SYNC => set_sync,
|
||||
SET_DESYNC => set_desync,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WlSubsurface {
|
||||
|
|
@ -404,13 +401,10 @@ pub enum WlSubsurfaceError {
|
|||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error("Cannot place {0} above/below itself")]
|
||||
AboveSelf(WlSurfaceId),
|
||||
#[error("{0} is not a sibling of {1}")]
|
||||
NotASibling(WlSurfaceId, WlSurfaceId),
|
||||
}
|
||||
efrom!(WlSubsurfaceError, WlSurfaceError);
|
||||
efrom!(WlSubsurfaceError, MsgParserError);
|
||||
efrom!(WlSubsurfaceError, ClientError);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
wire::{wp_fractional_scale_v1::*, WpFractionalScaleV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -16,15 +15,17 @@ pub struct WpFractionalScaleV1 {
|
|||
pub client: Rc<Client>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpFractionalScaleV1 {
|
||||
pub fn new(id: WpFractionalScaleV1Id, surface: &Rc<WlSurface>) -> Self {
|
||||
pub fn new(id: WpFractionalScaleV1Id, surface: &Rc<WlSurface>, version: Version) -> Self {
|
||||
Self {
|
||||
id,
|
||||
client: surface.client.clone(),
|
||||
surface: surface.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,9 +51,12 @@ impl WpFractionalScaleV1 {
|
|||
.to_wl(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), WpFractionalScaleError> {
|
||||
let _req: Destroy = self.client.parse(self, msg)?;
|
||||
impl WpFractionalScaleV1RequestHandler for WpFractionalScaleV1 {
|
||||
type Error = WpFractionalScaleError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.surface.fractional_scale.take();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
@ -61,8 +65,7 @@ impl WpFractionalScaleV1 {
|
|||
|
||||
object_base! {
|
||||
self = WpFractionalScaleV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WpFractionalScaleV1 {}
|
||||
|
|
@ -71,12 +74,9 @@ simple_add_obj!(WpFractionalScaleV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpFractionalScaleError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface already has a fractional scale extension attached")]
|
||||
Exists,
|
||||
}
|
||||
efrom!(WpFractionalScaleError, MsgParserError);
|
||||
efrom!(WpFractionalScaleError, ClientError);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
video::drm::sync_obj::SyncObjPoint,
|
||||
wire::{wp_linux_drm_syncobj_surface_v1::*, WpLinuxDrmSyncobjSurfaceV1Id},
|
||||
},
|
||||
|
|
@ -17,6 +16,7 @@ pub struct WpLinuxDrmSyncobjSurfaceV1 {
|
|||
client: Rc<Client>,
|
||||
surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
version: Version,
|
||||
}
|
||||
|
||||
impl WpLinuxDrmSyncobjSurfaceV1 {
|
||||
|
|
@ -24,12 +24,14 @@ impl WpLinuxDrmSyncobjSurfaceV1 {
|
|||
id: WpLinuxDrmSyncobjSurfaceV1Id,
|
||||
client: &Rc<Client>,
|
||||
surface: &Rc<WlSurface>,
|
||||
version: Version,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
surface: surface.clone(),
|
||||
version,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,9 +42,12 @@ impl WpLinuxDrmSyncobjSurfaceV1 {
|
|||
self.surface.sync_obj_surface.set(Some(self.clone()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WpLinuxDrmSyncobjSurfaceV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
impl WpLinuxDrmSyncobjSurfaceV1RequestHandler for WpLinuxDrmSyncobjSurfaceV1 {
|
||||
type Error = WpLinuxDrmSyncobjSurfaceV1Error;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.surface.sync_obj_surface.take();
|
||||
let pending = &mut *self.surface.pending.borrow_mut();
|
||||
pending.release_point.take();
|
||||
|
|
@ -51,22 +56,14 @@ impl WpLinuxDrmSyncobjSurfaceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_acquire_point(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WpLinuxDrmSyncobjSurfaceV1Error> {
|
||||
let req: SetAcquirePoint = self.client.parse(self, parser)?;
|
||||
fn set_acquire_point(&self, req: SetAcquirePoint, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let point = point(req.point_hi, req.point_lo);
|
||||
let timeline = self.client.lookup(req.timeline)?;
|
||||
self.surface.pending.borrow_mut().acquire_point = Some((timeline.sync_obj.clone(), point));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_release_point(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WpLinuxDrmSyncobjSurfaceV1Error> {
|
||||
let req: SetReleasePoint = self.client.parse(self, parser)?;
|
||||
fn set_release_point(&self, req: SetReleasePoint, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let point = point(req.point_hi, req.point_lo);
|
||||
let timeline = self.client.lookup(req.timeline)?;
|
||||
self.surface.pending.borrow_mut().release_point = Some((timeline.sync_obj.clone(), point));
|
||||
|
|
@ -80,10 +77,7 @@ fn point(hi: u32, lo: u32) -> SyncObjPoint {
|
|||
|
||||
object_base! {
|
||||
self = WpLinuxDrmSyncobjSurfaceV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_ACQUIRE_POINT => set_acquire_point,
|
||||
SET_RELEASE_POINT => set_release_point,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WpLinuxDrmSyncobjSurfaceV1 {}
|
||||
|
|
@ -92,12 +86,9 @@ simple_add_obj!(WpLinuxDrmSyncobjSurfaceV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpLinuxDrmSyncobjSurfaceV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface already has a syncobj extension attached")]
|
||||
Exists,
|
||||
}
|
||||
efrom!(WpLinuxDrmSyncobjSurfaceV1Error, MsgParserError);
|
||||
efrom!(WpLinuxDrmSyncobjSurfaceV1Error, ClientError);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use {
|
|||
client::ClientError,
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
wire::{wp_tearing_control_v1::*, WlSurfaceId, WpTearingControlV1Id},
|
||||
},
|
||||
std::{fmt::Debug, rc::Rc},
|
||||
|
|
@ -18,6 +17,7 @@ pub struct WpTearingControlV1 {
|
|||
pub id: WpTearingControlV1Id,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpTearingControlV1 {
|
||||
|
|
@ -28,12 +28,16 @@ impl WpTearingControlV1 {
|
|||
self.surface.tearing_control.set(Some(self.clone()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl WpTearingControlV1RequestHandler for WpTearingControlV1 {
|
||||
type Error = WpTearingControlV1Error;
|
||||
|
||||
fn set_presentation_hint(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WpTearingControlV1Error> {
|
||||
let req: SetPresentationHint = self.surface.client.parse(self, parser)?;
|
||||
req: SetPresentationHint,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let tearing = match req.hint {
|
||||
VSYNC => false,
|
||||
ASYNC => true,
|
||||
|
|
@ -43,8 +47,7 @@ impl WpTearingControlV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WpTearingControlV1Error> {
|
||||
let _req: Destroy = self.surface.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.surface.pending.borrow_mut().tearing = Some(false);
|
||||
self.surface.tearing_control.take();
|
||||
self.surface.client.remove_obj(self)?;
|
||||
|
|
@ -54,9 +57,7 @@ impl WpTearingControlV1 {
|
|||
|
||||
object_base! {
|
||||
self = WpTearingControlV1;
|
||||
|
||||
SET_PRESENTATION_HINT => set_presentation_hint,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WpTearingControlV1 {}
|
||||
|
|
@ -71,8 +72,5 @@ pub enum WpTearingControlV1Error {
|
|||
UnknownPresentationHint(u32),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(WpTearingControlV1Error, ClientError);
|
||||
efrom!(WpTearingControlV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
wire::{wp_viewport::*, WpViewportId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -16,15 +15,17 @@ pub struct WpViewport {
|
|||
pub client: Rc<Client>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpViewport {
|
||||
pub fn new(id: WpViewportId, surface: &Rc<WlSurface>) -> Self {
|
||||
pub fn new(id: WpViewportId, surface: &Rc<WlSurface>, version: Version) -> Self {
|
||||
Self {
|
||||
id,
|
||||
client: surface.client.clone(),
|
||||
surface: surface.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,9 +36,12 @@ impl WpViewport {
|
|||
self.surface.viewporter.set(Some(self.clone()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewportError> {
|
||||
let _req: Destroy = self.client.parse(self, msg)?;
|
||||
impl WpViewportRequestHandler for WpViewport {
|
||||
type Error = WpViewportError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let pending = &mut *self.surface.pending.borrow_mut();
|
||||
pending.src_rect = Some(None);
|
||||
pending.dst_size = Some(None);
|
||||
|
|
@ -46,8 +50,7 @@ impl WpViewport {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_source(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewportError> {
|
||||
let req: SetSource = self.client.parse(self, msg)?;
|
||||
fn set_source(&self, req: SetSource, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let rect = if req.x == -1 && req.y == -1 && req.width == -1 && req.height == -1 {
|
||||
None
|
||||
} else {
|
||||
|
|
@ -61,8 +64,7 @@ impl WpViewport {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_destination(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewportError> {
|
||||
let req: SetDestination = self.client.parse(self, msg)?;
|
||||
fn set_destination(&self, req: SetDestination, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let size = if req.width == -1 && req.height == -1 {
|
||||
None
|
||||
} else if req.width <= 0 || req.height <= 0 {
|
||||
|
|
@ -77,10 +79,7 @@ impl WpViewport {
|
|||
|
||||
object_base! {
|
||||
self = WpViewport;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_SOURCE => set_source,
|
||||
SET_DESTINATION => set_destination,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WpViewport {}
|
||||
|
|
@ -89,8 +88,6 @@ simple_add_obj!(WpViewport);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpViewportError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface already has a viewport")]
|
||||
|
|
@ -100,5 +97,4 @@ pub enum WpViewportError {
|
|||
#[error("Rectangle is empty")]
|
||||
InvalidDestRect,
|
||||
}
|
||||
efrom!(WpViewportError, MsgParserError);
|
||||
efrom!(WpViewportError, ClientError);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,8 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::wl_surface::{x_surface::XSurface, WlSurfaceError},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
cell_ext::CellExt,
|
||||
},
|
||||
object::{Object, Version},
|
||||
utils::cell_ext::CellExt,
|
||||
wire::{xwayland_surface_v1::*, XwaylandSurfaceV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -19,11 +16,13 @@ pub struct XwaylandSurfaceV1 {
|
|||
pub client: Rc<Client>,
|
||||
pub x: Rc<XSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl XwaylandSurfaceV1 {
|
||||
fn set_serial(&self, parser: MsgParser<'_, '_>) -> Result<(), XwaylandSurfaceV1Error> {
|
||||
let req: SetSerial = self.client.parse(self, parser)?;
|
||||
impl XwaylandSurfaceV1RequestHandler for XwaylandSurfaceV1 {
|
||||
type Error = XwaylandSurfaceV1Error;
|
||||
|
||||
fn set_serial(&self, req: SetSerial, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.x.surface.xwayland_serial.is_some() {
|
||||
return Err(XwaylandSurfaceV1Error::SerialAlreadySet);
|
||||
}
|
||||
|
|
@ -36,8 +35,7 @@ impl XwaylandSurfaceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XwaylandSurfaceV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.x.xwayland_surface.set(None);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
@ -46,9 +44,7 @@ impl XwaylandSurfaceV1 {
|
|||
|
||||
object_base! {
|
||||
self = XwaylandSurfaceV1;
|
||||
|
||||
SET_SERIAL => set_serial,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for XwaylandSurfaceV1 {
|
||||
|
|
@ -67,10 +63,7 @@ pub enum XwaylandSurfaceV1Error {
|
|||
NonMonotonicSerial,
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(#[from] WlSurfaceError),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(XwaylandSurfaceV1Error, MsgParserError);
|
||||
efrom!(XwaylandSurfaceV1Error, ClientError);
|
||||
|
|
|
|||
|
|
@ -19,11 +19,7 @@ use {
|
|||
rect::Rect,
|
||||
tree::{FindTreeResult, FoundNode, OutputNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
numcell::NumCell,
|
||||
option_ext::OptionExt,
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, numcell::NumCell, option_ext::OptionExt,
|
||||
},
|
||||
wire::{xdg_surface::*, WlSurfaceId, XdgPopupId, XdgSurfaceId},
|
||||
},
|
||||
|
|
@ -215,8 +211,17 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||
let _req: Destroy = self.surface.client.parse(self, parser)?;
|
||||
fn pending(&self) -> RefMut<Box<PendingXdgSurfaceData>> {
|
||||
RefMut::map(self.surface.pending.borrow_mut(), |p| {
|
||||
p.xdg_surface.get_or_insert_default_ext()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgSurfaceRequestHandler for XdgSurface {
|
||||
type Error = XdgSurfaceError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.ext.is_some() {
|
||||
return Err(XdgSurfaceError::RoleNotYetDestroyed(self.id));
|
||||
}
|
||||
|
|
@ -232,12 +237,11 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_toplevel(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||
let req: GetToplevel = self.surface.client.parse(&**self, parser)?;
|
||||
fn get_toplevel(&self, req: GetToplevel, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.set_role(XdgSurfaceRole::XdgToplevel)?;
|
||||
if self.ext.is_some() {
|
||||
self.surface.client.protocol_error(
|
||||
&**self,
|
||||
self,
|
||||
ALREADY_CONSTRUCTED,
|
||||
&format!(
|
||||
"wl_surface {} already has an assigned xdg_toplevel",
|
||||
|
|
@ -246,7 +250,7 @@ impl XdgSurface {
|
|||
);
|
||||
return Err(XdgSurfaceError::AlreadyConstructed);
|
||||
}
|
||||
let toplevel = Rc::new(XdgToplevel::new(req.id, self));
|
||||
let toplevel = Rc::new(XdgToplevel::new(req.id, slf));
|
||||
track!(self.surface.client, toplevel);
|
||||
self.surface.client.add_client_obj(&toplevel)?;
|
||||
self.ext.set(Some(toplevel.clone()));
|
||||
|
|
@ -257,8 +261,7 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_popup(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||
let req: GetPopup = self.surface.client.parse(&**self, parser)?;
|
||||
fn get_popup(&self, req: GetPopup, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.set_role(XdgSurfaceRole::XdgPopup)?;
|
||||
let mut parent = None;
|
||||
if req.parent.is_some() {
|
||||
|
|
@ -267,7 +270,7 @@ impl XdgSurface {
|
|||
let positioner = self.surface.client.lookup(req.positioner)?;
|
||||
if self.ext.is_some() {
|
||||
self.surface.client.protocol_error(
|
||||
&**self,
|
||||
self,
|
||||
ALREADY_CONSTRUCTED,
|
||||
&format!(
|
||||
"wl_surface {} already has an assigned xdg_popup",
|
||||
|
|
@ -276,7 +279,7 @@ impl XdgSurface {
|
|||
);
|
||||
return Err(XdgSurfaceError::AlreadyConstructed);
|
||||
}
|
||||
let popup = Rc::new(XdgPopup::new(req.id, self, parent.as_ref(), &positioner)?);
|
||||
let popup = Rc::new(XdgPopup::new(req.id, slf, parent.as_ref(), &positioner)?);
|
||||
track!(self.surface.client, popup);
|
||||
self.surface.client.add_client_obj(&popup)?;
|
||||
if let Some(parent) = &parent {
|
||||
|
|
@ -286,14 +289,11 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn pending(&self) -> RefMut<Box<PendingXdgSurfaceData>> {
|
||||
RefMut::map(self.surface.pending.borrow_mut(), |p| {
|
||||
p.xdg_surface.get_or_insert_default_ext()
|
||||
})
|
||||
}
|
||||
|
||||
fn set_window_geometry(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||
let req: SetWindowGeometry = self.surface.client.parse(self, parser)?;
|
||||
fn set_window_geometry(
|
||||
&self,
|
||||
req: SetWindowGeometry,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
if req.height == 0 && req.width == 0 {
|
||||
// TODO: https://crbug.com/1329214
|
||||
return Ok(());
|
||||
|
|
@ -306,14 +306,15 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||
let req: AckConfigure = self.surface.client.parse(self, parser)?;
|
||||
fn ack_configure(&self, req: AckConfigure, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.requested_serial.get() == req.serial {
|
||||
self.acked_serial.set(Some(req.serial));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgSurface {
|
||||
fn update_extents(&self) {
|
||||
let old_extents = self.extents.get();
|
||||
let mut new_extents = self.surface.extents.get();
|
||||
|
|
@ -360,12 +361,7 @@ impl XdgSurface {
|
|||
|
||||
object_base! {
|
||||
self = XdgSurface;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_TOPLEVEL => get_toplevel,
|
||||
GET_POPUP => get_popup,
|
||||
SET_WINDOW_GEOMETRY => set_window_geometry,
|
||||
ACK_CONFIGURE => ack_configure,
|
||||
version = self.base.version;
|
||||
}
|
||||
|
||||
impl Object for XdgSurface {
|
||||
|
|
@ -429,8 +425,6 @@ pub enum XdgSurfaceError {
|
|||
},
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error("Tried no set a non-positive width/height")]
|
||||
NonPositiveWidthHeight,
|
||||
#[error("Cannot destroy xdg_surface {0} because it's associated xdg_toplevel/popup is not yet destroyed")]
|
||||
|
|
@ -444,4 +438,3 @@ pub enum XdgSurfaceError {
|
|||
}
|
||||
efrom!(XdgSurfaceError, WlSurfaceError);
|
||||
efrom!(XdgSurfaceError, ClientError);
|
||||
efrom!(XdgSurfaceError, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@ use {
|
|||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
linkedlist::LinkedNode,
|
||||
},
|
||||
utils::{clonecell::CloneCell, linkedlist::LinkedNode},
|
||||
wire::{xdg_popup::*, XdgPopupId},
|
||||
},
|
||||
std::{
|
||||
|
|
@ -205,9 +201,12 @@ impl XdgPopup {
|
|||
.set_absolute_desired_extents(&rel.move_(parent.x1(), parent.y1()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPopupError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self, parser)?;
|
||||
impl XdgPopupRequestHandler for XdgPopup {
|
||||
type Error = XdgPopupError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.destroy_node();
|
||||
{
|
||||
if let Some(parent) = self.parent.take() {
|
||||
|
|
@ -221,13 +220,11 @@ impl XdgPopup {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn grab(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPopupError> {
|
||||
let _req: Grab = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn grab(&self, _req: Grab, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn reposition(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgPopupError> {
|
||||
let req: Reposition = self.xdg.surface.client.parse(&**self, parser)?;
|
||||
fn reposition(&self, req: Reposition, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
*self.pos.borrow_mut() = self.xdg.surface.client.lookup(req.positioner)?.value();
|
||||
if let Some(parent) = self.parent.get() {
|
||||
self.update_position(&parent)?;
|
||||
|
|
@ -238,7 +235,9 @@ impl XdgPopup {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgPopup {
|
||||
fn get_parent_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.parent.get()?.workspace.get()
|
||||
}
|
||||
|
|
@ -276,10 +275,7 @@ impl XdgPopup {
|
|||
|
||||
object_base! {
|
||||
self = XdgPopup;
|
||||
|
||||
DESTROY => destroy,
|
||||
GRAB => grab,
|
||||
REPOSITION => reposition if self.xdg.base.version >= 3,
|
||||
version = self.xdg.base.version;
|
||||
}
|
||||
|
||||
impl Object for XdgPopup {
|
||||
|
|
@ -419,10 +415,7 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
pub enum XdgPopupError {
|
||||
#[error("The `xdg_positioner` is incomplete")]
|
||||
Incomplete,
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(XdgPopupError, MsgParserError);
|
||||
efrom!(XdgPopupError, ClientError);
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@ use {
|
|||
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode,
|
||||
ToplevelData, ToplevelNode, ToplevelNodeBase, ToplevelNodeId, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{xdg_toplevel::*, XdgToplevelId},
|
||||
},
|
||||
ahash::{AHashMap, AHashSet},
|
||||
|
|
@ -35,7 +32,6 @@ use {
|
|||
cell::{Cell, RefCell},
|
||||
fmt::{Debug, Formatter},
|
||||
mem,
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
|
|
@ -199,9 +195,12 @@ impl XdgToplevel {
|
|||
capabilities: &[CAP_FULLSCREEN],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
impl XdgToplevelRequestHandler for XdgToplevel {
|
||||
type Error = XdgToplevelError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.tl_destroy();
|
||||
self.xdg.ext.set(None);
|
||||
{
|
||||
|
|
@ -223,13 +222,12 @@ impl XdgToplevel {
|
|||
parent.children.borrow_mut().remove(&self.id);
|
||||
}
|
||||
}
|
||||
self.xdg.surface.client.remove_obj(self.deref())?;
|
||||
self.xdg.surface.client.remove_obj(self)?;
|
||||
self.xdg.surface.set_toplevel(None);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_parent(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let req: SetParent = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_parent(&self, req: SetParent, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let mut parent = None;
|
||||
if req.parent.is_some() {
|
||||
parent = Some(self.xdg.surface.client.lookup(req.parent)?);
|
||||
|
|
@ -238,27 +236,23 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let req: SetTitle = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_title(&self, req: SetTitle, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.toplevel_data.set_title(req.title);
|
||||
self.tl_title_changed();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_app_id(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let req: SetAppId = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_app_id(&self, req: SetAppId, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.toplevel_data.set_app_id(req.app_id);
|
||||
self.bugs.set(bugs::get(req.app_id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn show_window_menu(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let _req: ShowWindowMenu = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn show_window_menu(&self, _req: ShowWindowMenu, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn move_(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let req: Move = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn move_(&self, req: Move, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let seat = self.xdg.surface.client.lookup(req.seat)?;
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
if let Some(float) = parent.node_into_float() {
|
||||
|
|
@ -268,13 +262,11 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn resize(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let _req: Resize = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn resize(&self, _req: Resize, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_max_size(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let req: SetMaxSize = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_max_size(&self, req: SetMaxSize, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if req.height < 0 || req.width < 0 {
|
||||
return Err(XdgToplevelError::NonNegative);
|
||||
}
|
||||
|
|
@ -291,8 +283,7 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_min_size(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let req: SetMinSize = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_min_size(&self, req: SetMinSize, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if req.height < 0 || req.width < 0 {
|
||||
return Err(XdgToplevelError::NonNegative);
|
||||
}
|
||||
|
|
@ -309,19 +300,16 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_maximized(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let _req: SetMaximized = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_maximized(&self, _req: SetMaximized, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unset_maximized(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let _req: UnsetMaximized = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn unset_maximized(&self, _req: UnsetMaximized, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
fn set_fullscreen(&self, req: SetFullscreen, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let client = &self.xdg.surface.client;
|
||||
let req: SetFullscreen = client.parse(self.deref(), parser)?;
|
||||
self.states.borrow_mut().insert(STATE_FULLSCREEN);
|
||||
'set_fullscreen: {
|
||||
let output = if req.output.is_some() {
|
||||
|
|
@ -338,29 +326,26 @@ impl XdgToplevel {
|
|||
break 'set_fullscreen;
|
||||
};
|
||||
self.toplevel_data
|
||||
.set_fullscreen(&client.state, self.clone(), &output);
|
||||
.set_fullscreen(&client.state, slf.clone(), &output);
|
||||
}
|
||||
self.send_current_configure();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unset_fullscreen(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgToplevelError> {
|
||||
let _req: UnsetFullscreen = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
fn unset_fullscreen(&self, _req: UnsetFullscreen, slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.states.borrow_mut().remove(&STATE_FULLSCREEN);
|
||||
self.toplevel_data
|
||||
.unset_fullscreen(&self.state, self.clone());
|
||||
.unset_fullscreen(&self.state, slf.clone());
|
||||
self.send_current_configure();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_minimized(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let _req: SetMinimized = self.xdg.surface.client.parse(self, parser)?;
|
||||
fn set_minimized(&self, _req: SetMinimized, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl XdgToplevel {
|
||||
fn map_floating(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>, abs_pos: Option<(i32, i32)>) {
|
||||
let (width, height) = self.toplevel_data.float_size(workspace);
|
||||
self.state
|
||||
|
|
@ -461,21 +446,7 @@ impl XdgToplevel {
|
|||
|
||||
object_base! {
|
||||
self = XdgToplevel;
|
||||
|
||||
DESTROY => destroy,
|
||||
SET_PARENT => set_parent,
|
||||
SET_TITLE => set_title,
|
||||
SET_APP_ID => set_app_id,
|
||||
SHOW_WINDOW_MENU => show_window_menu,
|
||||
MOVE => move_,
|
||||
RESIZE => resize,
|
||||
SET_MAX_SIZE => set_max_size,
|
||||
SET_MIN_SIZE => set_min_size,
|
||||
SET_MAXIMIZED => set_maximized,
|
||||
UNSET_MAXIMIZED => unset_maximized,
|
||||
SET_FULLSCREEN => set_fullscreen,
|
||||
UNSET_FULLSCREEN => unset_fullscreen,
|
||||
SET_MINIMIZED => set_minimized,
|
||||
version = self.xdg.base.version;
|
||||
}
|
||||
|
||||
impl Object for XdgToplevel {
|
||||
|
|
@ -673,12 +644,9 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgToplevelError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(XdgToplevelError, MsgParserError);
|
||||
efrom!(XdgToplevelError, ClientError);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use {
|
|||
ifs::wl_surface::{x_surface::xwayland_surface_v1::XwaylandSurfaceV1, WlSurfaceError},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{xwayland_shell_v1::*, WlSurfaceId, XwaylandShellV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -45,15 +44,19 @@ impl XwaylandShellV1Global {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
impl XwaylandShellV1 {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XwaylandShellV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
impl XwaylandShellV1RequestHandler for XwaylandShellV1 {
|
||||
type Error = XwaylandShellV1Error;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_xwayland_surface(&self, parser: MsgParser<'_, '_>) -> Result<(), XwaylandShellV1Error> {
|
||||
let req: GetXwaylandSurface = self.client.parse(self, parser)?;
|
||||
fn get_xwayland_surface(
|
||||
&self,
|
||||
req: GetXwaylandSurface,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let xsurface = surface.get_xsurface()?;
|
||||
if xsurface.xwayland_surface.is_some() {
|
||||
|
|
@ -64,6 +67,7 @@ impl XwaylandShellV1 {
|
|||
client: self.client.clone(),
|
||||
x: xsurface,
|
||||
tracker: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, xws);
|
||||
xws.x.xwayland_surface.set(Some(xws.clone()));
|
||||
|
|
@ -92,9 +96,7 @@ simple_add_global!(XwaylandShellV1Global);
|
|||
|
||||
object_base! {
|
||||
self = XwaylandShellV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_XWAYLAND_SURFACE => get_xwayland_surface,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for XwaylandShellV1 {}
|
||||
|
|
@ -105,12 +107,9 @@ simple_add_obj!(XwaylandShellV1);
|
|||
pub enum XwaylandShellV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error("The `wl_surface` {0} already has an extension object")]
|
||||
AlreadyAttached(WlSurfaceId),
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(#[from] WlSurfaceError),
|
||||
}
|
||||
efrom!(XwaylandShellV1Error, ClientError);
|
||||
efrom!(XwaylandShellV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,7 @@ use {
|
|||
renderer::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
cell_ext::CellExt,
|
||||
linkedlist::LinkedNode,
|
||||
numcell::NumCell,
|
||||
bitflags::BitflagsExt, cell_ext::CellExt, linkedlist::LinkedNode, numcell::NumCell,
|
||||
option_ext::OptionExt,
|
||||
},
|
||||
wire::{zwlr_layer_surface_v1::*, WlSurfaceId, ZwlrLayerSurfaceV1Id},
|
||||
|
|
@ -157,9 +153,12 @@ impl ZwlrLayerSurfaceV1 {
|
|||
m.layer_surface.get_or_insert_default_ext()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn set_size(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: SetSize = self.client.parse(self, parser)?;
|
||||
impl ZwlrLayerSurfaceV1RequestHandler for ZwlrLayerSurfaceV1 {
|
||||
type Error = ZwlrLayerSurfaceV1Error;
|
||||
|
||||
fn set_size(&self, req: SetSize, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if req.width > u16::MAX as u32 || req.height > u16::MAX as u32 {
|
||||
return Err(ZwlrLayerSurfaceV1Error::ExcessiveSize);
|
||||
}
|
||||
|
|
@ -169,8 +168,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_anchor(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: SetAnchor = self.client.parse(self, parser)?;
|
||||
fn set_anchor(&self, req: SetAnchor, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if req.anchor & !(LEFT | RIGHT | TOP | BOTTOM) != 0 {
|
||||
return Err(ZwlrLayerSurfaceV1Error::UnknownAnchor(req.anchor));
|
||||
}
|
||||
|
|
@ -180,16 +178,18 @@ impl ZwlrLayerSurfaceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_exclusive_zone(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: SetExclusiveZone = self.client.parse(self, parser)?;
|
||||
fn set_exclusive_zone(
|
||||
&self,
|
||||
req: SetExclusiveZone,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let mut pending = self.pending();
|
||||
pending.exclusive_zone = Some(req.zone);
|
||||
pending.any = true;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_margin(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: SetMargin = self.client.parse(self, parser)?;
|
||||
fn set_margin(&self, req: SetMargin, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let mut pending = self.pending();
|
||||
pending.margin = Some((req.top, req.right, req.bottom, req.left));
|
||||
pending.any = true;
|
||||
|
|
@ -198,9 +198,9 @@ impl ZwlrLayerSurfaceV1 {
|
|||
|
||||
fn set_keyboard_interactivity(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: SetKeyboardInteractivity = self.client.parse(self, parser)?;
|
||||
req: SetKeyboardInteractivity,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
if req.keyboard_interactivity > KI_ON_DEMAND {
|
||||
return Err(ZwlrLayerSurfaceV1Error::UnknownKi(
|
||||
req.keyboard_interactivity,
|
||||
|
|
@ -212,27 +212,23 @@ impl ZwlrLayerSurfaceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_popup(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let _req: GetPopup = self.client.parse(self, parser)?;
|
||||
fn get_popup(&self, _req: GetPopup, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn ack_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: AckConfigure = self.client.parse(self, parser)?;
|
||||
fn ack_configure(&self, req: AckConfigure, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.acked_serial.set(Some(req.serial));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.destroy_node();
|
||||
self.client.remove_obj(self)?;
|
||||
self.surface.unset_ext();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_layer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let req: SetLayer = self.client.parse(self, parser)?;
|
||||
fn set_layer(&self, req: SetLayer, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if req.layer > OVERLAY {
|
||||
return Err(ZwlrLayerSurfaceV1Error::UnknownLayer(req.layer));
|
||||
}
|
||||
|
|
@ -241,7 +237,9 @@ impl ZwlrLayerSurfaceV1 {
|
|||
pending.any = true;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwlrLayerSurfaceV1 {
|
||||
fn pre_commit(&self, pending: &mut PendingState) -> Result<(), ZwlrLayerSurfaceV1Error> {
|
||||
let pending = pending.layer_surface.get_or_insert_default_ext();
|
||||
let mut send_configure = mem::replace(&mut pending.any, false);
|
||||
|
|
@ -437,16 +435,7 @@ impl Node for ZwlrLayerSurfaceV1 {
|
|||
|
||||
object_base! {
|
||||
self = ZwlrLayerSurfaceV1;
|
||||
|
||||
SET_SIZE => set_size,
|
||||
SET_ANCHOR => set_anchor,
|
||||
SET_EXCLUSIVE_ZONE => set_exclusive_zone,
|
||||
SET_MARGIN => set_margin,
|
||||
SET_KEYBOARD_INTERACTIVITY => set_keyboard_interactivity,
|
||||
GET_POPUP => get_popup,
|
||||
ACK_CONFIGURE => ack_configure,
|
||||
DESTROY => destroy,
|
||||
SET_LAYER => set_layer if self.shell.version >= 2,
|
||||
version = self.shell.version;
|
||||
}
|
||||
|
||||
impl Object for ZwlrLayerSurfaceV1 {
|
||||
|
|
@ -468,8 +457,6 @@ pub enum ZwlrLayerSurfaceV1Error {
|
|||
HeightZero,
|
||||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Unknown layer {0}")]
|
||||
|
|
@ -482,5 +469,4 @@ pub enum ZwlrLayerSurfaceV1Error {
|
|||
UnknownKi(u32),
|
||||
}
|
||||
efrom!(ZwlrLayerSurfaceV1Error, WlSurfaceError);
|
||||
efrom!(ZwlrLayerSurfaceV1Error, MsgParserError);
|
||||
efrom!(ZwlrLayerSurfaceV1Error, ClientError);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
wire::{zwp_idle_inhibitor_v1::*, ZwpIdleInhibitorV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -19,18 +18,22 @@ pub struct ZwpIdleInhibitorV1 {
|
|||
pub client: Rc<Client>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl ZwpIdleInhibitorV1 {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpIdleInhibitorV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
impl ZwpIdleInhibitorV1RequestHandler for ZwpIdleInhibitorV1 {
|
||||
type Error = ZwpIdleInhibitorV1Error;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
if self.surface.idle_inhibitors.remove(&self.id).is_some() {
|
||||
self.deactivate();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwpIdleInhibitorV1 {
|
||||
pub fn install(self: &Rc<Self>) -> Result<(), ZwpIdleInhibitorV1Error> {
|
||||
self.surface.idle_inhibitors.insert(self.id, self.clone());
|
||||
if self.surface.visible.get() {
|
||||
|
|
@ -50,8 +53,7 @@ impl ZwpIdleInhibitorV1 {
|
|||
|
||||
object_base! {
|
||||
self = ZwpIdleInhibitorV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwpIdleInhibitorV1 {
|
||||
|
|
@ -64,10 +66,7 @@ simple_add_obj!(ZwpIdleInhibitorV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpIdleInhibitorV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpIdleInhibitorV1Error, ClientError);
|
||||
efrom!(ZwpIdleInhibitorV1Error, MsgParserError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue