shell: empty (un)minimize handlers

This commit is contained in:
Victoria Brekenfeld 2024-02-08 20:28:59 +01:00 committed by Victoria Brekenfeld
parent 3c3a5f2ccf
commit 068b70d4bc
4 changed files with 43 additions and 0 deletions

View file

@ -230,6 +230,7 @@ pub struct WorkspaceSet {
output: Output, output: Output,
theme: cosmic::Theme, theme: cosmic::Theme,
pub sticky_layer: FloatingLayout, pub sticky_layer: FloatingLayout,
pub minimized_windows: Vec<MinimizedWindow>,
pub workspaces: Vec<Workspace>, pub workspaces: Vec<Workspace>,
} }
@ -351,6 +352,7 @@ impl WorkspaceSet {
tiling_enabled, tiling_enabled,
theme, theme,
sticky_layer, sticky_layer,
minimized_windows: Vec::new(),
workspaces, workspaces,
output: output.clone(), output: output.clone(),
} }
@ -978,6 +980,7 @@ impl Shell {
[ [
WmCapabilities::Fullscreen, WmCapabilities::Fullscreen,
WmCapabilities::Maximize, WmCapabilities::Maximize,
WmCapabilities::Minimize,
WmCapabilities::WindowMenu, WmCapabilities::WindowMenu,
], ],
); );
@ -2618,6 +2621,10 @@ impl Shell {
} }
} }
pub fn minimize_request(&mut self, mapped: &CosmicMapped) {}
pub fn unminimize_request(&mut self, mapped: &CosmicMapped) {}
pub fn maximize_request(&mut self, mapped: &CosmicMapped) { pub fn maximize_request(&mut self, mapped: &CosmicMapped) {
let (original_layer, floating_layer, original_geometry) = if let Some(set) = self let (original_layer, floating_layer, original_geometry) = if let Some(set) = self
.workspaces .workspaces

View file

@ -77,6 +77,7 @@ pub struct Workspace {
pub output: Output, pub output: Output,
pub tiling_layer: TilingLayout, pub tiling_layer: TilingLayout,
pub floating_layer: FloatingLayout, pub floating_layer: FloatingLayout,
pub minimized_windows: Vec<MinimizedWindow>,
pub tiling_enabled: bool, pub tiling_enabled: bool,
pub fullscreen: Option<FullscreenSurface>, pub fullscreen: Option<FullscreenSurface>,
@ -90,6 +91,15 @@ pub struct Workspace {
pub dirty: AtomicBool, pub dirty: AtomicBool,
} }
#[derive(Debug)]
pub struct MinimizedWindow {
pub window: CosmicMapped,
pub previous_layer: ManagedLayer,
pub was_fullscreen: Option<FullscreenSurface>,
pub was_maximized: bool,
pub tiling_state: Option<(id_tree::NodeId, Rectangle<i32, Logical>)>,
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct FullscreenSurface { pub struct FullscreenSurface {
pub surface: CosmicSurface, pub surface: CosmicSurface,
@ -222,6 +232,7 @@ impl Workspace {
tiling_layer, tiling_layer,
floating_layer, floating_layer,
tiling_enabled, tiling_enabled,
minimized_windows: Vec::new(),
fullscreen: None, fullscreen: None,
handle, handle,
focus_stack: FocusStacks::default(), focus_stack: FocusStacks::default(),

View file

@ -162,6 +162,17 @@ impl XdgShellHandler for State {
Shell::resize_request(self, surface.wl_surface(), &seat, serial, edges.into()) Shell::resize_request(self, surface.wl_surface(), &seat, serial, edges.into())
} }
fn minimize_request(&mut self, surface: ToplevelSurface) {
if let Some(mapped) = self
.common
.shell
.element_for_wl_surface(surface.wl_surface())
.cloned()
{
self.common.shell.minimize_request(&mapped)
}
}
fn maximize_request(&mut self, surface: ToplevelSurface) { fn maximize_request(&mut self, surface: ToplevelSurface) {
if let Some(mapped) = self if let Some(mapped) = self
.common .common

View file

@ -426,6 +426,20 @@ impl XwmHandler for State {
} }
} }
fn minimize_request(&mut self, _xwm: XwmId, window: X11Surface) {
let surface = CosmicSurface::X11(window);
if let Some(mapped) = self.common.shell.element_for_surface(&surface).cloned() {
self.common.shell.minimize_request(&mapped);
}
}
fn unminimize_request(&mut self, _xwm: XwmId, window: X11Surface) {
let surface = CosmicSurface::X11(window);
if let Some(mapped) = self.common.shell.element_for_surface(&surface).cloned() {
self.common.shell.unminimize_request(&mapped);
}
}
fn fullscreen_request(&mut self, _xwm: XwmId, window: X11Surface) { fn fullscreen_request(&mut self, _xwm: XwmId, window: X11Surface) {
if let Some(mapped) = self.common.shell.element_for_x11_surface(&window).cloned() { if let Some(mapped) = self.common.shell.element_for_x11_surface(&window).cloned() {
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) { if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {