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

@ -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,
}
}