Files
oak-gpui/crates
张小白 36cbfbfb94 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
2024-03-13 12:10:22 -07:00
..
2024-03-13 11:28:17 -06:00
2024-03-11 10:45:57 +01:00
2024-03-11 10:45:57 +01:00
2024-03-12 22:30:04 -06:00
2024-03-11 10:45:57 +01:00
2024-03-11 10:45:57 +01:00
2024-03-11 10:45:57 +01:00
2024-03-11 13:28:10 +01:00
2024-03-07 19:56:41 -07:00
2024-03-11 10:03:51 +02:00
2024-03-07 13:52:50 -07:00