Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: Send modifiers of modifier-only bindings to clients #658

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ impl State {
)));
}
}

std::mem::drop(shell);

// cancel grabs
if is_grabbed
Expand Down Expand Up @@ -435,8 +437,7 @@ impl State {
}

// handle the rest of the global shortcuts
let mut intercepted = false;
let mut can_clear_modifiers_shortcut = true;
let mut clear_queue = true;
if !shortcuts_inhibited {
let modifiers_queue = seat.modifiers_shortcut_queue();

Expand All @@ -447,29 +448,33 @@ impl State {
continue;
}

let modifiers_bypass = binding.key.is_none()
// is this a released (triggered) modifier-only binding?
if binding.key.is_none()
&& state == KeyState::Released
&& !cosmic_modifiers_eq_smithay(&binding.modifiers, modifiers)
&& modifiers_queue.take(binding);
&& modifiers_queue.take(binding)
{
modifiers_queue.clear();
return FilterResult::Intercept(Some((
Action::Shortcut(action.clone()),
binding.clone(),
)));
}

if !modifiers_bypass && binding.key.is_none() && state == KeyState::Pressed && cosmic_modifiers_eq_smithay(&binding.modifiers, modifiers) {
// could this potentially become a modifier-only binding?
if binding.key.is_none() && state == KeyState::Pressed && cosmic_modifiers_eq_smithay(&binding.modifiers, modifiers) {
modifiers_queue.set(binding.clone());
can_clear_modifiers_shortcut = false;
intercepted = true;
clear_queue = false;
}

if (
binding.key.is_some()
&& state == KeyState::Pressed
&& handle.raw_syms().contains(&binding.key.unwrap())
&& cosmic_modifiers_eq_smithay(&binding.modifiers, modifiers)
) || modifiers_bypass
// is this a normal binding?
if binding.key.is_some()
&& state == KeyState::Pressed
&& handle.raw_syms().contains(&binding.key.unwrap())
&& cosmic_modifiers_eq_smithay(&binding.modifiers, modifiers)
{
modifiers_queue.clear();
// only suppress if the action is on Press
if !modifiers_bypass {
seat.supressed_keys().add(&handle, None);
}
seat.supressed_keys().add(&handle, None);
return FilterResult::Intercept(Some((
Action::Shortcut(action.clone()),
binding.clone(),
Expand All @@ -478,21 +483,20 @@ impl State {
}
}

if can_clear_modifiers_shortcut {
// no binding
if clear_queue {
seat.modifiers_shortcut_queue().clear();
}

// keys are passed through to apps
std::mem::drop(shell);
if intercepted {
FilterResult::Intercept(None)
} else {
FilterResult::Forward
}
FilterResult::Forward
},
)
.flatten()
{
if pattern.key.is_none() && state == KeyState::Released {
// we still want to send release-events and not have apps stuck on some modifiers.
keyboard.input(self, keycode, state, serial, time, |_, _, _| FilterResult::<()>::Forward);
}
self.handle_action(action, &seat, serial, time, pattern, None, true)
}
}
Expand Down
Loading