tree: make surface visibility tracking more robust
This commit is contained in:
parent
be0935c8dd
commit
ba98103233
26 changed files with 313 additions and 144 deletions
|
|
@ -125,9 +125,20 @@ impl Cursor for CursorSurface {
|
|||
|
||||
fn handle_set(self: Rc<Self>) {
|
||||
self.surface.cursors.insert(self.seat.id(), self.clone());
|
||||
if self.surface.cursors.is_not_empty() {
|
||||
self.surface
|
||||
.set_visible(self.surface.client.state.root_visible());
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_unset(&self) {
|
||||
self.surface.cursors.remove(&self.seat.id());
|
||||
if self.surface.cursors.is_empty() {
|
||||
self.surface.set_visible(false);
|
||||
}
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.set_visible(visible);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl ExtSessionLockSurfaceV1 {
|
|||
if let Some(output) = &self.output {
|
||||
if let Some(ls) = output.lock_surface.get() {
|
||||
if ls.node_id == self.node_id {
|
||||
output.lock_surface.take();
|
||||
output.set_lock_surface(None);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ pub struct WlSubsurface {
|
|||
latest_node: CloneCell<Option<NodeRef<StackElement>>>,
|
||||
depth: NumCell<u32>,
|
||||
pub tracker: Tracker<Self>,
|
||||
had_buffer: Cell<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -102,6 +103,7 @@ impl WlSubsurface {
|
|||
latest_node: Default::default(),
|
||||
depth: NumCell::new(0),
|
||||
tracker: Default::default(),
|
||||
had_buffer: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,6 +180,7 @@ impl WlSubsurface {
|
|||
}
|
||||
}
|
||||
self.surface.client.remove_obj(self)?;
|
||||
self.surface.destroy_node();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -344,6 +347,16 @@ impl SurfaceExt for WlSubsurface {
|
|||
self.parent.need_extents_update.set(true);
|
||||
}
|
||||
}
|
||||
let has_buffer = self.surface.buffer.is_some();
|
||||
if self.had_buffer.replace(has_buffer) != has_buffer {
|
||||
if has_buffer {
|
||||
if self.parent.visible.get() {
|
||||
self.surface.set_visible(true);
|
||||
}
|
||||
} else {
|
||||
self.surface.destroy_node();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn subsurface_parent(&self) -> Option<Rc<WlSurface>> {
|
||||
|
|
|
|||
|
|
@ -436,6 +436,10 @@ impl StackedNode for Xwindow {
|
|||
fn stacked_set_visible(&self, visible: bool) {
|
||||
self.tl_set_visible(visible);
|
||||
}
|
||||
|
||||
fn stacked_has_workspace_link(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ impl XdgSurface {
|
|||
|
||||
fn detach_node(&self) {
|
||||
self.workspace.set(None);
|
||||
self.surface.detach_node();
|
||||
self.surface.detach_node(false);
|
||||
let popups = self.popups.lock();
|
||||
for popup in popups.values() {
|
||||
popup.detach_node();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ pub struct XdgPopup {
|
|||
pos: RefCell<XdgPositioned>,
|
||||
pub tracker: Tracker<Self>,
|
||||
seat_state: NodeSeatState,
|
||||
set_visible_prepared: Cell<bool>,
|
||||
}
|
||||
|
||||
impl Debug for XdgPopup {
|
||||
|
|
@ -77,6 +78,7 @@ impl XdgPopup {
|
|||
pos: RefCell::new(pos),
|
||||
tracker: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
set_visible_prepared: Cell::new(false),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -243,6 +245,7 @@ impl XdgPopup {
|
|||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set visible = {}", visible);
|
||||
self.set_visible_prepared.set(false);
|
||||
self.xdg.set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
|
@ -340,8 +343,20 @@ impl Node for XdgPopup {
|
|||
impl StackedNode for XdgPopup {
|
||||
stacked_node_impl!();
|
||||
|
||||
fn stacked_prepare_set_visible(&self) {
|
||||
self.set_visible_prepared.set(true);
|
||||
}
|
||||
|
||||
fn stacked_needs_set_visible(&self) -> bool {
|
||||
self.set_visible_prepared.get()
|
||||
}
|
||||
|
||||
fn stacked_set_visible(&self, visible: bool) {
|
||||
self.xdg.set_visible(visible);
|
||||
self.set_visible(visible);
|
||||
}
|
||||
|
||||
fn stacked_has_workspace_link(&self) -> bool {
|
||||
self.workspace_link.borrow().is_some()
|
||||
}
|
||||
|
||||
fn stacked_absolute_position_constrains_input(&self) -> bool {
|
||||
|
|
|
|||
|
|
@ -389,6 +389,7 @@ impl XdgToplevel {
|
|||
}
|
||||
self.toplevel_data.detach_node(self);
|
||||
self.xdg.detach_node();
|
||||
self.tl_set_visible(self.state.root_visible());
|
||||
}
|
||||
|
||||
pub fn after_toplevel_drag(self: &Rc<Self>, output: &Rc<OutputNode>, x: i32, y: i32) {
|
||||
|
|
|
|||
|
|
@ -351,6 +351,7 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
|
||||
fn after_apply_commit(self: Rc<Self>, _pending: &mut PendingState) {
|
||||
let buffer_is_some = self.surface.buffer.is_some();
|
||||
let was_mapped = self.mapped.get();
|
||||
if self.mapped.get() {
|
||||
if !buffer_is_some {
|
||||
self.destroy_node();
|
||||
|
|
@ -367,6 +368,9 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
self.mapped.set(true);
|
||||
self.compute_position();
|
||||
}
|
||||
if self.mapped.get() != was_mapped {
|
||||
self.output.update_visible();
|
||||
}
|
||||
if self.mapped.get() {
|
||||
match self.keyboard_interactivity.get() {
|
||||
KI_NONE => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue