Compare commits

..

6 Commits

Author SHA1 Message Date
Kirill Chibisov
bbdcb79bbd Release 0.27.5 version 2022-10-26 17:41:45 +03:00
Kirill Chibisov
b8ac784ffc On Wayland, fix invalid offsets being sent in Preedit
Even when the protocol explicitly tells to send proper UTF-8
boundaries for cursor, some IMEs don't do that, so sanity check
them before sending downstream.
2022-10-26 17:41:45 +03:00
Kirill Chibisov
e7037c6ad0 Release 0.27.4 version 2022-10-10 00:37:55 +03:00
Kirill Chibisov
51986bce26 On X11, fix IME crashing during reload
During reload we were picking old styles, but the styles could
change during reload leading to errors during IME building.

Fixes #2510.
2022-10-10 00:37:55 +03:00
Markus Siglreithmaier
429cc58f98 Windows, emit ReceivedCharacter on system keybinds
Currently needed for downstream users relaying on `ReceivedCharacter` for implementing
keybindings.
2022-10-10 00:37:55 +03:00
killian
81303d81a8 On Windows, fixed focus event emission on minimize. 2022-10-10 00:37:55 +03:00
6 changed files with 47 additions and 10 deletions

View File

@@ -8,6 +8,16 @@ And please only add new entries to the top of this list, right below the `# Unre
# Unreleased
# 0.27.5
- On Wayland, fix byte offset in `Ime::Preedit` pointing to invalid bytes.
# 0.27.4
- On Windows, emit `ReceivedCharacter` events on system keybindings.
- On Windows, fixed focus event emission on minimize.
- On X11, fixed IME crashing during reload.
# 0.27.3 (2022-9-10)
- On Windows, added `WindowExtWindows::set_undecorated_shadow` and `WindowBuilderExtWindows::with_undecorated_shadow` to draw the drop shadow behind a borderless window.

View File

@@ -1,6 +1,6 @@
[package]
name = "winit"
version = "0.27.3"
version = "0.27.5"
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform window creation library."
edition = "2021"

View File

@@ -6,7 +6,7 @@
```toml
[dependencies]
winit = "0.27.3"
winit = "0.27.5"
```
## [Documentation](https://docs.rs/winit)

View File

@@ -68,9 +68,14 @@ pub(super) fn handle_text_input(
cursor_begin,
cursor_end,
} => {
let cursor_begin = usize::try_from(cursor_begin).ok();
let cursor_end = usize::try_from(cursor_end).ok();
let text = text.unwrap_or_default();
let cursor_begin = usize::try_from(cursor_begin)
.ok()
.and_then(|idx| text.is_char_boundary(idx).then(|| idx));
let cursor_end = usize::try_from(cursor_end)
.ok()
.and_then(|idx| text.is_char_boundary(idx).then(|| idx));
inner.pending_preedit = Some(Preedit {
text,
cursor_begin,

View File

@@ -108,10 +108,21 @@ unsafe fn replace_im(inner: *mut ImeInner) -> Result<(), ReplaceImError> {
let mut new_contexts = HashMap::new();
for (window, old_context) in (*inner).contexts.iter() {
let spot = old_context.as_ref().map(|old_context| old_context.ic_spot);
let style = old_context
// Check if the IME was allowed on that context.
let is_allowed = old_context
.as_ref()
.map(|old_context| old_context.style)
.map(|old_context| old_context.is_allowed())
.unwrap_or_default();
// We can't use the style from the old context here, since it may change on reload, so
// pick style from the new XIM based on the old state.
let style = if is_allowed {
new_im.preedit_style
} else {
new_im.none_style
};
let new_context = {
let result = ImeContext::new(
xconn,

View File

@@ -66,7 +66,7 @@ use windows_sys::Win32::{
WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY,
WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP, WM_POINTERUPDATE,
WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE,
WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED,
WM_SYSCHAR, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED,
WM_WINDOWPOSCHANGING, WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED,
WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP,
WS_VISIBLE,
@@ -1188,7 +1188,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
0
}
WM_CHAR => {
WM_CHAR | WM_SYSCHAR => {
use crate::event::WindowEvent::ReceivedCharacter;
use std::char;
let is_high_surrogate = (0xD800..=0xDBFF).contains(&wparam);
@@ -1219,7 +1219,18 @@ unsafe fn public_window_callback_inner<T: 'static>(
}
}
0
// todo(msiglreith):
// Ideally, `WM_SYSCHAR` shouldn't emit a `ReceivedChar` event
// indicating user text input. As we lack dedicated support
// accelerators/keybindings these events will be additionally
// emitted for downstream users.
// This means certain key combinations (ie Alt + Space) will
// trigger the default system behavior **and** emit a char event.
if msg == WM_SYSCHAR {
DefWindowProcW(window, msg, wparam, lparam)
} else {
0
}
}
WM_MENUCHAR => (MNC_CLOSE << 16) as isize,
@@ -1900,7 +1911,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
}
WM_NCACTIVATE => {
let is_active = wparam == 1;
let is_active = wparam != false.into();
let active_focus_changed = userdata.window_state.lock().set_active(is_active);
if active_focus_changed {
if is_active {