Skip to content

Commit

Permalink
shell: Set xdg_shell v4 bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Apr 5, 2023
1 parent bc49507 commit 8f6ad62
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/shell/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ impl CosmicMapped {
}
}

pub fn set_bounds(&self, size: impl Into<Option<Size<i32, Logical>>>) {
let size = size.into();
for (surface, _) in self.windows() {
surface.set_bounds(size.clone())
}
}

pub fn configure(&self) {
for window in match &self.element {
CosmicMappedInternal::Stack(s) => {
Expand Down
9 changes: 9 additions & 0 deletions src/shell/element/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ impl CosmicSurface {
}
}

pub fn set_bounds(&self, size: impl Into<Option<Size<i32, Logical>>>) {
match self {
CosmicSurface::Wayland(window) => window.toplevel().with_pending_state(|state| {
state.bounds = size.into();
}),
_ => {}
}
}

pub fn is_activated(&self) -> bool {
match self {
CosmicSurface::Wayland(window) => window
Expand Down
1 change: 1 addition & 0 deletions src/shell/layout/floating/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl FloatingLayout {

let layers = layer_map_for_output(&output);
let geometry = layers.non_exclusive_zone();
mapped.set_bounds(geometry.size);
let last_geometry = mapped.last_geometry.lock().unwrap().clone();

if let Some(size) = last_geometry.map(|g| g.size) {
Expand Down
1 change: 1 addition & 0 deletions src/shell/layout/tiling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ impl TilingLayout {
) {
let output = seat.active_output();
window.output_enter(&output, window.bbox());
window.set_bounds(output.geometry().size);
self.map_internal(window, &output, Some(focus_stack));
self.refresh();
}
Expand Down

0 comments on commit 8f6ad62

Please sign in to comment.