mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Drop pointerrawupdate
support
This commit is contained in:
parent
fc046add78
commit
a7a8ff0bbb
|
@ -69,7 +69,6 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On Web, fix touch input not gaining or loosing focus.
|
- On Web, fix touch input not gaining or loosing focus.
|
||||||
- **Breaking:** On Web, dropped support for Safari versions below 13.
|
- **Breaking:** On Web, dropped support for Safari versions below 13.
|
||||||
- On Web, prevent clicks on the canvas to select text.
|
- On Web, prevent clicks on the canvas to select text.
|
||||||
- On Web, use high-frequency pointer input events when supported by the browser.
|
|
||||||
- On Web, `EventLoopProxy` now implements `Send`.
|
- On Web, `EventLoopProxy` now implements `Send`.
|
||||||
- On Web, `Window` now implements `Send` and `Sync`.
|
- On Web, `Window` now implements `Send` and `Sync`.
|
||||||
- **Breaking:** `WindowExtWebSys::canvas()` now returns an `Option`.
|
- **Breaking:** `WindowExtWebSys::canvas()` now returns an `Option`.
|
||||||
|
|
|
@ -6,10 +6,9 @@ use crate::event::{Force, MouseButton};
|
||||||
use crate::keyboard::ModifiersState;
|
use crate::keyboard::ModifiersState;
|
||||||
|
|
||||||
use event::ButtonsState;
|
use event::ButtonsState;
|
||||||
use once_cell::unsync::OnceCell;
|
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
use wasm_bindgen::{JsCast, JsValue};
|
use wasm_bindgen::{JsCast, JsValue};
|
||||||
use web_sys::{HtmlCanvasElement, PointerEvent};
|
use web_sys::PointerEvent;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(super) struct PointerHandler {
|
pub(super) struct PointerHandler {
|
||||||
|
@ -191,11 +190,7 @@ impl PointerHandler {
|
||||||
let window = canvas_common.window.clone();
|
let window = canvas_common.window.clone();
|
||||||
let canvas = canvas_common.raw.clone();
|
let canvas = canvas_common.raw.clone();
|
||||||
self.on_cursor_move = Some(canvas_common.add_event(
|
self.on_cursor_move = Some(canvas_common.add_event(
|
||||||
if has_pointer_raw_support(&canvas) {
|
"pointermove",
|
||||||
"pointerrawupdate"
|
|
||||||
} else {
|
|
||||||
"pointermove"
|
|
||||||
},
|
|
||||||
move |event: PointerEvent| {
|
move |event: PointerEvent| {
|
||||||
// coalesced events are not available on Safari
|
// coalesced events are not available on Safari
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
|
@ -311,24 +306,3 @@ impl PointerHandler {
|
||||||
self.on_touch_cancel = None;
|
self.on_touch_cancel = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_pointer_raw_support(canvas: &HtmlCanvasElement) -> bool {
|
|
||||||
thread_local! {
|
|
||||||
static POINTER_RAW_SUPPORT: OnceCell<bool> = OnceCell::new();
|
|
||||||
}
|
|
||||||
|
|
||||||
POINTER_RAW_SUPPORT.with(|support| {
|
|
||||||
*support.get_or_init(|| {
|
|
||||||
#[wasm_bindgen]
|
|
||||||
extern "C" {
|
|
||||||
type HtmlCanvasElementExt;
|
|
||||||
|
|
||||||
#[wasm_bindgen(method, getter, js_name = onpointerrawupdate)]
|
|
||||||
fn has_on_pointerrawupdate(this: &HtmlCanvasElementExt) -> JsValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let canvas: &HtmlCanvasElementExt = canvas.unchecked_ref();
|
|
||||||
!canvas.has_on_pointerrawupdate().is_undefined()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue