Fix warnings

This commit is contained in:
Ryan Goldstein 2019-03-16 18:51:11 -04:00
parent 96786bbb87
commit 85446d81f3
2 changed files with 26 additions and 27 deletions

View file

@ -1,21 +1,18 @@
use super::*; use super::*;
use dpi::{LogicalPosition, LogicalSize}; use dpi::LogicalPosition;
use event::{DeviceEvent, DeviceId as RootDI, ElementState, Event, KeyboardInput, ModifiersState, MouseButton, ScanCode, StartCause, VirtualKeyCode, WindowEvent}; use event::{DeviceId as RootDI, ElementState, Event, KeyboardInput, StartCause, WindowEvent};
use event_loop::{ControlFlow, EventLoopWindowTarget as RootELW, EventLoopClosed}; use event_loop::{ControlFlow, EventLoopWindowTarget as RootELW, EventLoopClosed};
use icon::Icon; use window::{WindowId as RootWI};
use window::{MouseCursor, WindowId as RootWI};
use stdweb::{ use stdweb::{
JsSerialize,
traits::*, traits::*,
unstable::TryInto,
web::{ web::{
document, document,
event::*, event::*,
html_element::CanvasElement, html_element::CanvasElement,
}, },
}; };
use std::cell::{RefCell, RefMut}; use std::cell::RefCell;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::collections::vec_deque::IntoIter as VecDequeIter; use std::collections::vec_deque::IntoIter as VecDequeIter;
use std::marker::PhantomData; use std::marker::PhantomData;
@ -91,7 +88,7 @@ impl<T> EventLoop<T> {
MonitorHandle MonitorHandle
} }
pub fn run<F>(mut self, mut event_handler: F) -> ! pub fn run<F>(self, mut event_handler: F) -> !
where F: 'static + FnMut(Event<T>, &RootELW<T>, &mut ControlFlow) where F: 'static + FnMut(Event<T>, &RootELW<T>, &mut ControlFlow)
{ {
// TODO: how to handle request redraw? // TODO: how to handle request redraw?
@ -248,13 +245,6 @@ fn add_event<T: 'static, E, F>(elrs: &EventLoopRunnerShared<T>, target: &impl IE
} }
impl<T> ELRShared<T> { impl<T> ELRShared<T> {
fn blank() -> ELRShared<T> {
ELRShared {
runner: RefCell::new(None),
events: RefCell::new(VecDeque::new())
}
}
fn set_listener(&self, event_handler: Box<dyn FnMut(Event<T>, &mut ControlFlow)>) { fn set_listener(&self, event_handler: Box<dyn FnMut(Event<T>, &mut ControlFlow)>) {
*self.runner.borrow_mut() = Some(EventLoopRunner { *self.runner.borrow_mut() = Some(EventLoopRunner {
control: ControlFlow::Poll, control: ControlFlow::Poll,

View file

@ -3,9 +3,10 @@ use event::{Event, WindowEvent};
use icon::Icon; use icon::Icon;
use monitor::{MonitorHandle as RootMH}; use monitor::{MonitorHandle as RootMH};
use window::{CreationError, MouseCursor, WindowAttributes, WindowId as RootWI}; use window::{CreationError, MouseCursor, WindowAttributes, WindowId as RootWI};
use super::{EventLoopWindowTarget, EventLoopRunnerShared, register}; use super::{EventLoopWindowTarget, register};
use std::collections::VecDeque; use std::collections::VecDeque;
use std::collections::vec_deque::IntoIter as VecDequeIter; use std::collections::vec_deque::IntoIter as VecDequeIter;
use std::cell::RefCell;
use stdweb::{ use stdweb::{
traits::*, traits::*,
unstable::TryInto unstable::TryInto
@ -51,7 +52,8 @@ impl WindowId {
pub struct Window { pub struct Window {
pub(crate) canvas: CanvasElement, pub(crate) canvas: CanvasElement,
pub(crate) redraw: Box<dyn Fn()> pub(crate) redraw: Box<dyn Fn()>,
previous_pointer: RefCell<&'static str>
} }
impl Window { impl Window {
@ -76,7 +78,8 @@ impl Window {
let window = Window { let window = Window {
canvas, canvas,
redraw redraw,
previous_pointer: RefCell::new("auto")
}; };
if let Some(dimensions) = attr.dimensions { if let Some(dimensions) = attr.dimensions {
@ -135,7 +138,7 @@ impl Window {
None None
} }
pub fn set_position(&self, position: LogicalPosition) { pub fn set_position(&self, _position: LogicalPosition) {
// TODO: use CSS? // TODO: use CSS?
} }
@ -223,35 +226,41 @@ impl Window {
MouseCursor::ColResize => "col-resize", MouseCursor::ColResize => "col-resize",
MouseCursor::RowResize => "row-resize", MouseCursor::RowResize => "row-resize",
}; };
*self.previous_pointer.borrow_mut() = text;
self.canvas.set_attribute("cursor", text) self.canvas.set_attribute("cursor", text)
.expect("Setting the cursor on the canvas"); .expect("Setting the cursor on the canvas");
} }
#[inline] #[inline]
pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), String> { pub fn set_cursor_position(&self, _position: LogicalPosition) -> Result<(), String> {
// TODO: pointer capture // TODO: pointer capture
Ok(()) Ok(())
} }
#[inline] #[inline]
pub fn grab_cursor(&self, grab: bool) -> Result<(), String> { pub fn grab_cursor(&self, _grab: bool) -> Result<(), String> {
// TODO: pointer capture // TODO: pointer capture
Ok(()) Ok(())
} }
#[inline] #[inline]
pub fn hide_cursor(&self, hide: bool) { pub fn hide_cursor(&self, hide: bool) {
if hide {
self.canvas.set_attribute("cursor", "none") self.canvas.set_attribute("cursor", "none")
.expect("Setting the cursor on the canvas"); .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] #[inline]
pub fn set_maximized(&self, maximized: bool) { pub fn set_maximized(&self, _maximized: bool) {
// TODO: should there be a maximization / fullscreen API? // TODO: should there be a maximization / fullscreen API?
} }
#[inline] #[inline]
pub fn set_fullscreen(&self, monitor: Option<RootMH>) { pub fn set_fullscreen(&self, _monitor: Option<RootMH>) {
// TODO: should there be a maximization / fullscreen API? // TODO: should there be a maximization / fullscreen API?
} }
@ -266,12 +275,12 @@ impl Window {
} }
#[inline] #[inline]
pub fn set_window_icon(&self, window_icon: Option<Icon>) { pub fn set_window_icon(&self, _window_icon: Option<Icon>) {
// TODO: should this set the favicon? // TODO: should this set the favicon?
} }
#[inline] #[inline]
pub fn set_ime_spot(&self, position: LogicalPosition) { pub fn set_ime_spot(&self, _position: LogicalPosition) {
// TODO: what is this? // TODO: what is this?
} }