shell: Restore fullscreen surface to stack
Previously, a surface that was in a stack that is fullscreened would be removed from the stack, and on unfullscreening, restored to the floating/tiling layer as though it were a new window outside the stack. Instead, if the stack still exists, add the window to it at the same position it previously occupied.
This commit is contained in:
parent
f765696834
commit
9e6d46c17e
2 changed files with 42 additions and 23 deletions
|
|
@ -2592,9 +2592,21 @@ impl Shell {
|
||||||
pub fn remap_unfullscreened_window(
|
pub fn remap_unfullscreened_window(
|
||||||
&mut self,
|
&mut self,
|
||||||
surface: CosmicSurface,
|
surface: CosmicSurface,
|
||||||
state: Option<FullscreenRestoreState>,
|
mut state: Option<FullscreenRestoreState>,
|
||||||
loop_handle: &LoopHandle<'static, State>,
|
loop_handle: &LoopHandle<'static, State>,
|
||||||
) -> CosmicMapped {
|
) -> CosmicMapped {
|
||||||
|
if let Some(FullscreenRestoreState::Stack { state: stack_state }) = &state {
|
||||||
|
if let Some(mapped) = self.mapped().find(|m| **m == stack_state.stack)
|
||||||
|
&& let Some(stack) = mapped.stack_ref()
|
||||||
|
{
|
||||||
|
let idx = stack_state.idx.min(stack.len());
|
||||||
|
stack.add_window(surface, Some(idx), None);
|
||||||
|
return mapped.clone();
|
||||||
|
} else {
|
||||||
|
state = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let window = CosmicMapped::from(CosmicWindow::new(
|
let window = CosmicMapped::from(CosmicWindow::new(
|
||||||
surface,
|
surface,
|
||||||
loop_handle.clone(),
|
loop_handle.clone(),
|
||||||
|
|
@ -2637,7 +2649,9 @@ impl Shell {
|
||||||
workspace
|
workspace
|
||||||
}
|
}
|
||||||
None => self.workspaces.active_mut(&seat.active_output()).unwrap(),
|
None => self.workspaces.active_mut(&seat.active_output()).unwrap(),
|
||||||
Some(FullscreenRestoreState::Sticky { .. }) => unreachable!(),
|
Some(FullscreenRestoreState::Sticky { .. } | FullscreenRestoreState::Stack { .. }) => {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let fullscreen_geometry = workspace.output.geometry().to_local(&workspace.output);
|
let fullscreen_geometry = workspace.output.geometry().to_local(&workspace.output);
|
||||||
|
|
||||||
|
|
@ -2752,7 +2766,9 @@ impl Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(FullscreenRestoreState::Sticky { .. }) => unreachable!(),
|
Some(FullscreenRestoreState::Sticky { .. } | FullscreenRestoreState::Stack { .. }) => {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window
|
window
|
||||||
|
|
@ -4878,6 +4894,9 @@ impl Shell {
|
||||||
state,
|
state,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
WorkspaceRestoreData::Stack(stack_state) => {
|
||||||
|
Some(FullscreenRestoreState::Stack { state: stack_state })
|
||||||
|
}
|
||||||
WorkspaceRestoreData::Fullscreen(_) => unreachable!(),
|
WorkspaceRestoreData::Fullscreen(_) => unreachable!(),
|
||||||
},
|
},
|
||||||
Some(from),
|
Some(from),
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ use wayland_backend::server::ClientId;
|
||||||
use super::{
|
use super::{
|
||||||
CosmicMappedRenderElement, CosmicSurface, ResizeDirection, ResizeMode,
|
CosmicMappedRenderElement, CosmicSurface, ResizeDirection, ResizeMode,
|
||||||
element::{
|
element::{
|
||||||
CosmicMapped, MaximizedState, resize_indicator::ResizeIndicator,
|
CosmicMapped, CosmicMappedKey, MaximizedState, resize_indicator::ResizeIndicator,
|
||||||
stack::CosmicStackRenderElement, swap_indicator::SwapIndicator,
|
stack::CosmicStackRenderElement, swap_indicator::SwapIndicator,
|
||||||
window::CosmicWindowRenderElement,
|
window::CosmicWindowRenderElement,
|
||||||
},
|
},
|
||||||
|
|
@ -263,6 +263,9 @@ pub enum FullscreenRestoreState {
|
||||||
output: WeakOutput,
|
output: WeakOutput,
|
||||||
state: FloatingRestoreData,
|
state: FloatingRestoreData,
|
||||||
},
|
},
|
||||||
|
Stack {
|
||||||
|
state: StackRestoreData,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FullscreenRestoreState {
|
impl FullscreenRestoreState {
|
||||||
|
|
@ -271,6 +274,7 @@ impl FullscreenRestoreState {
|
||||||
FullscreenRestoreState::Floating { state, .. }
|
FullscreenRestoreState::Floating { state, .. }
|
||||||
| FullscreenRestoreState::Sticky { state, .. } => state.was_maximized,
|
| FullscreenRestoreState::Sticky { state, .. } => state.was_maximized,
|
||||||
FullscreenRestoreState::Tiling { state, .. } => state.was_maximized,
|
FullscreenRestoreState::Tiling { state, .. } => state.was_maximized,
|
||||||
|
FullscreenRestoreState::Stack { .. } => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -280,16 +284,7 @@ pub enum WorkspaceRestoreData {
|
||||||
Fullscreen(Option<FullscreenRestoreData>),
|
Fullscreen(Option<FullscreenRestoreData>),
|
||||||
Tiling(Option<TilingRestoreData>),
|
Tiling(Option<TilingRestoreData>),
|
||||||
Floating(Option<FloatingRestoreData>),
|
Floating(Option<FloatingRestoreData>),
|
||||||
}
|
Stack(StackRestoreData),
|
||||||
|
|
||||||
impl From<ManagedLayer> for WorkspaceRestoreData {
|
|
||||||
fn from(value: ManagedLayer) -> Self {
|
|
||||||
match value {
|
|
||||||
ManagedLayer::Floating | ManagedLayer::Sticky => WorkspaceRestoreData::Floating(None),
|
|
||||||
ManagedLayer::Tiling => WorkspaceRestoreData::Tiling(None),
|
|
||||||
ManagedLayer::Fullscreen => WorkspaceRestoreData::Fullscreen(None),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -321,6 +316,12 @@ pub struct TilingRestoreData {
|
||||||
pub was_maximized: bool,
|
pub was_maximized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct StackRestoreData {
|
||||||
|
pub stack: CosmicMappedKey,
|
||||||
|
pub idx: usize,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FullscreenRestoreData {
|
pub struct FullscreenRestoreData {
|
||||||
pub previous_state: FullscreenRestoreState,
|
pub previous_state: FullscreenRestoreState,
|
||||||
|
|
@ -716,15 +717,14 @@ impl Workspace {
|
||||||
if let Some(stack) = mapped.stack_ref()
|
if let Some(stack) = mapped.stack_ref()
|
||||||
&& stack.len() > 1
|
&& stack.len() > 1
|
||||||
{
|
{
|
||||||
let idx = stack.surfaces().position(|s| &s == surface);
|
let idx = stack.surfaces().position(|s| &s == surface)?;
|
||||||
let layer = if self.is_tiled(surface) {
|
return Some((
|
||||||
ManagedLayer::Tiling
|
stack.remove_idx(idx)?,
|
||||||
} else {
|
WorkspaceRestoreData::Stack(StackRestoreData {
|
||||||
ManagedLayer::Floating
|
stack: mapped.key(),
|
||||||
};
|
idx,
|
||||||
return idx
|
}),
|
||||||
.and_then(|idx| stack.remove_idx(idx))
|
));
|
||||||
.map(|s| (s, layer.into()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we know mapped is no stack with more than one element now,
|
// we know mapped is no stack with more than one element now,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue