shell: Have Move-shortcut for floating layer and fullscreen windows
This commit is contained in:
parent
3d10ca6105
commit
4709a1d684
11 changed files with 207 additions and 69 deletions
|
|
@ -13,18 +13,18 @@ use smithay::{
|
|||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::shell::focus::FocusDirection;
|
||||
use crate::shell::FocusResult;
|
||||
use crate::{
|
||||
backend::render::{element::AsGlowRenderer, IndicatorShader, Key, Usage},
|
||||
shell::{
|
||||
element::{
|
||||
resize_indicator::ResizeIndicator, stack::CosmicStackRenderElement,
|
||||
window::CosmicWindowRenderElement, CosmicMapped, CosmicMappedRenderElement,
|
||||
resize_indicator::ResizeIndicator,
|
||||
stack::{CosmicStackRenderElement, MoveResult as StackMoveResult},
|
||||
window::CosmicWindowRenderElement,
|
||||
CosmicMapped, CosmicMappedRenderElement, CosmicWindow,
|
||||
},
|
||||
focus::target::KeyboardFocusTarget,
|
||||
focus::{target::KeyboardFocusTarget, FocusDirection},
|
||||
grabs::ResizeEdge,
|
||||
CosmicSurface, ResizeDirection, ResizeMode,
|
||||
CosmicSurface, Direction, FocusResult, MoveResult, ResizeDirection, ResizeMode,
|
||||
},
|
||||
state::State,
|
||||
utils::prelude::*,
|
||||
|
|
@ -423,6 +423,62 @@ impl FloatingLayout {
|
|||
.unwrap_or(FocusResult::None)
|
||||
}
|
||||
|
||||
pub fn move_current_element<'a>(
|
||||
&mut self,
|
||||
direction: Direction,
|
||||
seat: &Seat<State>,
|
||||
) -> MoveResult {
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return MoveResult::None
|
||||
};
|
||||
|
||||
let Some(focused) = (match target {
|
||||
KeyboardFocusTarget::Popup(popup) => {
|
||||
let Some(toplevel_surface) = (match popup {
|
||||
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
|
||||
}) else {
|
||||
return MoveResult::None
|
||||
};
|
||||
self.space.elements().find(|elem| elem.wl_surface().as_ref() == Some(&toplevel_surface))
|
||||
},
|
||||
KeyboardFocusTarget::Element(elem) => self.space.elements().find(|e| *e == &elem),
|
||||
_ => None,
|
||||
}) else {
|
||||
return MoveResult::None
|
||||
};
|
||||
|
||||
match focused.handle_move(direction) {
|
||||
StackMoveResult::Handled => return MoveResult::Done,
|
||||
StackMoveResult::MoveOut(surface, loop_handle) => {
|
||||
let mapped: CosmicMapped = CosmicWindow::new(surface, loop_handle).into();
|
||||
let output = seat.active_output();
|
||||
let pos = self.space.element_geometry(focused).unwrap().loc
|
||||
+ match direction {
|
||||
Direction::Up => Point::from((5, -10)),
|
||||
Direction::Down => Point::from((5, 10)),
|
||||
Direction::Left => Point::from((-10, 5)),
|
||||
Direction::Right => Point::from((10, 5)),
|
||||
};
|
||||
let position = self
|
||||
.space
|
||||
.output_geometry(&output)
|
||||
.unwrap()
|
||||
.overlaps({
|
||||
let mut geo = mapped.geometry();
|
||||
geo.loc += pos;
|
||||
geo
|
||||
})
|
||||
.then_some(pos);
|
||||
|
||||
self.map_internal(mapped.clone(), &output, position);
|
||||
return MoveResult::ShiftFocus(KeyboardFocusTarget::Element(mapped));
|
||||
}
|
||||
StackMoveResult::Default => {}
|
||||
};
|
||||
|
||||
MoveResult::MoveFurther(KeyboardFocusTarget::Element(focused.clone()))
|
||||
}
|
||||
|
||||
pub fn mapped(&self) -> impl Iterator<Item = &CosmicMapped> {
|
||||
self.space.elements().rev()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ use crate::{
|
|||
},
|
||||
grabs::ResizeEdge,
|
||||
layout::Orientation,
|
||||
CosmicSurface, FocusResult, OutputNotMapped, OverviewMode, ResizeDirection, ResizeMode,
|
||||
Trigger,
|
||||
CosmicSurface, Direction, FocusResult, MoveResult, OutputNotMapped, OverviewMode,
|
||||
ResizeDirection, ResizeMode, Trigger,
|
||||
},
|
||||
utils::{prelude::*, tween::EaseRectangle},
|
||||
wayland::{
|
||||
|
|
@ -112,33 +112,6 @@ pub struct NodeDesc {
|
|||
pub stack_window: Option<CosmicSurface>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Direction {
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
}
|
||||
|
||||
impl std::ops::Not for Direction {
|
||||
type Output = Self;
|
||||
fn not(self) -> Self::Output {
|
||||
match self {
|
||||
Direction::Left => Direction::Right,
|
||||
Direction::Right => Direction::Left,
|
||||
Direction::Up => Direction::Down,
|
||||
Direction::Down => Direction::Up,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum MoveResult {
|
||||
Done,
|
||||
MoveFurther(KeyboardFocusTarget),
|
||||
ShiftFocus(KeyboardFocusTarget),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
enum TargetZone {
|
||||
Initial,
|
||||
|
|
@ -1454,12 +1427,12 @@ impl TilingLayout {
|
|||
let mut tree = queue.trees.back().unwrap().0.copy_clone();
|
||||
|
||||
let Some(target) = seat.get_keyboard().unwrap().current_focus() else {
|
||||
return MoveResult::Done;
|
||||
return MoveResult::None;
|
||||
};
|
||||
let Some((node_id, data)) =
|
||||
TilingLayout::currently_focused_node(&mut tree, &seat.active_output(), target)
|
||||
else {
|
||||
return MoveResult::Done;
|
||||
return MoveResult::None;
|
||||
};
|
||||
|
||||
// stacks may handle movement internally
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue