mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-02 06:40:06 -04:00
Revert: Web: don't wait for polling when sending events
This is a breaking change, thus revert it for patch series.
This commit is contained in:
@@ -40,11 +40,6 @@ changelog entry.
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- On Web, let events wake up event loop immediately when using
|
|
||||||
`ControlFlow::Poll`.
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- On Web, fix `EventLoopProxy::send_event()` triggering event loop immediately
|
- On Web, fix `EventLoopProxy::send_event()` triggering event loop immediately
|
||||||
|
|||||||
@@ -476,30 +476,33 @@ impl Shared {
|
|||||||
|
|
||||||
if local {
|
if local {
|
||||||
// If the loop is not running and triggered locally, queue on next microtick.
|
// If the loop is not running and triggered locally, queue on next microtick.
|
||||||
if let Ok(RunnerEnum::Running(_)) =
|
if let Ok(RunnerEnum::Running(ref runner)) =
|
||||||
self.0.runner.try_borrow().as_ref().map(Deref::deref)
|
self.0.runner.try_borrow().as_ref().map(Deref::deref)
|
||||||
{
|
{
|
||||||
#[wasm_bindgen]
|
// If we're currently polling let `send_events` do its job.
|
||||||
extern "C" {
|
if !matches!(runner.state, State::Poll { .. }) {
|
||||||
#[wasm_bindgen(js_name = queueMicrotask)]
|
#[wasm_bindgen]
|
||||||
fn queue_microtask(task: Function);
|
extern "C" {
|
||||||
}
|
#[wasm_bindgen(js_name = queueMicrotask)]
|
||||||
|
fn queue_microtask(task: Function);
|
||||||
|
}
|
||||||
|
|
||||||
queue_microtask(
|
queue_microtask(
|
||||||
Closure::once_into_js({
|
Closure::once_into_js({
|
||||||
let this = Rc::downgrade(&self.0);
|
let this = Rc::downgrade(&self.0);
|
||||||
move || {
|
move || {
|
||||||
if let Some(shared) = this.upgrade() {
|
if let Some(shared) = this.upgrade() {
|
||||||
Shared(shared).send_events(
|
Shared(shared).send_events(
|
||||||
iter::repeat(Event::UserEvent(())).take(count.get()),
|
iter::repeat(Event::UserEvent(())).take(count.get()),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
.unchecked_into(),
|
||||||
.unchecked_into(),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,8 +520,13 @@ impl Shared {
|
|||||||
// If we can run the event processing right now, or need to queue this and wait for later
|
// If we can run the event processing right now, or need to queue this and wait for later
|
||||||
let mut process_immediately = true;
|
let mut process_immediately = true;
|
||||||
match self.0.runner.try_borrow().as_ref().map(Deref::deref) {
|
match self.0.runner.try_borrow().as_ref().map(Deref::deref) {
|
||||||
// If the runner is attached but not running, we always wake it up.
|
Ok(RunnerEnum::Running(ref runner)) => {
|
||||||
Ok(RunnerEnum::Running(_)) => (),
|
// If we're currently polling, queue this and wait for the poll() method to be
|
||||||
|
// called.
|
||||||
|
if let State::Poll { .. } = runner.state {
|
||||||
|
process_immediately = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
Ok(RunnerEnum::Pending) => {
|
Ok(RunnerEnum::Pending) => {
|
||||||
// The runner still hasn't been attached: queue this event and wait for it to be
|
// The runner still hasn't been attached: queue this event and wait for it to be
|
||||||
process_immediately = false;
|
process_immediately = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user