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 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<T> EventLoop<T> {
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)
{
// 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> {
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)>) {
*self.runner.borrow_mut() = Some(EventLoopRunner {
control: ControlFlow::Poll,

View file

@ -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<dyn Fn()>
pub(crate) redraw: Box<dyn Fn()>,
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<RootMH>) {
pub fn set_fullscreen(&self, _monitor: Option<RootMH>) {
// TODO: should there be a maximization / fullscreen API?
}
@ -266,12 +275,12 @@ impl Window {
}
#[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?
}
#[inline]
pub fn set_ime_spot(&self, position: LogicalPosition) {
pub fn set_ime_spot(&self, _position: LogicalPosition) {
// TODO: what is this?
}