Compare commits

...

2 Commits

Author SHA1 Message Date
Kirill Chibisov
9cbce055d3 Winit version 0.30.7 2024-12-22 23:00:41 +03:00
Kirill Chibisov
727583ffbf x11: fix KeyboardInput delivered twice with IME
The filtered events were still processed even though they shouldn't once
we know that they're filtered.

Fixes #4048.
2024-12-22 23:00:41 +03:00
5 changed files with 21 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "winit"
version = "0.30.6"
version = "0.30.7"
authors = [
"The winit contributors",
"Pierre Krieger <pierre.krieger1708@gmail.com>",

View File

@@ -8,7 +8,7 @@
```toml
[dependencies]
winit = "0.30.6"
winit = "0.30.7"
```
## [Documentation](https://docs.rs/winit)

View File

@@ -1,3 +1,9 @@
## 0.30.7
### Fixed
- On X11, fixed KeyboardInput delivered twice when IME enabled.
## 0.30.6
### Added

View File

@@ -62,7 +62,7 @@
//! If your application is currently based on `NativeActivity` via the `ndk-glue` crate and building
//! with `cargo apk`, then the minimal changes would be:
//! 1. Remove `ndk-glue` from your `Cargo.toml`
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.30.6",
//! 2. Enable the `"android-native-activity"` feature for Winit: `winit = { version = "0.30.7",
//! features = [ "android-native-activity" ] }`
//! 3. Add an `android_main` entrypoint (as above), instead of using the '`[ndk_glue::main]` proc
//! macro from `ndk-macros` (optionally add a dependency on `android_logger` and initialize

View File

@@ -129,6 +129,7 @@ impl EventProcessor {
/// Specifically, this involves all of the KeyPress events in compose/pre-edit sequences,
/// along with an extra copy of the KeyRelease events. This also prevents backspace and
/// arrow keys from being detected twice.
#[must_use]
fn filter_event(&mut self, xev: &mut XEvent) -> bool {
let wt = Self::window_target(&self.target);
unsafe {
@@ -149,7 +150,7 @@ impl EventProcessor {
// and forward back. This is not desired for e.g. games since some IMEs may delay the input
// and game can toggle IME back when e.g. typing into some field where latency won't really
// matter.
if event_type == xlib::KeyPress || event_type == xlib::KeyRelease {
let filtered = if event_type == xlib::KeyPress || event_type == xlib::KeyRelease {
let wt = Self::window_target(&self.target);
let ime = wt.ime.as_ref();
let window = self.active_window.map(|window| window as XWindow);
@@ -157,7 +158,8 @@ impl EventProcessor {
.and_then(|ime| window.map(|window| ime.borrow().is_ime_allowed(window)))
.unwrap_or(false);
if forward_to_ime && self.filter_event(xev) {
let filtered = forward_to_ime && self.filter_event(xev);
if filtered {
let xev: &XKeyEvent = xev.as_ref();
if self.xmodmap.is_modifier(xev.keycode as u8) {
// Don't grow the buffer past the `MAX_MOD_REPLAY_LEN`. This could happen
@@ -170,8 +172,15 @@ impl EventProcessor {
self.xfiltered_modifiers.push_front(xev.serial);
}
}
filtered
} else {
self.filter_event(xev);
self.filter_event(xev)
};
// Don't process event if it was filtered.
if filtered {
return;
}
match event_type {