X11: Sync key press/release with window focus (#1296)

* X11: Sync key press/release with window focus

* When a window loses focus, key release events are issued for all pressed keys
* When a window gains focus, key press events are issued for all pressed keys
* Adds `is_synthetic` field to `WindowEvent` variant `KeyboardInput`
  to indicate that these events are synthetic.
* Adds `is_synthetic: false` to `WindowEvent::KeyboardInput` events issued
  on all other platforms

* Clarify code with comments
This commit is contained in:
Murarth 2019-12-07 15:51:37 -07:00 committed by GitHub
parent 830d47a5f7
commit 35505a3114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 180 additions and 31 deletions

View file

@ -1277,6 +1277,7 @@ unsafe extern "system" fn public_window_callback<T>(
virtual_keycode: vkey,
modifiers: event::get_key_mods(),
},
is_synthetic: false,
},
});
// Windows doesn't emit a delete character by default, but in order to make it
@ -1305,6 +1306,7 @@ unsafe extern "system" fn public_window_callback<T>(
virtual_keycode: vkey,
modifiers: event::get_key_mods(),
},
is_synthetic: false,
},
});
}