mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Focus window on touch press
This commit is contained in:
parent
61bd8b8254
commit
fbba203c4a
|
@ -64,6 +64,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
|||
- On Windows, port to `windows-sys` version 0.48.0.
|
||||
- On Web, fix pen treated as mouse input.
|
||||
- On Web, send mouse position on button release as well.
|
||||
- On Web, fix touch input not gaining or loosing focus.
|
||||
|
||||
# 0.28.6
|
||||
|
||||
|
|
|
@ -345,14 +345,15 @@ impl<T> EventLoopWindowTarget<T> {
|
|||
prevent_default,
|
||||
);
|
||||
|
||||
let runner = self.runner.clone();
|
||||
let runner_touch = self.runner.clone();
|
||||
let modifiers = self.modifiers.clone();
|
||||
let has_focus_clone = has_focus.clone();
|
||||
canvas.on_mouse_press(
|
||||
{
|
||||
let runner = self.runner.clone();
|
||||
let modifiers = self.modifiers.clone();
|
||||
let has_focus = has_focus.clone();
|
||||
|
||||
move |pointer_id, position, button, active_modifiers| {
|
||||
let focus_changed =
|
||||
(!has_focus_clone.replace(true)).then_some(Event::WindowEvent {
|
||||
(!has_focus.replace(true)).then_some(Event::WindowEvent {
|
||||
window_id: RootWindowId(id),
|
||||
event: WindowEvent::Focused(true),
|
||||
});
|
||||
|
@ -385,9 +386,21 @@ impl<T> EventLoopWindowTarget<T> {
|
|||
},
|
||||
},
|
||||
]));
|
||||
}
|
||||
},
|
||||
{
|
||||
let runner = self.runner.clone();
|
||||
let has_focus = has_focus.clone();
|
||||
|
||||
move |device_id, location, force| {
|
||||
runner_touch.send_event(Event::WindowEvent {
|
||||
let focus_changed =
|
||||
(!has_focus.replace(true)).then_some(Event::WindowEvent {
|
||||
window_id: RootWindowId(id),
|
||||
event: WindowEvent::Focused(true),
|
||||
});
|
||||
|
||||
runner.send_events(focus_changed.into_iter().chain(iter::once(
|
||||
Event::WindowEvent {
|
||||
window_id: RootWindowId(id),
|
||||
event: WindowEvent::Touch(Touch {
|
||||
id: device_id as u64,
|
||||
|
@ -396,7 +409,9 @@ impl<T> EventLoopWindowTarget<T> {
|
|||
force: Some(force),
|
||||
location,
|
||||
}),
|
||||
});
|
||||
},
|
||||
)));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue