shell: Unify mapping windows into stacks logic
This commit is contained in:
parent
c719b6bb3d
commit
835dbe45f3
5 changed files with 43 additions and 56 deletions
|
|
@ -124,7 +124,7 @@ pub fn tab_items(
|
|||
let focus_stack = workspace.focus_stack.get(&seat);
|
||||
workspace
|
||||
.tiling_layer
|
||||
.map(mapped, Some(focus_stack.iter()), None, false);
|
||||
.map(mapped, Some(focus_stack.iter()), None);
|
||||
} else {
|
||||
workspace.floating_layer.map(mapped, None)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ lazy_static::lazy_static! {
|
|||
]).unwrap();
|
||||
}
|
||||
|
||||
pub fn should_be_floating(window: &CosmicSurface) -> bool {
|
||||
pub fn is_dialog(window: &CosmicSurface) -> bool {
|
||||
// Check "window type"
|
||||
match window {
|
||||
CosmicSurface::Wayland(window) => {
|
||||
|
|
@ -136,6 +136,10 @@ pub fn should_be_floating(window: &CosmicSurface) -> bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
pub fn has_floating_exception(window: &CosmicSurface) -> bool {
|
||||
// else take a look at our exceptions
|
||||
let appid_matches = EXCEPTIONS_APPID.matches(&window.app_id());
|
||||
let title_matches = EXCEPTIONS_TITLE.matches(&window.title());
|
||||
|
|
|
|||
|
|
@ -367,11 +367,10 @@ impl TilingLayout {
|
|||
window: CosmicMapped,
|
||||
focus_stack: Option<impl Iterator<Item = &'a CosmicMapped> + 'a>,
|
||||
direction: Option<Direction>,
|
||||
add_to_stack: bool,
|
||||
) {
|
||||
window.output_enter(&self.output, window.bbox());
|
||||
window.set_bounds(self.output.geometry().size.as_logical());
|
||||
self.map_internal(window, focus_stack, direction, add_to_stack);
|
||||
self.map_internal(window, focus_stack, direction);
|
||||
}
|
||||
|
||||
pub fn map_internal<'a>(
|
||||
|
|
@ -379,21 +378,13 @@ impl TilingLayout {
|
|||
window: impl Into<CosmicMapped>,
|
||||
focus_stack: Option<impl Iterator<Item = &'a CosmicMapped> + 'a>,
|
||||
direction: Option<Direction>,
|
||||
add_to_stack: bool,
|
||||
) {
|
||||
let gaps = self.gaps();
|
||||
|
||||
let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
|
||||
let last_active = focus_stack
|
||||
.and_then(|focus_stack| TilingLayout::last_active_window(&mut tree, focus_stack));
|
||||
TilingLayout::map_to_tree(
|
||||
&mut tree,
|
||||
window,
|
||||
&self.output,
|
||||
last_active,
|
||||
direction,
|
||||
add_to_stack,
|
||||
);
|
||||
TilingLayout::map_to_tree(&mut tree, window, &self.output, last_active, direction);
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||
}
|
||||
|
|
@ -404,7 +395,6 @@ impl TilingLayout {
|
|||
output: &Output,
|
||||
node: Option<(NodeId, CosmicMapped)>,
|
||||
direction: Option<Direction>,
|
||||
add_to_stack: bool,
|
||||
) {
|
||||
let window = window.into();
|
||||
let new_window = Node::new(Data::Mapped {
|
||||
|
|
@ -434,16 +424,7 @@ impl TilingLayout {
|
|||
tree.insert(new_window, InsertBehavior::AsRoot).unwrap()
|
||||
}
|
||||
} else {
|
||||
if let Some((ref node_id, mut last_active_window)) = node {
|
||||
if add_to_stack && window.is_window() && last_active_window.is_stack() {
|
||||
let surface = window.active_window();
|
||||
last_active_window
|
||||
.stack_ref_mut()
|
||||
.unwrap()
|
||||
.add_window(surface, None);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some((ref node_id, _)) = node {
|
||||
let orientation = {
|
||||
let window_size = tree.get(node_id).unwrap().data().geometry().size;
|
||||
if window_size.w > window_size.h {
|
||||
|
|
@ -543,7 +524,7 @@ impl TilingLayout {
|
|||
}
|
||||
|
||||
mapped.set_tiled(true);
|
||||
other.map(mapped.clone(), Some(focus_stack), None, true);
|
||||
other.map(mapped.clone(), Some(focus_stack), None);
|
||||
return Some(KeyboardFocusTarget::Element(mapped));
|
||||
}
|
||||
None => {
|
||||
|
|
@ -1974,7 +1955,6 @@ impl TilingLayout {
|
|||
&self.output,
|
||||
Some(current_node),
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
let node = window.tiling_node_id.lock().unwrap().clone().unwrap();
|
||||
|
|
@ -2505,14 +2485,7 @@ impl TilingLayout {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
TilingLayout::map_to_tree(
|
||||
&mut tree,
|
||||
window.clone(),
|
||||
&self.output,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
TilingLayout::map_to_tree(&mut tree, window.clone(), &self.output, None, None);
|
||||
window
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1587,12 +1587,11 @@ impl Shell {
|
|||
.map(mapped, None)
|
||||
}
|
||||
ManagedLayer::Floating => new_workspace.floating_layer.map(mapped, None),
|
||||
ManagedLayer::Tiling => new_workspace.tiling_layer.map(
|
||||
mapped,
|
||||
Option::<std::iter::Empty<_>>::None,
|
||||
None,
|
||||
false,
|
||||
),
|
||||
ManagedLayer::Tiling => {
|
||||
new_workspace
|
||||
.tiling_layer
|
||||
.map(mapped, Option::<std::iter::Empty<_>>::None, None)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1714,6 +1713,26 @@ impl Shell {
|
|||
.toplevel_info_state
|
||||
.toplevel_enter_workspace(&window, &workspace.handle);
|
||||
|
||||
let workspace_output = workspace.output.clone();
|
||||
let was_activated = workspace_handle.is_some()
|
||||
&& (workspace_output != seat.active_output() || active_handle != workspace.handle);
|
||||
let workspace_handle = workspace.handle;
|
||||
let is_dialog = layout::is_dialog(&window);
|
||||
let floating_exception = layout::has_floating_exception(&window);
|
||||
|
||||
let maybe_focused = workspace.focus_stack.get(&seat).iter().next().cloned();
|
||||
if let Some(focused) = maybe_focused {
|
||||
if (focused.is_stack() && !is_dialog && !should_be_fullscreen)
|
||||
&& !(workspace.is_tiled(&focused) && floating_exception)
|
||||
{
|
||||
focused.stack_ref().unwrap().add_window(window, None);
|
||||
if was_activated {
|
||||
state.common.shell.set_urgent(&workspace_handle);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let mapped = CosmicMapped::from(CosmicWindow::new(
|
||||
window.clone(),
|
||||
state.common.event_loop_handle.clone(),
|
||||
|
|
@ -1725,8 +1744,7 @@ impl Shell {
|
|||
}
|
||||
|
||||
let workspace_empty = workspace.mapped().next().is_none();
|
||||
|
||||
if layout::should_be_floating(&window) || !workspace.tiling_enabled {
|
||||
if is_dialog || floating_exception || !workspace.tiling_enabled {
|
||||
workspace.floating_layer.map(mapped.clone(), None);
|
||||
} else {
|
||||
for mapped in workspace
|
||||
|
|
@ -1741,17 +1759,13 @@ impl Shell {
|
|||
let focus_stack = workspace.focus_stack.get(&seat);
|
||||
workspace
|
||||
.tiling_layer
|
||||
.map(mapped.clone(), Some(focus_stack.iter()), None, true);
|
||||
.map(mapped.clone(), Some(focus_stack.iter()), None);
|
||||
}
|
||||
|
||||
if !parent_is_sticky && should_be_fullscreen {
|
||||
workspace.fullscreen_request(&mapped.active_window(), None);
|
||||
}
|
||||
|
||||
let was_activated = workspace_handle.is_some();
|
||||
let workspace_handle = workspace.handle;
|
||||
let workspace_output = workspace.output.clone();
|
||||
|
||||
if parent_is_sticky {
|
||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||
state
|
||||
|
|
@ -1923,7 +1937,6 @@ impl Shell {
|
|||
mapped.clone(),
|
||||
focus_stack.as_ref().map(|x| x.iter()),
|
||||
direction,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -2891,12 +2904,9 @@ impl Shell {
|
|||
}
|
||||
ManagedLayer::Tiling => {
|
||||
let focus_stack = workspace.focus_stack.get(seat);
|
||||
workspace.tiling_layer.map(
|
||||
mapped.clone(),
|
||||
Some(focus_stack.iter()),
|
||||
None,
|
||||
false,
|
||||
);
|
||||
workspace
|
||||
.tiling_layer
|
||||
.map(mapped.clone(), Some(focus_stack.iter()), None);
|
||||
}
|
||||
ManagedLayer::Sticky => unreachable!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ impl Workspace {
|
|||
{
|
||||
self.floating_layer.unmap(&window);
|
||||
self.tiling_layer
|
||||
.map(window, Some(focus_stack.iter()), None, false)
|
||||
.map(window, Some(focus_stack.iter()), None)
|
||||
}
|
||||
self.tiling_enabled = true;
|
||||
}
|
||||
|
|
@ -655,7 +655,7 @@ impl Workspace {
|
|||
let focus_stack = self.focus_stack.get(seat);
|
||||
self.floating_layer.unmap(&window);
|
||||
self.tiling_layer
|
||||
.map(window.clone(), Some(focus_stack.iter()), None, false)
|
||||
.map(window.clone(), Some(focus_stack.iter()), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue