seat: add focus history
This commit is contained in:
parent
9941263a82
commit
d12234b38b
21 changed files with 546 additions and 22 deletions
|
|
@ -15,6 +15,7 @@ use {
|
|||
color_management::ColorManagement,
|
||||
config::{ConfigParser, ConfigParserError},
|
||||
float::Float,
|
||||
focus_history::FocusHistory,
|
||||
},
|
||||
},
|
||||
toml::{self},
|
||||
|
|
@ -22,7 +23,7 @@ use {
|
|||
ahash::AHashMap,
|
||||
jay_config::{
|
||||
Axis, Direction, Workspace,
|
||||
input::{SwitchEvent, acceleration::AccelProfile, clickmethod::ClickMethod},
|
||||
input::{SwitchEvent, Timeline, acceleration::AccelProfile, clickmethod::ClickMethod},
|
||||
keyboard::{Keymap, ModifiedKeySym, mods::Modifiers, syms::KeySym},
|
||||
logging::LogLevel,
|
||||
status::MessageFormat,
|
||||
|
|
@ -70,6 +71,7 @@ pub enum SimpleCommand {
|
|||
KillClient,
|
||||
ShowBar(bool),
|
||||
ToggleBar,
|
||||
FocusHistory(Timeline),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -486,6 +488,7 @@ pub struct Config {
|
|||
pub pointer_revert_key: Option<KeySym>,
|
||||
pub use_hardware_cursor: Option<bool>,
|
||||
pub show_bar: Option<bool>,
|
||||
pub focus_history: Option<FocusHistory>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ mod drm_device_match;
|
|||
mod env;
|
||||
pub mod exec;
|
||||
pub mod float;
|
||||
pub mod focus_history;
|
||||
mod format;
|
||||
mod gfx_api;
|
||||
mod idle;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ use {
|
|||
jay_config::{
|
||||
Axis::{Horizontal, Vertical},
|
||||
get_workspace,
|
||||
input::Timeline,
|
||||
},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
|
@ -136,6 +137,8 @@ impl ActionParser<'_> {
|
|||
"show-bar" => ShowBar(true),
|
||||
"hide-bar" => ShowBar(false),
|
||||
"toggle-bar" => ToggleBar,
|
||||
"focus-prev" => FocusHistory(Timeline::Older),
|
||||
"focus-next" => FocusHistory(Timeline::Newer),
|
||||
_ => {
|
||||
return Err(
|
||||
ActionParserError::UnknownSimpleAction(string.to_string()).spanned(span)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use {
|
|||
drm_device_match::DrmDeviceMatchParser,
|
||||
env::EnvParser,
|
||||
float::FloatParser,
|
||||
focus_history::FocusHistoryParser,
|
||||
gfx_api::GfxApiParser,
|
||||
idle::IdleParser,
|
||||
input::InputsParser,
|
||||
|
|
@ -133,6 +134,7 @@ impl Parser for ConfigParser<'_> {
|
|||
pointer_revert_key_str,
|
||||
use_hardware_cursor,
|
||||
show_bar,
|
||||
focus_history_val,
|
||||
),
|
||||
) = ext.extract((
|
||||
(
|
||||
|
|
@ -181,6 +183,7 @@ impl Parser for ConfigParser<'_> {
|
|||
recover(opt(str("pointer-revert-key"))),
|
||||
recover(opt(bol("use-hardware-cursor"))),
|
||||
recover(opt(bol("show-bar"))),
|
||||
opt(val("focus-history")),
|
||||
),
|
||||
))?;
|
||||
let mut keymap = None;
|
||||
|
|
@ -458,6 +461,18 @@ impl Parser for ConfigParser<'_> {
|
|||
None => log::warn!("Unknown keysym: {}", self.0.error3(value.span)),
|
||||
}
|
||||
}
|
||||
let mut focus_history = None;
|
||||
if let Some(value) = focus_history_val {
|
||||
match value.parse(&mut FocusHistoryParser(self.0)) {
|
||||
Ok(v) => focus_history = Some(v),
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
"Could not parse the focus-history settings: {}",
|
||||
self.0.error(e)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Config {
|
||||
keymap,
|
||||
repeat_rate,
|
||||
|
|
@ -497,6 +512,7 @@ impl Parser for ConfigParser<'_> {
|
|||
pointer_revert_key,
|
||||
use_hardware_cursor: use_hardware_cursor.despan(),
|
||||
show_bar: show_bar.despan(),
|
||||
focus_history,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
53
toml-config/src/config/parsers/focus_history.rs
Normal file
53
toml-config/src/config/parsers/focus_history.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
use {
|
||||
crate::{
|
||||
config::{
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, bol, opt, recover},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
},
|
||||
toml::{
|
||||
toml_span::{DespanExt, Span, Spanned},
|
||||
toml_value::Value,
|
||||
},
|
||||
},
|
||||
indexmap::IndexMap,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FocusHistoryParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error(transparent)]
|
||||
Extract(#[from] ExtractorError),
|
||||
}
|
||||
|
||||
pub struct FocusHistoryParser<'a>(pub &'a Context<'a>);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FocusHistory {
|
||||
pub only_visible: Option<bool>,
|
||||
pub same_workspace: Option<bool>,
|
||||
}
|
||||
|
||||
impl Parser for FocusHistoryParser<'_> {
|
||||
type Value = FocusHistory;
|
||||
type Error = FocusHistoryParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::Table];
|
||||
|
||||
fn parse_table(
|
||||
&mut self,
|
||||
span: Span,
|
||||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let (only_visible, same_workspace) = ext.extract((
|
||||
recover(opt(bol("only-visible"))),
|
||||
recover(opt(bol("same-workspace"))),
|
||||
))?;
|
||||
Ok(FocusHistory {
|
||||
only_visible: only_visible.despan(),
|
||||
same_workspace: same_workspace.despan(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -156,6 +156,10 @@ impl Action {
|
|||
SimpleCommand::KillClient => client_action!(c, c.kill()),
|
||||
SimpleCommand::ShowBar(show) => B::new(move || set_show_bar(show)),
|
||||
SimpleCommand::ToggleBar => B::new(toggle_show_bar),
|
||||
SimpleCommand::FocusHistory(timeline) => {
|
||||
let persistent = state.persistent.clone();
|
||||
B::new(move || persistent.seat.focus_history(timeline))
|
||||
}
|
||||
},
|
||||
Action::Multi { actions } => {
|
||||
let actions: Vec<_> = actions.into_iter().map(|a| a.into_fn(state)).collect();
|
||||
|
|
@ -1252,6 +1256,14 @@ fn load_config(initial_load: bool, persistent: &Rc<PersistentState>) {
|
|||
if let Some(v) = config.show_bar {
|
||||
set_show_bar(v);
|
||||
}
|
||||
if let Some(v) = config.focus_history {
|
||||
if let Some(v) = v.only_visible {
|
||||
persistent.seat.focus_history_set_only_visible(v);
|
||||
}
|
||||
if let Some(v) = v.same_workspace {
|
||||
persistent.seat.focus_history_set_same_workspace(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_command(exec: &Exec) -> Command {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue