Merge branch 'fix-modifier-toggling' into 'main'
input: Make it possible to deactivate a modifier with any button for it Closes #433 See merge request World/Phosh/squeekboard!706
This commit is contained in:
@ -1186,7 +1186,7 @@ mod seat {
|
||||
key_id,
|
||||
modifier, time,
|
||||
),
|
||||
false => submission.handle_drop_modifier(key_id, time),
|
||||
false => submission.handle_drop_modifier(key_id, modifier, time),
|
||||
}
|
||||
}
|
||||
// only show when UI is present
|
||||
|
||||
@ -220,7 +220,8 @@ impl Submission {
|
||||
pub fn handle_add_modifier(
|
||||
&mut self,
|
||||
key_id: KeyStateId,
|
||||
modifier: Modifier, _time: Timestamp,
|
||||
modifier: Modifier,
|
||||
_time: Timestamp,
|
||||
) {
|
||||
self.modifiers_active.push((key_id, modifier));
|
||||
self.update_modifiers();
|
||||
@ -228,10 +229,11 @@ impl Submission {
|
||||
|
||||
pub fn handle_drop_modifier(
|
||||
&mut self,
|
||||
key_id: KeyStateId,
|
||||
_key_id: KeyStateId,
|
||||
modifier: Modifier,
|
||||
_time: Timestamp,
|
||||
) {
|
||||
vec_remove(&mut self.modifiers_active, |(id, _)| *id == key_id);
|
||||
vec_remove(&mut self.modifiers_active, |(_, m)| *m == modifier);
|
||||
self.update_modifiers();
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ pub trait WarningHandler {
|
||||
fn handle(&mut self, warning: &str);
|
||||
}
|
||||
|
||||
/// Removes the first matcing item
|
||||
/// Removes the first matching item
|
||||
pub fn vec_remove<T, F: FnMut(&T) -> bool>(v: &mut Vec<T>, pred: F) -> Option<T> {
|
||||
let idx = v.iter().position(pred);
|
||||
idx.map(|idx| v.remove(idx))
|
||||
|
||||
Reference in New Issue
Block a user