input: Various new keybindings
This commit is contained in:
parent
6cec3cb7e0
commit
544acecd2e
6 changed files with 476 additions and 280 deletions
|
|
@ -69,6 +69,13 @@ pub enum Direction {
|
|||
Down,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum FocusResult {
|
||||
None,
|
||||
Handled,
|
||||
Some(KeyboardFocusTarget),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TilingLayout {
|
||||
gaps: (i32, i32),
|
||||
|
|
@ -660,7 +667,7 @@ impl TilingLayout {
|
|||
direction: FocusDirection,
|
||||
seat: &Seat<State>,
|
||||
focus_stack: impl Iterator<Item = &'a CosmicMapped> + 'a,
|
||||
) -> Option<KeyboardFocusTarget> {
|
||||
) -> FocusResult {
|
||||
let output = seat.active_output();
|
||||
let tree = self.trees.get_mut(&output).unwrap();
|
||||
|
||||
|
|
@ -671,7 +678,7 @@ impl TilingLayout {
|
|||
|
||||
// stacks may handle focus internally
|
||||
if last_window.handle_focus(direction) {
|
||||
return None;
|
||||
return FocusResult::Handled;
|
||||
}
|
||||
|
||||
let mut node_id = last_node_id.clone();
|
||||
|
|
@ -682,7 +689,7 @@ impl TilingLayout {
|
|||
assert!(group_data.is_group());
|
||||
|
||||
if direction == FocusDirection::Out {
|
||||
return Some(
|
||||
return FocusResult::Some(
|
||||
WindowGroup {
|
||||
node: group.clone(),
|
||||
output: output.downgrade(),
|
||||
|
|
@ -787,7 +794,7 @@ impl TilingLayout {
|
|||
});
|
||||
}
|
||||
Data::Mapped { mapped, .. } => {
|
||||
return Some(mapped.clone().into());
|
||||
return FocusResult::Some(mapped.clone().into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -797,7 +804,7 @@ impl TilingLayout {
|
|||
}
|
||||
}
|
||||
|
||||
None
|
||||
FocusResult::None
|
||||
}
|
||||
|
||||
pub fn update_orientation<'a>(
|
||||
|
|
|
|||
|
|
@ -325,6 +325,16 @@ impl WorkspaceMode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn len(&self, output: &Output) -> usize {
|
||||
match self {
|
||||
WorkspaceMode::Global(set) => set.workspaces.len(),
|
||||
WorkspaceMode::OutputBound(sets, _) => {
|
||||
let set = sets.get(output).unwrap();
|
||||
set.workspaces.len()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spaces(&self) -> impl Iterator<Item = &Workspace> {
|
||||
match self {
|
||||
WorkspaceMode::Global(set) => {
|
||||
|
|
@ -970,16 +980,27 @@ impl Shell {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn move_current_window(state: &mut State, seat: &Seat<State>, output: &Output, idx: usize) {
|
||||
if idx == state.common.shell.workspaces.active_num(output) {
|
||||
pub fn move_current_window(
|
||||
state: &mut State,
|
||||
seat: &Seat<State>,
|
||||
from_output: &Output,
|
||||
to: (&Output, Option<usize>),
|
||||
) {
|
||||
let (to_output, to_idx) = to;
|
||||
let to_idx = to_idx.unwrap_or(state.common.shell.workspaces.active_num(to_output));
|
||||
|
||||
if from_output == to_output
|
||||
&& to_idx == state.common.shell.workspaces.active_num(from_output)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let old_workspace = state.common.shell.workspaces.active_mut(output);
|
||||
let maybe_window = old_workspace.focus_stack.get(seat).last().cloned();
|
||||
let from_workspace = state.common.shell.workspaces.active_mut(from_output);
|
||||
let maybe_window = from_workspace.focus_stack.get(seat).last().cloned();
|
||||
|
||||
if let Some(mapped) = maybe_window {
|
||||
let was_floating = old_workspace.floating_layer.unmap(&mapped);
|
||||
let was_tiling = old_workspace.tiling_layer.unmap(&mapped);
|
||||
let was_floating = from_workspace.floating_layer.unmap(&mapped);
|
||||
let was_tiling = from_workspace.tiling_layer.unmap(&mapped);
|
||||
assert!(was_floating != was_tiling);
|
||||
|
||||
for (toplevel, _) in mapped.windows() {
|
||||
|
|
@ -987,22 +1008,25 @@ impl Shell {
|
|||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_leave_workspace(&toplevel, &old_workspace.handle);
|
||||
.toplevel_leave_workspace(&toplevel, &from_workspace.handle);
|
||||
}
|
||||
let elements = old_workspace.mapped().cloned().collect::<Vec<_>>();
|
||||
std::mem::drop(old_workspace);
|
||||
let elements = from_workspace.mapped().cloned().collect::<Vec<_>>();
|
||||
std::mem::drop(from_workspace);
|
||||
for mapped in elements.into_iter() {
|
||||
state.common.shell.update_reactive_popups(&mapped);
|
||||
}
|
||||
|
||||
let new_workspace = state.common.shell.workspaces.get_mut(idx, output).unwrap(); // checked above
|
||||
let focus_stack = new_workspace.focus_stack.get(&seat);
|
||||
let to_workspace = state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.get_mut(to_idx, to_output)
|
||||
.unwrap(); // checked above
|
||||
let focus_stack = to_workspace.focus_stack.get(&seat);
|
||||
if was_floating {
|
||||
new_workspace
|
||||
.floating_layer
|
||||
.map(mapped.clone(), &seat, None);
|
||||
to_workspace.floating_layer.map(mapped.clone(), &seat, None);
|
||||
} else {
|
||||
new_workspace
|
||||
to_workspace
|
||||
.tiling_layer
|
||||
.map(mapped.clone(), &seat, focus_stack.iter());
|
||||
}
|
||||
|
|
@ -1011,10 +1035,10 @@ impl Shell {
|
|||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_workspace(&toplevel, &new_workspace.handle);
|
||||
.toplevel_enter_workspace(&toplevel, &to_workspace.handle);
|
||||
}
|
||||
|
||||
for mapped in new_workspace
|
||||
for mapped in to_workspace
|
||||
.mapped()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
|
|
@ -1023,7 +1047,7 @@ impl Shell {
|
|||
state.common.shell.update_reactive_popups(&mapped);
|
||||
}
|
||||
|
||||
state.common.shell.activate(output, idx);
|
||||
state.common.shell.activate(to_output, to_idx);
|
||||
Common::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,11 +249,11 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fullscreen_toggle(&mut self, window: &Window, output: &Output) {
|
||||
pub fn maximize_toggle(&mut self, window: &Window, output: &Output) {
|
||||
if self.fullscreen.contains_key(output) {
|
||||
self.unfullscreen_request(window)
|
||||
self.unmaximize_request(window)
|
||||
} else {
|
||||
self.fullscreen_request(window, output)
|
||||
self.maximize_request(window, output)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue