From 85446d81f3f3d4bde288f8ad55b6ccf43a198b06 Mon Sep 17 00:00:00 2001 From: Ryan Goldstein Date: Sat, 16 Mar 2019 18:51:11 -0400 Subject: [PATCH] Fix warnings --- src/platform_impl/stdweb/event_loop.rs | 20 ++++------------ src/platform_impl/stdweb/window.rs | 33 ++++++++++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/platform_impl/stdweb/event_loop.rs b/src/platform_impl/stdweb/event_loop.rs index 68a5efee..ea2b9acd 100644 --- a/src/platform_impl/stdweb/event_loop.rs +++ b/src/platform_impl/stdweb/event_loop.rs @@ -1,21 +1,18 @@ use super::*; -use dpi::{LogicalPosition, LogicalSize}; -use event::{DeviceEvent, DeviceId as RootDI, ElementState, Event, KeyboardInput, ModifiersState, MouseButton, ScanCode, StartCause, VirtualKeyCode, WindowEvent}; +use dpi::LogicalPosition; +use event::{DeviceId as RootDI, ElementState, Event, KeyboardInput, StartCause, WindowEvent}; use event_loop::{ControlFlow, EventLoopWindowTarget as RootELW, EventLoopClosed}; -use icon::Icon; -use window::{MouseCursor, WindowId as RootWI}; +use window::{WindowId as RootWI}; use stdweb::{ - JsSerialize, traits::*, - unstable::TryInto, web::{ document, event::*, html_element::CanvasElement, }, }; -use std::cell::{RefCell, RefMut}; +use std::cell::RefCell; use std::collections::VecDeque; use std::collections::vec_deque::IntoIter as VecDequeIter; use std::marker::PhantomData; @@ -91,7 +88,7 @@ impl EventLoop { MonitorHandle } - pub fn run(mut self, mut event_handler: F) -> ! + pub fn run(self, mut event_handler: F) -> ! where F: 'static + FnMut(Event, &RootELW, &mut ControlFlow) { // TODO: how to handle request redraw? @@ -248,13 +245,6 @@ fn add_event(elrs: &EventLoopRunnerShared, target: &impl IE } impl ELRShared { - fn blank() -> ELRShared { - ELRShared { - runner: RefCell::new(None), - events: RefCell::new(VecDeque::new()) - } - } - fn set_listener(&self, event_handler: Box, &mut ControlFlow)>) { *self.runner.borrow_mut() = Some(EventLoopRunner { control: ControlFlow::Poll, diff --git a/src/platform_impl/stdweb/window.rs b/src/platform_impl/stdweb/window.rs index a66bc191..df875f03 100644 --- a/src/platform_impl/stdweb/window.rs +++ b/src/platform_impl/stdweb/window.rs @@ -3,9 +3,10 @@ use event::{Event, WindowEvent}; use icon::Icon; use monitor::{MonitorHandle as RootMH}; use window::{CreationError, MouseCursor, WindowAttributes, WindowId as RootWI}; -use super::{EventLoopWindowTarget, EventLoopRunnerShared, register}; +use super::{EventLoopWindowTarget, register}; use std::collections::VecDeque; use std::collections::vec_deque::IntoIter as VecDequeIter; +use std::cell::RefCell; use stdweb::{ traits::*, unstable::TryInto @@ -51,7 +52,8 @@ impl WindowId { pub struct Window { pub(crate) canvas: CanvasElement, - pub(crate) redraw: Box + pub(crate) redraw: Box, + previous_pointer: RefCell<&'static str> } impl Window { @@ -76,7 +78,8 @@ impl Window { let window = Window { canvas, - redraw + redraw, + previous_pointer: RefCell::new("auto") }; if let Some(dimensions) = attr.dimensions { @@ -135,7 +138,7 @@ impl Window { None } - pub fn set_position(&self, position: LogicalPosition) { + pub fn set_position(&self, _position: LogicalPosition) { // TODO: use CSS? } @@ -223,35 +226,41 @@ impl Window { MouseCursor::ColResize => "col-resize", MouseCursor::RowResize => "row-resize", }; + *self.previous_pointer.borrow_mut() = text; self.canvas.set_attribute("cursor", text) .expect("Setting the cursor on the canvas"); } #[inline] - pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), String> { + pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), String> { // TODO: pointer capture Ok(()) } #[inline] - pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { + pub fn grab_cursor(&self, _grab: bool) -> Result<(), String> { // TODO: pointer capture Ok(()) } #[inline] pub fn hide_cursor(&self, hide: bool) { - self.canvas.set_attribute("cursor", "none") - .expect("Setting the cursor on the canvas"); + if hide { + self.canvas.set_attribute("cursor", "none") + .expect("Setting the cursor on the canvas"); + } else { + self.canvas.set_attribute("cursor", *self.previous_pointer.borrow()) + .expect("Setting the cursor on the canvas"); + } } #[inline] - pub fn set_maximized(&self, maximized: bool) { + pub fn set_maximized(&self, _maximized: bool) { // TODO: should there be a maximization / fullscreen API? } #[inline] - pub fn set_fullscreen(&self, monitor: Option) { + pub fn set_fullscreen(&self, _monitor: Option) { // TODO: should there be a maximization / fullscreen API? } @@ -266,12 +275,12 @@ impl Window { } #[inline] - pub fn set_window_icon(&self, window_icon: Option) { + pub fn set_window_icon(&self, _window_icon: Option) { // TODO: should this set the favicon? } #[inline] - pub fn set_ime_spot(&self, position: LogicalPosition) { + pub fn set_ime_spot(&self, _position: LogicalPosition) { // TODO: what is this? }