Skip to content

Commit

Permalink
Remove needs_key_repetition argument
Browse files Browse the repository at this point in the history
Not supressing key repetition in backends seems like it was a bug, and
should be fixed as of Smithay/smithay#1535.

So an argument for this should be unnecessary now.
  • Loading branch information
ids1024 authored and Drakulix committed Sep 19, 2024
1 parent 6d01722 commit d7ca032
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/backend/kms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn init_libinput(
state.backend.kms().input_devices.remove(device.name());
}

state.process_input_event(event, true);
state.process_input_event(event);

for output in state.common.shell.read().unwrap().outputs() {
state.backend.kms().schedule_render(output);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl State {
render_ping.ping();
}
WinitEvent::Redraw => render_ping.ping(),
WinitEvent::Input(event) => self.process_input_event(event, false),
WinitEvent::Input(event) => self.process_input_event(event),
WinitEvent::CloseRequested => {
self.common.should_stop = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ impl State {
_ => {}
};

self.process_input_event(event, false);
self.process_input_event(event);
// TODO actually figure out the output
for output in self.common.shell.read().unwrap().outputs() {
self.backend.x11().schedule_render(output);
Expand Down
71 changes: 28 additions & 43 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,8 @@ impl ModifiersShortcutQueue {
}

impl State {
pub fn process_input_event<B: InputBackend>(
&mut self,
event: InputEvent<B>,
needs_key_repetition: bool,
) where
pub fn process_input_event<B: InputBackend>(&mut self, event: InputEvent<B>)
where
<B as InputBackend>::Device: 'static,
{
use smithay::backend::input::Event;
Expand Down Expand Up @@ -226,13 +223,7 @@ impl State {
time,
|data, modifiers, handle| {
Self::filter_keyboard_input(
data,
&event,
&seat,
modifiers,
handle,
serial,
needs_key_repetition,
data, &event, &seat, modifiers, handle, serial,
)
},
)
Expand Down Expand Up @@ -1439,7 +1430,6 @@ impl State {
modifiers: &ModifiersState,
handle: KeysymHandle<'_>,
serial: Serial,
needs_key_repetition: bool,
) -> FilterResult<Option<(Action, shortcuts::Binding)>> {
let mut shell = self.common.shell.write().unwrap();

Expand Down Expand Up @@ -1567,36 +1557,31 @@ impl State {
}
}
} else {
let token = if needs_key_repetition {
let seat_clone = seat.clone();
let action_clone = action.clone();
let key_pattern_clone = key_pattern.clone();
let start = Instant::now();
let time = event.time_msec();
self.common
.event_loop_handle
.insert_source(
Timer::from_duration(Duration::from_millis(200)),
move |current, _, state| {
let duration = current.duration_since(start).as_millis();
state.handle_action(
action_clone.clone(),
&seat_clone,
serial,
time.overflowing_add(duration as u32).0,
key_pattern_clone.clone(),
None,
true,
);
calloop::timer::TimeoutAction::ToDuration(
Duration::from_millis(25),
)
},
)
.ok()
} else {
None
};
let seat_clone = seat.clone();
let action_clone = action.clone();
let key_pattern_clone = key_pattern.clone();
let start = Instant::now();
let time = event.time_msec();
let token = self
.common
.event_loop_handle
.insert_source(
Timer::from_duration(Duration::from_millis(200)),
move |current, _, state| {
let duration = current.duration_since(start).as_millis();
state.handle_action(
action_clone.clone(),
&seat_clone,
serial,
time.overflowing_add(duration as u32).0,
key_pattern_clone.clone(),
None,
true,
);
calloop::timer::TimeoutAction::ToDuration(Duration::from_millis(25))
},
)
.ok();

seat.supressed_keys().add(&handle, token);
}
Expand Down

0 comments on commit d7ca032

Please sign in to comment.