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);
|
let focus_stack = workspace.focus_stack.get(&seat);
|
||||||
workspace
|
workspace
|
||||||
.tiling_layer
|
.tiling_layer
|
||||||
.map(mapped, Some(focus_stack.iter()), None, false);
|
.map(mapped, Some(focus_stack.iter()), None);
|
||||||
} else {
|
} else {
|
||||||
workspace.floating_layer.map(mapped, None)
|
workspace.floating_layer.map(mapped, None)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ lazy_static::lazy_static! {
|
||||||
]).unwrap();
|
]).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn should_be_floating(window: &CosmicSurface) -> bool {
|
pub fn is_dialog(window: &CosmicSurface) -> bool {
|
||||||
// Check "window type"
|
// Check "window type"
|
||||||
match window {
|
match window {
|
||||||
CosmicSurface::Wayland(window) => {
|
CosmicSurface::Wayland(window) => {
|
||||||
|
|
@ -136,6 +136,10 @@ pub fn should_be_floating(window: &CosmicSurface) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_floating_exception(window: &CosmicSurface) -> bool {
|
||||||
// else take a look at our exceptions
|
// else take a look at our exceptions
|
||||||
let appid_matches = EXCEPTIONS_APPID.matches(&window.app_id());
|
let appid_matches = EXCEPTIONS_APPID.matches(&window.app_id());
|
||||||
let title_matches = EXCEPTIONS_TITLE.matches(&window.title());
|
let title_matches = EXCEPTIONS_TITLE.matches(&window.title());
|
||||||
|
|
|
||||||
|
|
@ -367,11 +367,10 @@ impl TilingLayout {
|
||||||
window: CosmicMapped,
|
window: CosmicMapped,
|
||||||
focus_stack: Option<impl Iterator<Item = &'a CosmicMapped> + 'a>,
|
focus_stack: Option<impl Iterator<Item = &'a CosmicMapped> + 'a>,
|
||||||
direction: Option<Direction>,
|
direction: Option<Direction>,
|
||||||
add_to_stack: bool,
|
|
||||||
) {
|
) {
|
||||||
window.output_enter(&self.output, window.bbox());
|
window.output_enter(&self.output, window.bbox());
|
||||||
window.set_bounds(self.output.geometry().size.as_logical());
|
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>(
|
pub fn map_internal<'a>(
|
||||||
|
|
@ -379,21 +378,13 @@ impl TilingLayout {
|
||||||
window: impl Into<CosmicMapped>,
|
window: impl Into<CosmicMapped>,
|
||||||
focus_stack: Option<impl Iterator<Item = &'a CosmicMapped> + 'a>,
|
focus_stack: Option<impl Iterator<Item = &'a CosmicMapped> + 'a>,
|
||||||
direction: Option<Direction>,
|
direction: Option<Direction>,
|
||||||
add_to_stack: bool,
|
|
||||||
) {
|
) {
|
||||||
let gaps = self.gaps();
|
let gaps = self.gaps();
|
||||||
|
|
||||||
let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
|
let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
|
||||||
let last_active = focus_stack
|
let last_active = focus_stack
|
||||||
.and_then(|focus_stack| TilingLayout::last_active_window(&mut tree, focus_stack));
|
.and_then(|focus_stack| TilingLayout::last_active_window(&mut tree, focus_stack));
|
||||||
TilingLayout::map_to_tree(
|
TilingLayout::map_to_tree(&mut tree, window, &self.output, last_active, direction);
|
||||||
&mut tree,
|
|
||||||
window,
|
|
||||||
&self.output,
|
|
||||||
last_active,
|
|
||||||
direction,
|
|
||||||
add_to_stack,
|
|
||||||
);
|
|
||||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||||
}
|
}
|
||||||
|
|
@ -404,7 +395,6 @@ impl TilingLayout {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
node: Option<(NodeId, CosmicMapped)>,
|
node: Option<(NodeId, CosmicMapped)>,
|
||||||
direction: Option<Direction>,
|
direction: Option<Direction>,
|
||||||
add_to_stack: bool,
|
|
||||||
) {
|
) {
|
||||||
let window = window.into();
|
let window = window.into();
|
||||||
let new_window = Node::new(Data::Mapped {
|
let new_window = Node::new(Data::Mapped {
|
||||||
|
|
@ -434,16 +424,7 @@ impl TilingLayout {
|
||||||
tree.insert(new_window, InsertBehavior::AsRoot).unwrap()
|
tree.insert(new_window, InsertBehavior::AsRoot).unwrap()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some((ref node_id, mut last_active_window)) = node {
|
if let Some((ref node_id, _)) = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
let orientation = {
|
let orientation = {
|
||||||
let window_size = tree.get(node_id).unwrap().data().geometry().size;
|
let window_size = tree.get(node_id).unwrap().data().geometry().size;
|
||||||
if window_size.w > window_size.h {
|
if window_size.w > window_size.h {
|
||||||
|
|
@ -543,7 +524,7 @@ impl TilingLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
mapped.set_tiled(true);
|
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));
|
return Some(KeyboardFocusTarget::Element(mapped));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
@ -1974,7 +1955,6 @@ impl TilingLayout {
|
||||||
&self.output,
|
&self.output,
|
||||||
Some(current_node),
|
Some(current_node),
|
||||||
None,
|
None,
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let node = window.tiling_node_id.lock().unwrap().clone().unwrap();
|
let node = window.tiling_node_id.lock().unwrap().clone().unwrap();
|
||||||
|
|
@ -2505,14 +2485,7 @@ impl TilingLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
TilingLayout::map_to_tree(
|
TilingLayout::map_to_tree(&mut tree, window.clone(), &self.output, None, None);
|
||||||
&mut tree,
|
|
||||||
window.clone(),
|
|
||||||
&self.output,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
window
|
window
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1587,12 +1587,11 @@ impl Shell {
|
||||||
.map(mapped, None)
|
.map(mapped, None)
|
||||||
}
|
}
|
||||||
ManagedLayer::Floating => new_workspace.floating_layer.map(mapped, None),
|
ManagedLayer::Floating => new_workspace.floating_layer.map(mapped, None),
|
||||||
ManagedLayer::Tiling => new_workspace.tiling_layer.map(
|
ManagedLayer::Tiling => {
|
||||||
mapped,
|
new_workspace
|
||||||
Option::<std::iter::Empty<_>>::None,
|
.tiling_layer
|
||||||
None,
|
.map(mapped, Option::<std::iter::Empty<_>>::None, None)
|
||||||
false,
|
}
|
||||||
),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1714,6 +1713,26 @@ impl Shell {
|
||||||
.toplevel_info_state
|
.toplevel_info_state
|
||||||
.toplevel_enter_workspace(&window, &workspace.handle);
|
.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(
|
let mapped = CosmicMapped::from(CosmicWindow::new(
|
||||||
window.clone(),
|
window.clone(),
|
||||||
state.common.event_loop_handle.clone(),
|
state.common.event_loop_handle.clone(),
|
||||||
|
|
@ -1725,8 +1744,7 @@ impl Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspace_empty = workspace.mapped().next().is_none();
|
let workspace_empty = workspace.mapped().next().is_none();
|
||||||
|
if is_dialog || floating_exception || !workspace.tiling_enabled {
|
||||||
if layout::should_be_floating(&window) || !workspace.tiling_enabled {
|
|
||||||
workspace.floating_layer.map(mapped.clone(), None);
|
workspace.floating_layer.map(mapped.clone(), None);
|
||||||
} else {
|
} else {
|
||||||
for mapped in workspace
|
for mapped in workspace
|
||||||
|
|
@ -1741,17 +1759,13 @@ impl Shell {
|
||||||
let focus_stack = workspace.focus_stack.get(&seat);
|
let focus_stack = workspace.focus_stack.get(&seat);
|
||||||
workspace
|
workspace
|
||||||
.tiling_layer
|
.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 {
|
if !parent_is_sticky && should_be_fullscreen {
|
||||||
workspace.fullscreen_request(&mapped.active_window(), None);
|
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 {
|
if parent_is_sticky {
|
||||||
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
let seats = state.common.seats().cloned().collect::<Vec<_>>();
|
||||||
state
|
state
|
||||||
|
|
@ -1923,7 +1937,6 @@ impl Shell {
|
||||||
mapped.clone(),
|
mapped.clone(),
|
||||||
focus_stack.as_ref().map(|x| x.iter()),
|
focus_stack.as_ref().map(|x| x.iter()),
|
||||||
direction,
|
direction,
|
||||||
true,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2891,12 +2904,9 @@ impl Shell {
|
||||||
}
|
}
|
||||||
ManagedLayer::Tiling => {
|
ManagedLayer::Tiling => {
|
||||||
let focus_stack = workspace.focus_stack.get(seat);
|
let focus_stack = workspace.focus_stack.get(seat);
|
||||||
workspace.tiling_layer.map(
|
workspace
|
||||||
mapped.clone(),
|
.tiling_layer
|
||||||
Some(focus_stack.iter()),
|
.map(mapped.clone(), Some(focus_stack.iter()), None);
|
||||||
None,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
ManagedLayer::Sticky => unreachable!(),
|
ManagedLayer::Sticky => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,7 @@ impl Workspace {
|
||||||
{
|
{
|
||||||
self.floating_layer.unmap(&window);
|
self.floating_layer.unmap(&window);
|
||||||
self.tiling_layer
|
self.tiling_layer
|
||||||
.map(window, Some(focus_stack.iter()), None, false)
|
.map(window, Some(focus_stack.iter()), None)
|
||||||
}
|
}
|
||||||
self.tiling_enabled = true;
|
self.tiling_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
@ -655,7 +655,7 @@ impl Workspace {
|
||||||
let focus_stack = self.focus_stack.get(seat);
|
let focus_stack = self.focus_stack.get(seat);
|
||||||
self.floating_layer.unmap(&window);
|
self.floating_layer.unmap(&window);
|
||||||
self.tiling_layer
|
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