mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
WindowBuilderExtWebSys::with_prevent_default disables scrolling on both mobile and desktop (previously just desktop) (#2216)
* Disable scrolling on web by default but provide method in builder to enable it * rename enable_web_scroll -> enable_web_page_scroll * move enable_web_page_scroll into prevent_default option * final approach * Mark prevent_default change as breaking Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
parent
ab56e9f57d
commit
0fca8b088d
|
@ -18,6 +18,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On Windows, added `WindowExtWindows::set_undecorated_shadow` and `WindowBuilderExtWindows::with_undecorated_shadow` to draw the drop shadow behind a borderless window.
|
- On Windows, added `WindowExtWindows::set_undecorated_shadow` and `WindowBuilderExtWindows::with_undecorated_shadow` to draw the drop shadow behind a borderless window.
|
||||||
- On Windows, fixed default window features (ie snap, animations, shake, etc.) when decorations are disabled.
|
- On Windows, fixed default window features (ie snap, animations, shake, etc.) when decorations are disabled.
|
||||||
- **Breaking:** On macOS, add support for two-finger touchpad magnification and rotation gestures with new events `WindowEvent::TouchpadMagnify` and `WindowEvent::TouchpadRotate`.
|
- **Breaking:** On macOS, add support for two-finger touchpad magnification and rotation gestures with new events `WindowEvent::TouchpadMagnify` and `WindowEvent::TouchpadRotate`.
|
||||||
|
- **Breaking:** On web, the `WindowBuilderExtWebSys::with_prevent_default` setting (enabled by default), now additionally prevents scrolling of the webpage in mobile browsers, previously it only disabled scrolling on desktop.
|
||||||
- On Wayland, `wayland-csd-adwaita` now uses `ab_glyph` instead of `crossfont` to render the title for decorations.
|
- On Wayland, `wayland-csd-adwaita` now uses `ab_glyph` instead of `crossfont` to render the title for decorations.
|
||||||
- On Wayland, a new `wayland-csd-adwaita-crossfont` feature was added to use `crossfont` instead of `ab_glyph` for decorations.
|
- On Wayland, a new `wayland-csd-adwaita-crossfont` feature was added to use `crossfont` instead of `ab_glyph` for decorations.
|
||||||
- On Wayland, if not otherwise specified use upstream automatic CSD theme selection.
|
- On Wayland, if not otherwise specified use upstream automatic CSD theme selection.
|
||||||
|
|
|
@ -63,6 +63,9 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
let mut canvas = canvas.borrow_mut();
|
let mut canvas = canvas.borrow_mut();
|
||||||
canvas.set_attribute("data-raw-handle", &id.0.to_string());
|
canvas.set_attribute("data-raw-handle", &id.0.to_string());
|
||||||
|
|
||||||
|
canvas.on_touch_start(prevent_default);
|
||||||
|
canvas.on_touch_end(prevent_default);
|
||||||
|
|
||||||
let runner = self.runner.clone();
|
let runner = self.runner.clone();
|
||||||
canvas.on_blur(move || {
|
canvas.on_blur(move || {
|
||||||
runner.send_event(Event::WindowEvent {
|
runner.send_event(Event::WindowEvent {
|
||||||
|
@ -153,7 +156,8 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
});
|
});
|
||||||
|
|
||||||
let runner = self.runner.clone();
|
let runner = self.runner.clone();
|
||||||
canvas.on_cursor_move(move |pointer_id, position, delta, modifiers| {
|
canvas.on_cursor_move(
|
||||||
|
move |pointer_id, position, delta, modifiers| {
|
||||||
runner.send_event(Event::WindowEvent {
|
runner.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(id),
|
window_id: RootWindowId(id),
|
||||||
event: WindowEvent::CursorMoved {
|
event: WindowEvent::CursorMoved {
|
||||||
|
@ -168,7 +172,9 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
delta: (delta.x, delta.y),
|
delta: (delta.x, delta.y),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
prevent_default,
|
||||||
|
);
|
||||||
|
|
||||||
let runner = self.runner.clone();
|
let runner = self.runner.clone();
|
||||||
canvas.on_mouse_press(move |pointer_id, position, button, modifiers| {
|
canvas.on_mouse_press(move |pointer_id, position, button, modifiers| {
|
||||||
|
|
|
@ -21,6 +21,8 @@ mod pointer_handler;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct Canvas {
|
pub struct Canvas {
|
||||||
common: Common,
|
common: Common,
|
||||||
|
on_touch_start: Option<EventListenerHandle<dyn FnMut(Event)>>,
|
||||||
|
on_touch_end: Option<EventListenerHandle<dyn FnMut(Event)>>,
|
||||||
on_focus: Option<EventListenerHandle<dyn FnMut(FocusEvent)>>,
|
on_focus: Option<EventListenerHandle<dyn FnMut(FocusEvent)>>,
|
||||||
on_blur: Option<EventListenerHandle<dyn FnMut(FocusEvent)>>,
|
on_blur: Option<EventListenerHandle<dyn FnMut(FocusEvent)>>,
|
||||||
on_keyboard_release: Option<EventListenerHandle<dyn FnMut(KeyboardEvent)>>,
|
on_keyboard_release: Option<EventListenerHandle<dyn FnMut(KeyboardEvent)>>,
|
||||||
|
@ -79,6 +81,8 @@ impl Canvas {
|
||||||
raw: canvas,
|
raw: canvas,
|
||||||
wants_fullscreen: Rc::new(RefCell::new(false)),
|
wants_fullscreen: Rc::new(RefCell::new(false)),
|
||||||
},
|
},
|
||||||
|
on_touch_start: None,
|
||||||
|
on_touch_end: None,
|
||||||
on_blur: None,
|
on_blur: None,
|
||||||
on_focus: None,
|
on_focus: None,
|
||||||
on_keyboard_release: None,
|
on_keyboard_release: None,
|
||||||
|
@ -132,6 +136,22 @@ impl Canvas {
|
||||||
&self.common.raw
|
&self.common.raw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn on_touch_start(&mut self, prevent_default: bool) {
|
||||||
|
self.on_touch_start = Some(self.common.add_event("touchstart", move |event: Event| {
|
||||||
|
if prevent_default {
|
||||||
|
event.prevent_default();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn on_touch_end(&mut self, prevent_default: bool) {
|
||||||
|
self.on_touch_end = Some(self.common.add_event("touchend", move |event: Event| {
|
||||||
|
if prevent_default {
|
||||||
|
event.prevent_default();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn on_blur<F>(&mut self, mut handler: F)
|
pub fn on_blur<F>(&mut self, mut handler: F)
|
||||||
where
|
where
|
||||||
F: 'static + FnMut(),
|
F: 'static + FnMut(),
|
||||||
|
@ -262,12 +282,14 @@ impl Canvas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_cursor_move<F>(&mut self, handler: F)
|
pub fn on_cursor_move<F>(&mut self, handler: F, prevent_default: bool)
|
||||||
where
|
where
|
||||||
F: 'static + FnMut(i32, PhysicalPosition<f64>, PhysicalPosition<f64>, ModifiersState),
|
F: 'static + FnMut(i32, PhysicalPosition<f64>, PhysicalPosition<f64>, ModifiersState),
|
||||||
{
|
{
|
||||||
match &mut self.mouse_state {
|
match &mut self.mouse_state {
|
||||||
MouseState::HasPointerEvent(h) => h.on_cursor_move(&self.common, handler),
|
MouseState::HasPointerEvent(h) => {
|
||||||
|
h.on_cursor_move(&self.common, handler, prevent_default)
|
||||||
|
}
|
||||||
MouseState::NoPointerEvent(h) => h.on_cursor_move(&self.common, handler),
|
MouseState::NoPointerEvent(h) => h.on_cursor_move(&self.common, handler),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,13 +88,20 @@ impl PointerHandler {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_cursor_move<F>(&mut self, canvas_common: &super::Common, mut handler: F)
|
pub fn on_cursor_move<F>(
|
||||||
where
|
&mut self,
|
||||||
|
canvas_common: &super::Common,
|
||||||
|
mut handler: F,
|
||||||
|
prevent_default: bool,
|
||||||
|
) where
|
||||||
F: 'static + FnMut(i32, PhysicalPosition<f64>, PhysicalPosition<f64>, ModifiersState),
|
F: 'static + FnMut(i32, PhysicalPosition<f64>, PhysicalPosition<f64>, ModifiersState),
|
||||||
{
|
{
|
||||||
self.on_cursor_move = Some(canvas_common.add_event(
|
self.on_cursor_move = Some(canvas_common.add_event(
|
||||||
"pointermove",
|
"pointermove",
|
||||||
move |event: PointerEvent| {
|
move |event: PointerEvent| {
|
||||||
|
if prevent_default {
|
||||||
|
event.prevent_default();
|
||||||
|
}
|
||||||
handler(
|
handler(
|
||||||
event.pointer_id(),
|
event.pointer_id(),
|
||||||
event::mouse_position(&event).to_physical(super::super::scale_factor()),
|
event::mouse_position(&event).to_physical(super::super::scale_factor()),
|
||||||
|
|
Loading…
Reference in a new issue