Skip to content

Commit

Permalink
Manually emit focused event on mouse click
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Feb 25, 2022
1 parent b7e7755 commit 9f938f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ And please only add new entries to the top of this list, right below the `# Unre
- Added `Window::is_decorated`.
- On X11, fix for repeated event loop iteration when `ControlFlow` was `Wait`
- On Wayland, report unaccelerated mouse deltas in `DeviceEvent::MouseMotion`.
- On web, a focused event is manually generated when a click occurs to emulate behaviour of other backends.
- **Breaking:** Bump `ndk` version to 0.6, ndk-sys to `v0.3`, `ndk-glue` to `0.6`.
- Remove no longer needed `WINIT_LINK_COLORSYNC` environment variable.
- **Breaking:** Rename the `Exit` variant of `ControlFlow` to `ExitWithCode`, which holds a value to control the exit code after running. Add an `Exit` constant which aliases to `ExitWithCode(0)` instead to avoid major breakage. This shouldn't affect most existing programs.
Expand Down
6 changes: 5 additions & 1 deletion src/platform_impl/web/event_loop/window_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,17 @@ impl<T> WindowTarget<T> {
// user code has the correct cursor position.
runner.send_events(
std::iter::once(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::Focused(true),
})
.chain(std::iter::once(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::CursorMoved {
device_id: DeviceId(device::Id(pointer_id)),
position,
modifiers,
},
})
}))
.chain(std::iter::once(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::MouseInput {
Expand Down

0 comments on commit 9f938f3

Please sign in to comment.