1
0
Fork 0
forked from wry/wry

autocommit 2022-01-08 18:38:24 CET

This commit is contained in:
Julian Orth 2022-01-08 18:38:24 +01:00
parent 33549184d4
commit d061a5c313
38 changed files with 179 additions and 371 deletions

View file

@ -33,12 +33,12 @@ const SET_BUFFER_TRANSFORM: u32 = 7;
const SET_BUFFER_SCALE: u32 = 8;
const DAMAGE_BUFFER: u32 = 9;
const ENTER: u32 = 0;
const LEAVE: u32 = 1;
#[allow(dead_code)] const ENTER: u32 = 0;
#[allow(dead_code)] const LEAVE: u32 = 1;
const INVALID_SCALE: u32 = 0;
const INVALID_TRANSFORM: u32 = 1;
const INVALID_SIZE: u32 = 2;
#[allow(dead_code)] const INVALID_SCALE: u32 = 0;
#[allow(dead_code)] const INVALID_TRANSFORM: u32 = 1;
#[allow(dead_code)] const INVALID_SIZE: u32 = 2;
id!(WlSurfaceId);
@ -143,7 +143,7 @@ impl XdgSurfaceRoleData {
}
struct XdgPopupData {
popup: Rc<XdgPopup>,
_popup: Rc<XdgPopup>,
parent: Option<Rc<XdgSurface>>,
}
@ -229,7 +229,7 @@ impl WlSurface {
for surface in children.subsurfaces.values() {
let rd = surface.role_data.borrow();
if let RoleData::Subsurface(ss) = &*rd {
let mut ss_extents = surface.extents.get();
let ss_extents = surface.extents.get();
extents.x1 = extents.x1.min(ss_extents.x1 + ss.x);
extents.y1 = extents.y1.min(ss_extents.y1 + ss.y);
extents.x2 = extents.x2.max(ss_extents.x2 + ss.x);
@ -249,10 +249,6 @@ impl WlSurface {
parent.calculate_extents();
}
pub fn is_subsurface(&self) -> bool {
self.role.get() == SurfaceRole::Subsurface
}
pub fn get_root(self: &Rc<Self>) -> Rc<WlSurface> {
let mut root = self.clone();
loop {
@ -381,7 +377,7 @@ impl WlSurface {
}
async fn damage(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageError> {
let req: Damage = self.parse(parser)?;
let _req: Damage = self.parse(parser)?;
Ok(())
}
@ -518,17 +514,17 @@ impl WlSurface {
&self,
parser: MsgParser<'_, '_>,
) -> Result<(), SetBufferTransformError> {
let req: SetBufferTransform = self.parse(parser)?;
let _req: SetBufferTransform = self.parse(parser)?;
Ok(())
}
async fn set_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), SetBufferScaleError> {
let req: SetBufferScale = self.parse(parser)?;
let _req: SetBufferScale = self.parse(parser)?;
Ok(())
}
async fn damage_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageBufferError> {
let req: DamageBuffer = self.parse(parser)?;
let _req: DamageBuffer = self.parse(parser)?;
Ok(())
}

View file

@ -17,7 +17,7 @@ const PLACE_BELOW: u32 = 3;
const SET_SYNC: u32 = 4;
const SET_DESYNC: u32 = 5;
const BAD_SURFACE: u32 = 0;
#[allow(dead_code)] const BAD_SURFACE: u32 = 0;
const MAX_SUBSURFACE_DEPTH: u32 = 100;
@ -29,7 +29,7 @@ pub struct WlSubsurface {
pub(super) parent: Rc<WlSurface>,
}
fn update_children_sync(surface: &Rc<WlSurface>, sync: bool) -> Result<(), WlSubsurfaceError> {
fn update_children_sync(surface: &Rc<WlSurface>, sync: bool) {
let children = surface.children.borrow();
if let Some(children) = &*children {
for child in children.subsurfaces.values() {
@ -44,7 +44,6 @@ fn update_children_sync(surface: &Rc<WlSurface>, sync: bool) -> Result<(), WlSub
}
}
}
Ok(())
}
fn update_children_attach(
@ -63,7 +62,7 @@ fn update_children_attach(
}
data.sync_ancestor = sync;
let sync = data.sync_ancestor || data.sync_requested;
update_children_attach(child, sync, depth + 1);
update_children_attach(child, sync, depth + 1)?;
}
}
}

View file

@ -24,17 +24,16 @@ const ACK_CONFIGURE: u32 = 4;
const CONFIGURE: u32 = 0;
const NOT_CONSTRUCTED: u32 = 1;
#[allow(dead_code)] const NOT_CONSTRUCTED: u32 = 1;
const ALREADY_CONSTRUCTED: u32 = 2;
const UNCONFIGURED_BUFFER: u32 = 3;
#[allow(dead_code)] const UNCONFIGURED_BUFFER: u32 = 3;
id!(XdgSurfaceId);
pub struct XdgSurface {
id: XdgSurfaceId,
wm_base: Rc<XdgWmBaseObj>,
base: Rc<XdgWmBaseObj>,
pub surface: Rc<WlSurface>,
version: u32,
}
impl XdgSurface {
@ -42,13 +41,11 @@ impl XdgSurface {
wm_base: &Rc<XdgWmBaseObj>,
id: XdgSurfaceId,
surface: &Rc<WlSurface>,
version: u32,
) -> Self {
Self {
id,
wm_base: wm_base.clone(),
base: wm_base.clone(),
surface: surface.clone(),
version,
}
}
@ -64,6 +61,7 @@ impl XdgSurface {
if !matches!(old_role, SurfaceRole::None | SurfaceRole::XdgSurface) {
return Err(XdgSurfaceError::IncompatibleRole(self.surface.id, old_role));
}
self.surface.role.set(SurfaceRole::XdgSurface);
let mut data = self.surface.role_data.borrow_mut();
if data.is_some() {
return Err(XdgSurfaceError::AlreadyAttached(self.surface.id));
@ -101,7 +99,7 @@ impl XdgSurface {
}
*data = RoleData::None;
}
self.wm_base.surfaces.remove(&self.id);
self.base.surfaces.remove(&self.id);
self.surface.client.remove_obj(self).await?;
Ok(())
}
@ -128,7 +126,7 @@ impl XdgSurface {
return Err(GetToplevelError::AlreadyConstructed);
}
data.role = XdgSurfaceRole::Toplevel;
let toplevel = Rc::new(XdgToplevel::new(req.id, self, self.version));
let toplevel = Rc::new(XdgToplevel::new(req.id, self));
self.surface.client.add_client_obj(&toplevel)?;
data.role_data = XdgSurfaceRoleData::Toplevel(XdgToplevelData {
toplevel,
@ -161,7 +159,7 @@ impl XdgSurface {
return Err(GetPopupError::AlreadyConstructed);
}
data.role = XdgSurfaceRole::Popup;
let popup = Rc::new(XdgPopup::new(req.id, self, self.version));
let popup = Rc::new(XdgPopup::new(req.id, self));
self.surface.client.add_client_obj(&popup)?;
if let Some(parent) = &parent {
let mut data = parent.surface.role_data.borrow_mut();
@ -169,7 +167,7 @@ impl XdgSurface {
xdg.popups.set(self.surface.id, popup.clone());
}
}
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { popup, parent });
data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { _popup: popup, parent });
}
Ok(())
}

View file

@ -15,22 +15,20 @@ const CONFIGURE: u32 = 0;
const POPUP_DONE: u32 = 1;
const REPOSITIONED: u32 = 2;
const INVALID_GRAB: u32 = 1;
#[allow(dead_code)] const INVALID_GRAB: u32 = 1;
id!(XdgPopupId);
pub struct XdgPopup {
id: XdgPopupId,
pub(in super::super) surface: Rc<XdgSurface>,
version: u32,
}
impl XdgPopup {
pub fn new(id: XdgPopupId, surface: &Rc<XdgSurface>, version: u32) -> Self {
pub fn new(id: XdgPopupId, surface: &Rc<XdgSurface>) -> Self {
Self {
id,
surface: surface.clone(),
version,
}
}

View file

@ -40,29 +40,27 @@ pub enum ResizeEdge {
BottomRight = 10,
}
const STATE_MAXIMIZED: u32 = 1;
const STATE_FULLSCREEN: u32 = 2;
const STATE_RESIZING: u32 = 3;
const STATE_ACTIVATED: u32 = 4;
const STATE_TILED_LEFT: u32 = 5;
const STATE_TILED_RIGHT: u32 = 6;
const STATE_TILED_TOP: u32 = 7;
const STATE_TILED_BOTTOM: u32 = 8;
#[allow(dead_code)] const STATE_MAXIMIZED: u32 = 1;
#[allow(dead_code)] const STATE_FULLSCREEN: u32 = 2;
#[allow(dead_code)] const STATE_RESIZING: u32 = 3;
#[allow(dead_code)] const STATE_ACTIVATED: u32 = 4;
#[allow(dead_code)] const STATE_TILED_LEFT: u32 = 5;
#[allow(dead_code)] const STATE_TILED_RIGHT: u32 = 6;
#[allow(dead_code)] const STATE_TILED_TOP: u32 = 7;
#[allow(dead_code)] const STATE_TILED_BOTTOM: u32 = 8;
id!(XdgToplevelId);
pub struct XdgToplevel {
id: XdgToplevelId,
pub surface: Rc<XdgSurface>,
version: u32,
}
impl XdgToplevel {
pub fn new(id: XdgToplevelId, surface: &Rc<XdgSurface>, version: u32) -> Self {
pub fn new(id: XdgToplevelId, surface: &Rc<XdgSurface>) -> Self {
Self {
id,
surface: surface.clone(),
version,
}
}