autocommit 2022-02-04 16:52:11 CET
This commit is contained in:
parent
bb1639a2ae
commit
89bfd2ffcd
21 changed files with 599 additions and 46 deletions
|
|
@ -84,8 +84,8 @@ pub struct WlSurface {
|
|||
input_region: Cell<Option<Region>>,
|
||||
opaque_region: Cell<Option<Region>>,
|
||||
pub extents: Cell<Rect>,
|
||||
pub buffer_abs_pos: Cell<Rect>,
|
||||
pub need_extents_update: Cell<bool>,
|
||||
pub effective_extents: Cell<Rect>,
|
||||
pub buffer: CloneCell<Option<Rc<WlBuffer>>>,
|
||||
pub buf_x: NumCell<i32>,
|
||||
pub buf_y: NumCell<i32>,
|
||||
|
|
@ -179,8 +179,8 @@ impl WlSurface {
|
|||
input_region: Cell::new(None),
|
||||
opaque_region: Cell::new(None),
|
||||
extents: Default::default(),
|
||||
buffer_abs_pos: Cell::new(Default::default()),
|
||||
need_extents_update: Cell::new(false),
|
||||
effective_extents: Default::default(),
|
||||
buffer: CloneCell::new(None),
|
||||
buf_x: Default::default(),
|
||||
buf_y: Default::default(),
|
||||
|
|
@ -193,6 +193,18 @@ impl WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_absolute_position(&self, x1: i32, y1: i32) {
|
||||
self.buffer_abs_pos
|
||||
.set(self.buffer_abs_pos.get().at_point(x1, y1));
|
||||
if let Some(children) = self.children.borrow_mut().deref_mut() {
|
||||
for ss in children.subsurfaces.values() {
|
||||
let pos = ss.position.get();
|
||||
ss.surface
|
||||
.set_absolute_position(x1 + pos.x1(), y1 + pos.y1());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_cursor(&self) -> bool {
|
||||
self.role.get() == SurfaceRole::Cursor
|
||||
}
|
||||
|
|
@ -405,6 +417,12 @@ impl WlSurface {
|
|||
if let Some((dx, dy, buffer)) = buffer_change {
|
||||
let _ = buffer.update_texture();
|
||||
new_size = Some(buffer.rect);
|
||||
self.buffer_abs_pos.set(
|
||||
self.buffer_abs_pos
|
||||
.get()
|
||||
.with_size(buffer.rect.width(), buffer.rect.height())
|
||||
.unwrap(),
|
||||
);
|
||||
self.buffer.set(Some(buffer));
|
||||
self.buf_x.fetch_add(dx);
|
||||
self.buf_y.fetch_add(dy);
|
||||
|
|
@ -596,6 +614,10 @@ impl Node for WlSurface {
|
|||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.buffer_abs_pos.get()
|
||||
}
|
||||
|
||||
fn active_changed(&self, active: bool) {
|
||||
if let Some(xdg) = self.xdg.get() {
|
||||
xdg.surface_active_changed(active);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,19 @@ impl XdgSurface {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_absolute_desired_extents(&self, ext: &Rect) {
|
||||
let prev = self.absolute_desired_extents.replace(*ext);
|
||||
if ext.x1() != prev.x1() || ext.y1() != prev.y1() {
|
||||
let (mut x1, mut y1) = (ext.x1(), ext.y1());
|
||||
if let Some(geo) = self.geometry.get() {
|
||||
x1 -= geo.x1();
|
||||
y1 -= geo.y1();
|
||||
}
|
||||
self.surface.set_absolute_position(x1, y1);
|
||||
self.update_popup_positions();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn surface_active_changed(&self, active: bool) {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.surface_active_changed(active);
|
||||
|
|
@ -331,7 +344,6 @@ impl XdgSurface {
|
|||
let popups = self.popups.lock();
|
||||
for popup in popups.values() {
|
||||
popup.update_absolute_position();
|
||||
popup.xdg.update_popup_positions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ impl XdgPopup {
|
|||
}
|
||||
}
|
||||
self.relative_position.set(rel_pos);
|
||||
self.xdg.absolute_desired_extents.set(abs_pos);
|
||||
self.xdg.set_absolute_desired_extents(&abs_pos);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -182,8 +182,7 @@ impl XdgPopup {
|
|||
let rel = self.relative_position.get();
|
||||
let parent = parent.absolute_desired_extents.get();
|
||||
self.xdg
|
||||
.absolute_desired_extents
|
||||
.set(rel.move_(parent.x1(), parent.y1()));
|
||||
.set_absolute_desired_extents(&rel.move_(parent.x1(), parent.y1()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,12 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn set_parent(&self, parser: MsgParser<'_, '_>) -> Result<(), SetParentError> {
|
||||
let _req: SetParent = self.xdg.surface.client.parse(self, parser)?;
|
||||
let req: SetParent = self.xdg.surface.client.parse(self, parser)?;
|
||||
let mut parent = None;
|
||||
if req.parent.is_some() {
|
||||
parent = Some(self.xdg.surface.client.get_xdg_toplevel(req.parent)?);
|
||||
}
|
||||
self.parent.set(parent);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -329,6 +334,7 @@ impl XdgToplevel {
|
|||
self.xdg.set_workspace(&workspace);
|
||||
let output = workspace.output.get();
|
||||
let output_rect = output.position.get();
|
||||
log::info!("or = {:?}", output_rect);
|
||||
let position = {
|
||||
let extents = self.xdg.extents.get().to_origin();
|
||||
let width = extents.width();
|
||||
|
|
@ -343,6 +349,7 @@ impl XdgToplevel {
|
|||
}
|
||||
Rect::new_sized(x1, y1, width, height).unwrap()
|
||||
};
|
||||
log::info!("pos = {:?}", position);
|
||||
let state = &self.xdg.surface.client.state;
|
||||
let floater = Rc::new(FloatNode {
|
||||
id: state.node_ids.next(),
|
||||
|
|
@ -365,6 +372,7 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn map_tiled(self: &Rc<Self>) {
|
||||
log::info!("map tiled");
|
||||
let state = &self.xdg.surface.client.state;
|
||||
let seat = state.seat_queue.last();
|
||||
if let Some(seat) = seat {
|
||||
|
|
@ -472,7 +480,7 @@ impl Node for XdgToplevel {
|
|||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.replace(*rect);
|
||||
let de = self.xdg.absolute_desired_extents.get();
|
||||
if de.width() != nw || de.height() != nh {
|
||||
self.xdg
|
||||
.surface
|
||||
|
|
@ -481,9 +489,7 @@ impl Node for XdgToplevel {
|
|||
self.xdg.send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
if de.x1() != rect.x1() || de.y1() != rect.y1() {
|
||||
self.xdg.update_popup_positions();
|
||||
}
|
||||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue