feat: runtime configurable keybindings
This commit is contained in:
parent
62afa4cf61
commit
553c49b42b
25 changed files with 674 additions and 829 deletions
|
|
@ -6,6 +6,7 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use cosmic_settings_config::shortcuts::action::ResizeDirection;
|
||||
use keyframe::{ease, functions::EaseInOutCubic};
|
||||
use smithay::{
|
||||
backend::renderer::{
|
||||
|
|
@ -36,7 +37,7 @@ use crate::{
|
|||
FocusStackMut,
|
||||
},
|
||||
grabs::{GrabStartData, ReleaseMode, ResizeEdge},
|
||||
CosmicSurface, Direction, ManagedLayer, MoveResult, ResizeDirection, ResizeMode,
|
||||
CosmicSurface, Direction, ManagedLayer, MoveResult, ResizeMode,
|
||||
},
|
||||
state::State,
|
||||
utils::{prelude::*, tween::EaseRectangle},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic_settings_config::shortcuts::action::Orientation;
|
||||
use regex::RegexSet;
|
||||
use smithay::{
|
||||
desktop::WindowSurface,
|
||||
|
|
@ -12,22 +13,6 @@ use super::CosmicSurface;
|
|||
pub mod floating;
|
||||
pub mod tiling;
|
||||
|
||||
#[derive(Debug, serde::Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Orientation {
|
||||
Horizontal,
|
||||
Vertical,
|
||||
}
|
||||
|
||||
impl std::ops::Not for Orientation {
|
||||
type Output = Self;
|
||||
fn not(self) -> Self::Output {
|
||||
match self {
|
||||
Orientation::Horizontal => Orientation::Vertical,
|
||||
Orientation::Vertical => Orientation::Horizontal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref EXCEPTIONS_APPID: RegexSet = RegexSet::new(&[
|
||||
r"Authy Desktop",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use cosmic_settings_config::shortcuts;
|
||||
use smithay::{
|
||||
backend::input::KeyState,
|
||||
input::{
|
||||
|
|
@ -12,7 +13,7 @@ use smithay::{
|
|||
use xkbcommon::xkb::Keysym;
|
||||
|
||||
use crate::{
|
||||
config::{Action, KeyPattern},
|
||||
config::key_bindings::cosmic_modifiers_from_smithay,
|
||||
shell::{layout::tiling::NodeDesc, OverviewMode, Trigger},
|
||||
state::State,
|
||||
};
|
||||
|
|
@ -53,12 +54,11 @@ impl KeyboardGrab<State> for SwapWindowGrab {
|
|||
let focus_bindings = &data
|
||||
.common
|
||||
.config
|
||||
.static_conf
|
||||
.key_bindings
|
||||
.shortcuts
|
||||
.iter()
|
||||
.filter(|(_, action)| matches!(action, Action::Focus(_)))
|
||||
.filter(|(_, action)| matches!(action, shortcuts::Action::Focus(_)))
|
||||
.map(|(pattern, action)| {
|
||||
let Action::Focus(direction) = action else {
|
||||
let shortcuts::Action::Focus(direction) = action else {
|
||||
unreachable!()
|
||||
};
|
||||
(pattern.key, *direction)
|
||||
|
|
@ -72,14 +72,17 @@ impl KeyboardGrab<State> for SwapWindowGrab {
|
|||
return;
|
||||
};
|
||||
|
||||
data.handle_action(
|
||||
Action::Focus(direction),
|
||||
data.handle_shortcut_action(
|
||||
shortcuts::Action::Focus(direction),
|
||||
&self.seat,
|
||||
serial,
|
||||
time,
|
||||
KeyPattern {
|
||||
modifiers: modifiers.map(Into::into).unwrap_or_default(),
|
||||
shortcuts::Binding {
|
||||
modifiers: modifiers
|
||||
.map(cosmic_modifiers_from_smithay)
|
||||
.unwrap_or_default(),
|
||||
key: Some(Keysym::new(keycode)),
|
||||
description: None,
|
||||
},
|
||||
None,
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ use crate::{
|
|||
},
|
||||
focus::{
|
||||
target::{KeyboardFocusTarget, PointerFocusTarget, WindowGroup},
|
||||
FocusDirection, FocusStackMut,
|
||||
FocusStackMut,
|
||||
},
|
||||
grabs::ResizeEdge,
|
||||
layout::Orientation,
|
||||
CosmicSurface, Direction, FocusResult, MoveResult, OutputNotMapped, OverviewMode,
|
||||
ResizeDirection, ResizeMode, Trigger,
|
||||
ResizeMode, Trigger,
|
||||
},
|
||||
utils::{prelude::*, tween::EaseRectangle},
|
||||
wayland::{
|
||||
|
|
@ -38,6 +38,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
use cosmic_settings_config::shortcuts::action::{FocusDirection, ResizeDirection};
|
||||
use id_tree::{InsertBehavior, MoveBehavior, Node, NodeId, NodeIdError, RemoveBehavior, Tree};
|
||||
use keyframe::{
|
||||
ease,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue