mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 13:51:30 +11:00
Properly remove window mouse event listeners (#2632)
* Properly remove window mouse event listeners * Update CHANGELOG.md * Fix formatting Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
parent
809162fbd0
commit
b711a11549
|
@ -61,6 +61,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- Added `Window::set_transparent` to provide a hint about transparency of the window on Wayland and macOS.
|
- Added `Window::set_transparent` to provide a hint about transparency of the window on Wayland and macOS.
|
||||||
- On macOS, fix the mouse buttons other than left/right/middle being reported as middle.
|
- On macOS, fix the mouse buttons other than left/right/middle being reported as middle.
|
||||||
- On Wayland, support fractional scaling via the wp-fractional-scale protocol.
|
- On Wayland, support fractional scaling via the wp-fractional-scale protocol.
|
||||||
|
- On web, fix removal of mouse event listeners from the global object upon window distruction.
|
||||||
|
|
||||||
# 0.27.5
|
# 0.27.5
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ features = [
|
||||||
'DomRect',
|
'DomRect',
|
||||||
'Element',
|
'Element',
|
||||||
'Event',
|
'Event',
|
||||||
|
"EventListenerOptions",
|
||||||
'EventTarget',
|
'EventTarget',
|
||||||
'FocusEvent',
|
'FocusEvent',
|
||||||
'HtmlCanvasElement',
|
'HtmlCanvasElement',
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use wasm_bindgen::{prelude::Closure, JsCast};
|
use wasm_bindgen::{prelude::Closure, JsCast};
|
||||||
use web_sys::{AddEventListenerOptions, EventTarget};
|
use web_sys::{AddEventListenerOptions, EventListenerOptions, EventTarget};
|
||||||
|
|
||||||
pub(super) struct EventListenerHandle<T: ?Sized> {
|
pub(super) struct EventListenerHandle<T: ?Sized> {
|
||||||
target: EventTarget,
|
target: EventTarget,
|
||||||
event_type: &'static str,
|
event_type: &'static str,
|
||||||
listener: Closure<T>,
|
listener: Closure<T>,
|
||||||
|
options: EventListenerOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ?Sized> EventListenerHandle<T> {
|
impl<T: ?Sized> EventListenerHandle<T> {
|
||||||
|
@ -20,6 +21,7 @@ impl<T: ?Sized> EventListenerHandle<T> {
|
||||||
target,
|
target,
|
||||||
event_type,
|
event_type,
|
||||||
listener,
|
listener,
|
||||||
|
options: EventListenerOptions::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +46,7 @@ impl<T: ?Sized> EventListenerHandle<T> {
|
||||||
target,
|
target,
|
||||||
event_type,
|
event_type,
|
||||||
listener,
|
listener,
|
||||||
|
options: options.clone().unchecked_into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +54,10 @@ impl<T: ?Sized> EventListenerHandle<T> {
|
||||||
impl<T: ?Sized> Drop for EventListenerHandle<T> {
|
impl<T: ?Sized> Drop for EventListenerHandle<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.target
|
self.target
|
||||||
.remove_event_listener_with_callback(
|
.remove_event_listener_with_callback_and_event_listener_options(
|
||||||
self.event_type,
|
self.event_type,
|
||||||
self.listener.as_ref().unchecked_ref(),
|
self.listener.as_ref().unchecked_ref(),
|
||||||
|
&self.options,
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
web_sys::console::error_2(
|
web_sys::console::error_2(
|
||||||
|
|
Loading…
Reference in a new issue