Update winit to 0.29.4

This commit is contained in:
Héctor Ramón Jiménez 2023-12-15 13:15:44 +01:00
parent dd249a1d11
commit e819c2390b
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
19 changed files with 654 additions and 846 deletions

View file

@ -8,7 +8,7 @@ pub use crate::core::event::Status;
/// A [`Canvas`] event.
///
/// [`Canvas`]: crate::Canvas
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum Event {
/// A mouse event.
Mouse(mouse::Event),

View file

@ -9,7 +9,7 @@ pub use crate::core::event::Status;
/// A [`Shader`] event.
///
/// [`Shader`]: crate::Shader
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum Event {
/// A mouse event.
Mouse(mouse::Event),

View file

@ -649,6 +649,7 @@ impl Update {
keyboard::Event::KeyPressed {
key_code,
modifiers,
text,
} if state.is_focused => {
if let Some(motion) = motion(key_code) {
let motion =
@ -678,12 +679,15 @@ impl Update {
{
Some(Self::Paste)
}
_ => None,
_ => {
let text = text?;
edit(Edit::Insert(
text.chars().next().unwrap_or_default(),
))
}
}
}
keyboard::Event::CharacterReceived(c) if state.is_focused => {
edit(Edit::Insert(c))
}
_ => None,
},
_ => None,

View file

@ -752,34 +752,9 @@ where
return event::Status::Captured;
}
}
Event::Keyboard(keyboard::Event::CharacterReceived(c)) => {
let state = state();
if let Some(focus) = &mut state.is_focused {
let Some(on_input) = on_input else {
return event::Status::Ignored;
};
if state.is_pasting.is_none()
&& !state.keyboard_modifiers.command()
&& !c.is_control()
{
let mut editor = Editor::new(value, &mut state.cursor);
editor.insert(c);
let message = (on_input)(editor.contents());
shell.publish(message);
focus.updated_at = Instant::now();
update_cache(state, value);
return event::Status::Captured;
}
}
}
Event::Keyboard(keyboard::Event::KeyPressed { key_code, .. }) => {
Event::Keyboard(keyboard::Event::KeyPressed {
key_code, text, ..
}) => {
let state = state();
if let Some(focus) = &mut state.is_focused {
@ -971,7 +946,30 @@ where
| keyboard::KeyCode::Down => {
return event::Status::Ignored;
}
_ => {}
_ => {
if let Some(text) = text {
let c = text.chars().next().unwrap_or_default();
if state.is_pasting.is_none()
&& !state.keyboard_modifiers.command()
&& !c.is_control()
{
let mut editor =
Editor::new(value, &mut state.cursor);
editor.insert(c);
let message = (on_input)(editor.contents());
shell.publish(message);
focus.updated_at = Instant::now();
update_cache(state, value);
return event::Status::Captured;
}
}
}
}
return event::Status::Captured;