diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index d62aeb9443..89286b6c94 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -76,6 +76,7 @@ changelog entry. - Change signature of `EventLoop::run_app`, `EventLoopExtPumpEvents::pump_app_events` and `EventLoopExtRunOnDemand::run_app_on_demand` to accept a `impl ApplicationHandler` directly, instead of requiring a `&mut` reference to it. +- On Web, `Window::canvas()` now returns a reference. ### Removed diff --git a/src/platform/web.rs b/src/platform/web.rs index 75b904189e..b47bf46566 100644 --- a/src/platform/web.rs +++ b/src/platform/web.rs @@ -42,6 +42,7 @@ //! [`WindowEvent::Touch`]: crate::event::WindowEvent::Touch //! [`Window::set_outer_position()`]: crate::window::Window::set_outer_position +use std::cell::Ref; use std::error::Error; use std::fmt::{self, Display, Formatter}; use std::future::Future; @@ -74,7 +75,7 @@ pub struct HtmlCanvasElement; pub trait WindowExtWeb { /// Only returns the canvas if called from inside the window context (the /// main thread). - fn canvas(&self) -> Option; + fn canvas(&self) -> Option>; /// Returns [`true`] if calling `event.preventDefault()` is enabled. /// @@ -94,7 +95,7 @@ pub trait WindowExtWeb { impl WindowExtWeb for Window { #[inline] - fn canvas(&self) -> Option { + fn canvas(&self) -> Option> { self.window.canvas() } diff --git a/src/platform_impl/web/event_loop/runner.rs b/src/platform_impl/web/event_loop/runner.rs index 82434f819a..190ecff90c 100644 --- a/src/platform_impl/web/event_loop/runner.rs +++ b/src/platform_impl/web/event_loop/runner.rs @@ -55,7 +55,7 @@ struct Execution { navigator: Navigator, document: Document, #[allow(clippy::type_complexity)] - all_canvases: RefCell>, DispatchRunner)>>, + all_canvases: RefCell, DispatchRunner)>>, redraw_pending: RefCell>, destroy_pending: RefCell>, pub(crate) monitor: Rc, @@ -121,7 +121,7 @@ impl Runner { EventWrapper::Event(event) => (self.event_handler)(event), EventWrapper::ScaleChange { canvas, size, scale } => { if let Some(canvas) = canvas.upgrade() { - canvas.borrow().handle_scale_change( + canvas.handle_scale_change( runner, |event| (self.event_handler)(event), size, @@ -209,7 +209,7 @@ impl Shared { pub fn add_canvas( &self, id: WindowId, - canvas: Weak>, + canvas: Weak, runner: DispatchRunner, ) { self.0.all_canvases.borrow_mut().push((id, canvas, runner)); @@ -456,7 +456,7 @@ impl Shared { // - not visible and we don't know if it intersects yet // - visible and intersects if let (false, Some(true) | None) | (true, Some(true)) = - (is_visible, canvas.borrow().is_intersecting) + (is_visible, canvas.is_intersecting.get()) { runner.send_event(Event::WindowEvent { window_id: *id, @@ -772,7 +772,6 @@ impl Shared { // In case any remaining `Window`s are still not dropped, we will need // to explicitly remove the event handlers associated with their canvases. if let Some(canvas) = canvas.upgrade() { - let mut canvas = canvas.borrow_mut(); canvas.remove_listeners(); } } @@ -816,7 +815,7 @@ impl Shared { DeviceEvents::WhenFocused => { self.0.all_canvases.borrow().iter().any(|(_, canvas, _)| { if let Some(canvas) = canvas.upgrade() { - canvas.borrow().has_focus.get() + canvas.has_focus.get() } else { false } @@ -886,7 +885,7 @@ impl WeakShared { pub(crate) enum EventWrapper { Event(Event), - ScaleChange { canvas: Weak>, size: PhysicalSize, scale: f64 }, + ScaleChange { canvas: Weak, size: PhysicalSize, scale: f64 }, } impl From for EventWrapper { diff --git a/src/platform_impl/web/event_loop/window_target.rs b/src/platform_impl/web/event_loop/window_target.rs index 618ec399f4..32f31a45d0 100644 --- a/src/platform_impl/web/event_loop/window_target.rs +++ b/src/platform_impl/web/event_loop/window_target.rs @@ -1,4 +1,4 @@ -use std::cell::{Cell, RefCell}; +use std::cell::Cell; use std::clone::Clone; use std::iter; use std::rc::Rc; @@ -79,9 +79,8 @@ impl ActiveEventLoop { CustomCursorFuture(CustomCursor::new_async(self, source.inner)) } - pub fn register(&self, canvas: &Rc>, id: WindowId) { + pub fn register(&self, canvas: &Rc, id: WindowId) { let canvas_clone = canvas.clone(); - let mut canvas = canvas.borrow_mut(); #[cfg(any(feature = "rwh_04", feature = "rwh_05"))] canvas.set_attribute("data-raw-handle", &id.0.to_string()); @@ -604,7 +603,6 @@ impl ActiveEventLoop { let canvas = canvas_clone.clone(); move |new_size| { - let canvas = canvas.borrow(); canvas.set_current_size(new_size); if canvas.old_size() != new_size { canvas.set_old_size(new_size); @@ -622,7 +620,7 @@ impl ActiveEventLoop { canvas.on_intersection(move |is_intersecting| { // only fire if visible while skipping the first event if it's intersecting if backend::is_visible(runner.document()) - && !(is_intersecting && canvas_clone.borrow().is_intersecting.is_none()) + && !(is_intersecting && canvas_clone.is_intersecting.get().is_none()) { runner.send_event(Event::WindowEvent { window_id: RootWindowId(id), @@ -630,7 +628,7 @@ impl ActiveEventLoop { }); } - canvas_clone.borrow_mut().is_intersecting = Some(is_intersecting); + canvas_clone.is_intersecting.set(Some(is_intersecting)); }); let runner = self.runner.clone(); diff --git a/src/platform_impl/web/web_sys/canvas.rs b/src/platform_impl/web/web_sys/canvas.rs index 8446fdc52d..c3eb9abcab 100644 --- a/src/platform_impl/web/web_sys/canvas.rs +++ b/src/platform_impl/web/web_sys/canvas.rs @@ -1,4 +1,4 @@ -use std::cell::Cell; +use std::cell::{Cell, RefCell}; use std::ops::Deref; use std::rc::Rc; use std::sync::{Arc, Mutex}; @@ -34,7 +34,13 @@ pub struct Canvas { id: WindowId, pub has_focus: Rc>, pub prevent_default: Rc>, - pub is_intersecting: Option, + pub is_intersecting: Cell>, + cursor: CursorHandler, + handlers: RefCell, +} + +struct Handlers { + animation_frame_handler: AnimationFrameHandler, on_touch_start: Option>, on_focus: Option>, on_blur: Option>, @@ -45,10 +51,8 @@ pub struct Canvas { pointer_handler: PointerHandler, on_resize_scale: Option, on_intersect: Option, - animation_frame_handler: AnimationFrameHandler, on_touch_end: Option>, on_context_menu: Option>, - cursor: CursorHandler, } pub struct Common { @@ -158,21 +162,23 @@ impl Canvas { id, has_focus: Rc::new(Cell::new(false)), prevent_default: Rc::new(Cell::new(attr.platform_specific.prevent_default)), - is_intersecting: None, - on_touch_start: None, - on_blur: None, - on_focus: None, - on_keyboard_release: None, - on_keyboard_press: None, - on_mouse_wheel: None, - on_dark_mode: None, - pointer_handler: PointerHandler::new(), - on_resize_scale: None, - on_intersect: None, - animation_frame_handler: AnimationFrameHandler::new(window), - on_touch_end: None, - on_context_menu: None, + is_intersecting: Cell::new(None), cursor, + handlers: RefCell::new(Handlers { + animation_frame_handler: AnimationFrameHandler::new(window), + on_touch_start: None, + on_blur: None, + on_focus: None, + on_keyboard_release: None, + on_keyboard_press: None, + on_mouse_wheel: None, + on_dark_mode: None, + pointer_handler: PointerHandler::new(), + on_resize_scale: None, + on_intersect: None, + on_touch_end: None, + on_context_menu: None, + }), }) } @@ -270,39 +276,42 @@ impl Canvas { &self.common.style } - pub fn on_touch_start(&mut self) { + pub fn on_touch_start(&self) { let prevent_default = Rc::clone(&self.prevent_default); - self.on_touch_start = Some(self.common.add_event("touchstart", move |event: Event| { - if prevent_default.get() { - event.prevent_default(); - } - })); + self.handlers.borrow_mut().on_touch_start = + Some(self.common.add_event("touchstart", move |event: Event| { + if prevent_default.get() { + event.prevent_default(); + } + })); } - pub fn on_blur(&mut self, mut handler: F) + pub fn on_blur(&self, mut handler: F) where F: 'static + FnMut(), { - self.on_blur = Some(self.common.add_event("blur", move |_: FocusEvent| { - handler(); - })); + self.handlers.borrow_mut().on_blur = + Some(self.common.add_event("blur", move |_: FocusEvent| { + handler(); + })); } - pub fn on_focus(&mut self, mut handler: F) + pub fn on_focus(&self, mut handler: F) where F: 'static + FnMut(), { - self.on_focus = Some(self.common.add_event("focus", move |_: FocusEvent| { - handler(); - })); + self.handlers.borrow_mut().on_focus = + Some(self.common.add_event("focus", move |_: FocusEvent| { + handler(); + })); } - pub fn on_keyboard_release(&mut self, mut handler: F) + pub fn on_keyboard_release(&self, mut handler: F) where F: 'static + FnMut(PhysicalKey, Key, Option, KeyLocation, bool, ModifiersState), { let prevent_default = Rc::clone(&self.prevent_default); - self.on_keyboard_release = + self.handlers.borrow_mut().on_keyboard_release = Some(self.common.add_event("keyup", move |event: KeyboardEvent| { if prevent_default.get() { event.prevent_default(); @@ -320,12 +329,12 @@ impl Canvas { })); } - pub fn on_keyboard_press(&mut self, mut handler: F) + pub fn on_keyboard_press(&self, mut handler: F) where F: 'static + FnMut(PhysicalKey, Key, Option, KeyLocation, bool, ModifiersState), { let prevent_default = Rc::clone(&self.prevent_default); - self.on_keyboard_press = + self.handlers.borrow_mut().on_keyboard_press = Some(self.common.add_event("keydown", move |event: KeyboardEvent| { if prevent_default.get() { event.prevent_default(); @@ -343,22 +352,22 @@ impl Canvas { })); } - pub fn on_cursor_leave(&mut self, handler: F) + pub fn on_cursor_leave(&self, handler: F) where F: 'static + FnMut(ModifiersState, Option), { - self.pointer_handler.on_cursor_leave(&self.common, handler) + self.handlers.borrow_mut().pointer_handler.on_cursor_leave(&self.common, handler) } - pub fn on_cursor_enter(&mut self, handler: F) + pub fn on_cursor_enter(&self, handler: F) where F: 'static + FnMut(ModifiersState, Option), { - self.pointer_handler.on_cursor_enter(&self.common, handler) + self.handlers.borrow_mut().pointer_handler.on_cursor_enter(&self.common, handler) } pub fn on_mouse_release( - &mut self, + &self, modifier_handler: MOD, mouse_handler: M, touch_handler: T, @@ -367,7 +376,7 @@ impl Canvas { M: 'static + FnMut(ModifiersState, i32, PhysicalPosition, MouseButton), T: 'static + FnMut(ModifiersState, i32, PhysicalPosition, Force), { - self.pointer_handler.on_mouse_release( + self.handlers.borrow_mut().pointer_handler.on_mouse_release( &self.common, modifier_handler, mouse_handler, @@ -376,7 +385,7 @@ impl Canvas { } pub fn on_mouse_press( - &mut self, + &self, modifier_handler: MOD, mouse_handler: M, touch_handler: T, @@ -385,7 +394,7 @@ impl Canvas { M: 'static + FnMut(ModifiersState, i32, PhysicalPosition, MouseButton), T: 'static + FnMut(ModifiersState, i32, PhysicalPosition, Force), { - self.pointer_handler.on_mouse_press( + self.handlers.borrow_mut().pointer_handler.on_mouse_press( &self.common, modifier_handler, mouse_handler, @@ -395,7 +404,7 @@ impl Canvas { } pub fn on_cursor_move( - &mut self, + &self, modifier_handler: MOD, mouse_handler: M, touch_handler: T, @@ -407,7 +416,7 @@ impl Canvas { + FnMut(ModifiersState, i32, &mut dyn Iterator, Force)>), B: 'static + FnMut(ModifiersState, i32, PhysicalPosition, ButtonsState, MouseButton), { - self.pointer_handler.on_cursor_move( + self.handlers.borrow_mut().pointer_handler.on_cursor_move( &self.common, modifier_handler, mouse_handler, @@ -417,48 +426,49 @@ impl Canvas { ) } - pub fn on_touch_cancel(&mut self, handler: F) + pub fn on_touch_cancel(&self, handler: F) where F: 'static + FnMut(i32, PhysicalPosition, Force), { - self.pointer_handler.on_touch_cancel(&self.common, handler) + self.handlers.borrow_mut().pointer_handler.on_touch_cancel(&self.common, handler) } - pub fn on_mouse_wheel(&mut self, mut handler: F) + pub fn on_mouse_wheel(&self, mut handler: F) where F: 'static + FnMut(i32, MouseScrollDelta, ModifiersState), { let window = self.common.window.clone(); let prevent_default = Rc::clone(&self.prevent_default); - self.on_mouse_wheel = Some(self.common.add_event("wheel", move |event: WheelEvent| { - if prevent_default.get() { - event.prevent_default(); - } + self.handlers.borrow_mut().on_mouse_wheel = + Some(self.common.add_event("wheel", move |event: WheelEvent| { + if prevent_default.get() { + event.prevent_default(); + } - if let Some(delta) = event::mouse_scroll_delta(&window, &event) { - let modifiers = event::mouse_modifiers(&event); - handler(0, delta, modifiers); - } - })); + if let Some(delta) = event::mouse_scroll_delta(&window, &event) { + let modifiers = event::mouse_modifiers(&event); + handler(0, delta, modifiers); + } + })); } - pub fn on_dark_mode(&mut self, mut handler: F) + pub fn on_dark_mode(&self, mut handler: F) where F: 'static + FnMut(bool), { - self.on_dark_mode = Some(MediaQueryListHandle::new( + self.handlers.borrow_mut().on_dark_mode = Some(MediaQueryListHandle::new( &self.common.window, "(prefers-color-scheme: dark)", move |mql| handler(mql.matches()), )); } - pub(crate) fn on_resize_scale(&mut self, scale_handler: S, size_handler: R) + pub(crate) fn on_resize_scale(&self, scale_handler: S, size_handler: R) where S: 'static + Fn(PhysicalSize, f64), R: 'static + Fn(PhysicalSize), { - self.on_resize_scale = Some(ResizeScaleHandle::new( + self.handlers.borrow_mut().on_resize_scale = Some(ResizeScaleHandle::new( self.window().clone(), self.document().clone(), self.raw().clone(), @@ -468,23 +478,24 @@ impl Canvas { )); } - pub(crate) fn on_intersection(&mut self, handler: F) + pub(crate) fn on_intersection(&self, handler: F) where F: 'static + FnMut(bool), { - self.on_intersect = Some(IntersectionObserverHandle::new(self.raw(), handler)); + self.handlers.borrow_mut().on_intersect = + Some(IntersectionObserverHandle::new(self.raw(), handler)); } - pub(crate) fn on_animation_frame(&mut self, f: F) + pub(crate) fn on_animation_frame(&self, f: F) where F: 'static + FnMut(), { - self.animation_frame_handler.on_animation_frame(f) + self.handlers.borrow_mut().animation_frame_handler.on_animation_frame(f) } - pub(crate) fn on_context_menu(&mut self) { + pub(crate) fn on_context_menu(&self) { let prevent_default = Rc::clone(&self.prevent_default); - self.on_context_menu = + self.handlers.borrow_mut().on_context_menu = Some(self.common.add_event("contextmenu", move |event: PointerEvent| { if prevent_default.get() { event.prevent_default(); @@ -511,7 +522,7 @@ impl Canvas { } pub fn request_animation_frame(&self) { - self.animation_frame_handler.request(); + self.handlers.borrow().animation_frame_handler.request(); } pub(crate) fn handle_scale_change( @@ -544,7 +555,9 @@ impl Canvas { super::set_canvas_size(self.document(), self.raw(), self.style(), new_size); // Set the size might not trigger the event because the calculation is inaccurate. - self.on_resize_scale + self.handlers + .borrow() + .on_resize_scale .as_ref() .expect("expected Window to still be active") .notify_resize(); @@ -558,20 +571,21 @@ impl Canvas { } } - pub fn remove_listeners(&mut self) { - self.on_touch_start = None; - self.on_focus = None; - self.on_blur = None; - self.on_keyboard_release = None; - self.on_keyboard_press = None; - self.on_mouse_wheel = None; - self.on_dark_mode = None; - self.pointer_handler.remove_listeners(); - self.on_resize_scale = None; - self.on_intersect = None; - self.animation_frame_handler.cancel(); - self.on_touch_end = None; - self.on_context_menu = None; + pub fn remove_listeners(&self) { + let mut handlers = self.handlers.borrow_mut(); + handlers.on_touch_start.take(); + handlers.on_focus.take(); + handlers.on_blur.take(); + handlers.on_keyboard_release.take(); + handlers.on_keyboard_press.take(); + handlers.on_mouse_wheel.take(); + handlers.on_dark_mode.take(); + handlers.pointer_handler.remove_listeners(); + handlers.on_resize_scale = None; + handlers.on_intersect = None; + handlers.animation_frame_handler.cancel(); + handlers.on_touch_end = None; + handlers.on_context_menu = None; } } diff --git a/src/platform_impl/web/window.rs b/src/platform_impl/web/window.rs index 97bef7e28f..6ff93cc57d 100644 --- a/src/platform_impl/web/window.rs +++ b/src/platform_impl/web/window.rs @@ -1,4 +1,4 @@ -use std::cell::RefCell; +use std::cell::Ref; use std::rc::Rc; use std::sync::Arc; @@ -24,7 +24,7 @@ pub struct Inner { id: WindowId, pub window: web_sys::Window, monitor: Rc, - canvas: Rc>, + canvas: Rc, destroy_fn: Option>, } @@ -41,7 +41,7 @@ impl Window { document.clone(), attr, )?; - let canvas = Rc::new(RefCell::new(canvas)); + let canvas = Rc::new(canvas); target.register(&canvas, id); @@ -71,17 +71,17 @@ impl Window { self.inner.queue(f) } - pub fn canvas(&self) -> Option { + pub fn canvas(&self) -> Option> { MainThreadMarker::new() - .map(|main_thread| self.inner.value(main_thread).canvas.borrow().raw().clone()) + .map(|main_thread| Ref::map(self.inner.value(main_thread), |inner| inner.canvas.raw())) } pub(crate) fn prevent_default(&self) -> bool { - self.inner.queue(|inner| inner.canvas.borrow().prevent_default.get()) + self.inner.queue(|inner| inner.canvas.prevent_default.get()) } pub(crate) fn set_prevent_default(&self, prevent_default: bool) { - self.inner.dispatch(move |inner| inner.canvas.borrow().prevent_default.set(prevent_default)) + self.inner.dispatch(move |inner| inner.canvas.prevent_default.set(prevent_default)) } #[cfg(feature = "rwh_06")] @@ -90,9 +90,8 @@ impl Window { MainThreadMarker::new() .map(|main_thread| { let inner = self.inner.value(main_thread); - let canvas = inner.canvas.borrow(); // SAFETY: This will only work if the reference to `HtmlCanvasElement` stays valid. - let canvas: &wasm_bindgen::JsValue = canvas.raw(); + let canvas: &wasm_bindgen::JsValue = inner.canvas.raw(); let window_handle = rwh_06::WebCanvasWindowHandle::new(std::ptr::NonNull::from(canvas).cast()); rwh_06::RawWindowHandle::WebCanvas(window_handle) @@ -111,7 +110,7 @@ impl Window { impl Inner { pub fn set_title(&self, title: &str) { - self.canvas.borrow().set_title(title) + self.canvas.set_title(title) } pub fn set_transparent(&self, _transparent: bool) {} @@ -119,7 +118,7 @@ impl Inner { pub fn set_blur(&self, _blur: bool) {} pub fn set_visible(&self, visible: bool) { - self.canvas.borrow().set_visible(visible); + self.canvas.set_visible(visible); } #[inline] @@ -128,13 +127,13 @@ impl Inner { } pub fn request_redraw(&self) { - self.canvas.borrow().request_animation_frame(); + self.canvas.request_animation_frame(); } pub fn pre_present_notify(&self) {} pub fn outer_position(&self) -> Result, NotSupportedError> { - Ok(self.canvas.borrow().position().to_physical(self.scale_factor())) + Ok(self.canvas.position().to_physical(self.scale_factor())) } pub fn inner_position(&self) -> Result, NotSupportedError> { @@ -143,15 +142,19 @@ impl Inner { } pub fn set_outer_position(&self, position: Position) { - let canvas = self.canvas.borrow(); let position = position.to_logical::(self.scale_factor()); - backend::set_canvas_position(canvas.document(), canvas.raw(), canvas.style(), position) + backend::set_canvas_position( + self.canvas.document(), + self.canvas.raw(), + self.canvas.style(), + position, + ) } #[inline] pub fn inner_size(&self) -> PhysicalSize { - self.canvas.borrow().inner_size() + self.canvas.inner_size() } #[inline] @@ -163,23 +166,35 @@ impl Inner { #[inline] pub fn request_inner_size(&self, size: Size) -> Option> { let size = size.to_logical(self.scale_factor()); - let canvas = self.canvas.borrow(); - backend::set_canvas_size(canvas.document(), canvas.raw(), canvas.style(), size); + backend::set_canvas_size( + self.canvas.document(), + self.canvas.raw(), + self.canvas.style(), + size, + ); None } #[inline] pub fn set_min_inner_size(&self, dimensions: Option) { let dimensions = dimensions.map(|dimensions| dimensions.to_logical(self.scale_factor())); - let canvas = self.canvas.borrow(); - backend::set_canvas_min_size(canvas.document(), canvas.raw(), canvas.style(), dimensions) + backend::set_canvas_min_size( + self.canvas.document(), + self.canvas.raw(), + self.canvas.style(), + dimensions, + ) } #[inline] pub fn set_max_inner_size(&self, dimensions: Option) { let dimensions = dimensions.map(|dimensions| dimensions.to_logical(self.scale_factor())); - let canvas = self.canvas.borrow(); - backend::set_canvas_max_size(canvas.document(), canvas.raw(), canvas.style(), dimensions) + backend::set_canvas_max_size( + self.canvas.document(), + self.canvas.raw(), + self.canvas.style(), + dimensions, + ) } #[inline] @@ -216,7 +231,7 @@ impl Inner { #[inline] pub fn set_cursor(&self, cursor: Cursor) { - self.canvas.borrow().set_cursor(cursor) + self.canvas.set_cursor(cursor) } #[inline] @@ -234,12 +249,12 @@ impl Inner { }, }; - self.canvas.borrow().set_cursor_lock(lock).map_err(ExternalError::Os) + self.canvas.set_cursor_lock(lock).map_err(ExternalError::Os) } #[inline] pub fn set_cursor_visible(&self, visible: bool) { - self.canvas.borrow().set_cursor_visible(visible) + self.canvas.set_cursor_visible(visible) } #[inline] @@ -273,7 +288,7 @@ impl Inner { #[inline] pub fn set_maximized(&self, maximized: bool) { - self.canvas.borrow().set_maximized(maximized) + self.canvas.set_maximized(maximized) } #[inline] @@ -284,7 +299,7 @@ impl Inner { #[inline] pub(crate) fn fullscreen(&self) -> Option { - if self.canvas.borrow().is_fullscreen() { + if self.canvas.is_fullscreen() { Some(Fullscreen::Borderless(None)) } else { None @@ -293,12 +308,10 @@ impl Inner { #[inline] pub(crate) fn set_fullscreen(&self, fullscreen: Option) { - let canvas = &self.canvas.borrow(); - if let Some(fullscreen) = fullscreen { - canvas.request_fullscreen(fullscreen); + self.canvas.request_fullscreen(fullscreen); } else { - canvas.exit_fullscreen() + self.canvas.exit_fullscreen() } } @@ -318,7 +331,7 @@ impl Inner { #[inline] pub fn set_window_icon(&self, window_icon: Option) { - self.canvas.borrow().set_window_icon(window_icon); + self.canvas.set_window_icon(window_icon); } #[inline] @@ -338,7 +351,7 @@ impl Inner { #[inline] pub fn focus_window(&self) { - let _ = self.canvas.borrow().raw().focus(); + let _ = self.canvas.raw().focus(); } #[inline] @@ -406,7 +419,7 @@ impl Inner { #[inline] pub fn has_focus(&self) -> bool { - self.canvas.borrow().has_focus.get() + self.canvas.has_focus.get() } pub fn title(&self) -> String {