shell: implement minimize
This commit is contained in:
parent
fffae1491d
commit
3eb7e5f82e
20 changed files with 1185 additions and 307 deletions
|
|
@ -379,6 +379,16 @@ impl CosmicMapped {
|
|||
window.is_activated(pending)
|
||||
}
|
||||
|
||||
pub fn is_minimized(&self) -> bool {
|
||||
self.active_window().is_minimized()
|
||||
}
|
||||
|
||||
pub fn set_minimized(&self, minimized: bool) {
|
||||
for (w, _) in self.windows() {
|
||||
w.set_minimized(minimized);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pending_size(&self) -> Option<Size<i32, Logical>> {
|
||||
match &self.element {
|
||||
CosmicMappedInternal::Stack(s) => s.pending_size(),
|
||||
|
|
|
|||
|
|
@ -725,11 +725,10 @@ impl Program for CosmicStackInternal {
|
|||
} else if let Some(workspace) =
|
||||
state.common.shell.space_for_mut(&mapped)
|
||||
{
|
||||
workspace
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(&workspace.output)
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
elem_geo.loc.to_global(&workspace.output)
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
|
@ -761,11 +760,10 @@ impl Program for CosmicStackInternal {
|
|||
state.common.shell.element_for_wl_surface(&surface).cloned()
|
||||
{
|
||||
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
||||
let position = workspace
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(&workspace.output);
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
let position = elem_geo.loc.to_global(&workspace.output);
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
use std::time::Duration;
|
||||
use std::{
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use smithay::{
|
||||
backend::renderer::{
|
||||
|
|
@ -70,6 +73,9 @@ impl From<X11Surface> for CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Minimized(AtomicBool);
|
||||
|
||||
pub const SSD_HEIGHT: i32 = 48;
|
||||
pub const RESIZE_BORDER: i32 = 10;
|
||||
|
||||
|
|
@ -351,6 +357,45 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_minimized(&self) -> bool {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(_) => self
|
||||
.0
|
||||
.user_data()
|
||||
.get_or_insert_threadsafe(Minimized::default)
|
||||
.0
|
||||
.load(Ordering::SeqCst),
|
||||
WindowSurface::X11(surface) => surface.is_minimized(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_minimized(&self, minimized: bool) {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(_) => self
|
||||
.0
|
||||
.user_data()
|
||||
.get_or_insert_threadsafe(Minimized::default)
|
||||
.0
|
||||
.store(minimized, Ordering::SeqCst),
|
||||
WindowSurface::X11(surface) => {
|
||||
let _ = surface.set_minimized(minimized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_suspended(&self, suspended: bool) {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(window) => window.with_pending_state(|state| {
|
||||
if suspended {
|
||||
state.states.set(ToplevelState::Suspended);
|
||||
} else {
|
||||
state.states.unset(ToplevelState::Suspended);
|
||||
}
|
||||
}),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn min_size(&self) -> Option<Size<i32, Logical>> {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(toplevel) => {
|
||||
|
|
|
|||
|
|
@ -290,7 +290,8 @@ impl Program for CosmicWindowInternal {
|
|||
if let Some(mapped) =
|
||||
state.common.shell.element_for_wl_surface(&surface).cloned()
|
||||
{
|
||||
state.common.shell.maximize_toggle(&mapped)
|
||||
let seat = state.common.last_active_seat().clone();
|
||||
state.common.shell.maximize_toggle(&mapped, &seat)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -315,11 +316,10 @@ impl Program for CosmicWindowInternal {
|
|||
} else if let Some(workspace) =
|
||||
state.common.shell.space_for_mut(&mapped)
|
||||
{
|
||||
workspace
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(&workspace.output)
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
elem_geo.loc.to_global(&workspace.output)
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue