windows: Better keyboard input support (#9180)
### Description Currently, there are some issues with input handling on Windows: #### 1. Direct crash when encountering IME input. https://github.com/zed-industries/zed/assets/14981363/598f7272-1948-4a42-99c5-2ef7b9162a1e #### 2. Handling messages every 1/60 seconds in the main thread. Despite being named "immediate_handle," it's not exactly immediate. ```rust // actually halt here let wait_result = unsafe { DCompositionWaitForCompositorClock(Some(&[self.inner.event]), INFINITE) }; // compositor clock ticked so we should draw a frame if wait_result == 1 { unsafe { invalidate_thread_windows(GetCurrentThreadId()) }; while unsafe { PeekMessageW(&mut msg, HWND::default(), 0, 0, PM_REMOVE) }.as_bool() ``` #### 3. According to Windows recommendations, character input should be obtained using `WM_CHAR` instead of `WM_KEYDOWN`. Additionally, there are problems with the handling within `WM_CHAR`. ```rust fn handle_char_msg(&self, wparam: WPARAM) -> LRESULT { let mut callbacks = self.callbacks.borrow_mut(); if let Some(callback) = callbacks.input.as_mut() { let modifiers = self.current_modifiers(); let msg_char = wparam.0 as u8 as char; // these are u16 chars, cant treat them as u8 ``` And, we don't handle `WM_SYSKEYDOWN` properly, which leads to `Alt + F4` not working. Release Notes: - N/A
This commit is contained in:
+16
-12
@@ -323,7 +323,13 @@ url = "2.2"
|
||||
uuid = { version = "1.1.2", features = ["v4"] }
|
||||
wasmparser = "0.121"
|
||||
wasm-encoder = "0.41"
|
||||
wasmtime = { version = "18.0", default-features = false, features = ["async", "demangle", "runtime", "cranelift", "component-model"] }
|
||||
wasmtime = { version = "18.0", default-features = false, features = [
|
||||
"async",
|
||||
"demangle",
|
||||
"runtime",
|
||||
"cranelift",
|
||||
"component-model",
|
||||
] }
|
||||
wasmtime-wasi = "18.0"
|
||||
which = "6.0.0"
|
||||
wit-component = "0.20"
|
||||
@@ -334,23 +340,21 @@ version = "0.53.0"
|
||||
features = [
|
||||
"implement",
|
||||
"Wdk_System_SystemServices",
|
||||
"Win32_Graphics_Gdi",
|
||||
"Win32_Graphics_DirectComposition",
|
||||
"Win32_UI_Controls",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
"Win32_UI_Input_KeyboardAndMouse",
|
||||
"Win32_UI_Shell",
|
||||
"Win32_System_Com",
|
||||
"Win32_System_SystemInformation",
|
||||
"Win32_System_SystemServices",
|
||||
"Win32_System_Time",
|
||||
"Win32_Graphics_Gdi",
|
||||
"Win32_Security",
|
||||
"Win32_System_Com",
|
||||
"Win32_System_Com_StructuredStorage",
|
||||
"Win32_System_Threading",
|
||||
"Win32_System_DataExchange",
|
||||
"Win32_System_Ole",
|
||||
"Win32_System_Com",
|
||||
"Win32_System_SystemInformation",
|
||||
"Win32_System_SystemServices",
|
||||
"Win32_System_Time",
|
||||
"Win32_System_Threading",
|
||||
"Win32_UI_Controls",
|
||||
"Win32_UI_Input_KeyboardAndMouse",
|
||||
"Win32_UI_Shell",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
]
|
||||
|
||||
[patch.crates-io]
|
||||
|
||||
Reference in New Issue
Block a user