From 6732fa731df4e84cb001ee1cf25a2e127bd6a8ea Mon Sep 17 00:00:00 2001 From: Ryan Goldstein Date: Tue, 24 Sep 2019 19:39:13 -0400 Subject: [PATCH] Fix compilation errors --- Cargo.toml | 2 +- src/platform_impl/web/event_loop/proxy.rs | 11 +++++++-- src/platform_impl/web/mod.rs | 4 +++- src/platform_impl/web/monitor.rs | 27 ++++++++++++++++++++++- src/platform_impl/web/window.rs | 18 ++++++++++++--- 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b3446b4c..9aa5d983 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ libc = "0.2" log = "0.4" serde = { version = "1", optional = true, features = ["serde_derive"] } derivative = "1.0.2" -raw-window-handle = "0.1" +raw-window-handle = { git = "https://github.com/ryanisaacg/raw-window-handle", branch = "add-web-support" } [dev-dependencies] image = "0.21" diff --git a/src/platform_impl/web/event_loop/proxy.rs b/src/platform_impl/web/event_loop/proxy.rs index cbc4732e..ad9a35f7 100644 --- a/src/platform_impl/web/event_loop/proxy.rs +++ b/src/platform_impl/web/event_loop/proxy.rs @@ -2,8 +2,7 @@ use super::runner; use crate::event::Event; use crate::event_loop::EventLoopClosed; -#[derive(Clone)] -pub struct Proxy { +pub struct Proxy{ runner: runner::Shared, } @@ -17,3 +16,11 @@ impl Proxy { Ok(()) } } + +impl Clone for Proxy { + fn clone(&self) -> Self { + Proxy { + runner: self.runner.clone() + } + } +} diff --git a/src/platform_impl/web/mod.rs b/src/platform_impl/web/mod.rs index 7715336a..a272835d 100644 --- a/src/platform_impl/web/mod.rs +++ b/src/platform_impl/web/mod.rs @@ -21,7 +21,9 @@ pub use self::error::OsError; pub use self::event_loop::{ EventLoop, Proxy as EventLoopProxy, WindowTarget as EventLoopWindowTarget, }; -pub use self::monitor::Handle as MonitorHandle; +pub use self::monitor::{ + Handle as MonitorHandle, Mode as VideoMode +}; pub use self::window::{ Id as WindowId, PlatformSpecificBuilderAttributes as PlatformSpecificWindowBuilderAttributes, Window, diff --git a/src/platform_impl/web/monitor.rs b/src/platform_impl/web/monitor.rs index 1aeaa320..196c23c8 100644 --- a/src/platform_impl/web/monitor.rs +++ b/src/platform_impl/web/monitor.rs @@ -1,5 +1,5 @@ use crate::dpi::{PhysicalPosition, PhysicalSize}; -use crate::monitor::VideoMode; +use crate::monitor::{MonitorHandle, VideoMode}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Handle; @@ -26,3 +26,28 @@ impl Handle { std::iter::empty() } } + +#[derive(Derivative)] +#[derivative(Clone, Debug, PartialEq, Eq, Hash)] +pub struct Mode; + +impl Mode { + pub fn size(&self) -> PhysicalSize { + unimplemented!(); + } + + pub fn bit_depth(&self) -> u16 { + unimplemented!(); + } + + pub fn refresh_rate(&self) -> u16 { + 32 + } + + pub fn monitor(&self) -> MonitorHandle { + MonitorHandle { + inner: Handle + } + } +} + diff --git a/src/platform_impl/web/window.rs b/src/platform_impl/web/window.rs index 5a14c6db..0ac1cdc2 100644 --- a/src/platform_impl/web/window.rs +++ b/src/platform_impl/web/window.rs @@ -2,7 +2,9 @@ use crate::dpi::{LogicalPosition, LogicalSize}; use crate::error::{ExternalError, NotSupportedError, OsError as RootOE}; use crate::icon::Icon; use crate::monitor::MonitorHandle as RootMH; -use crate::window::{CursorIcon, WindowAttributes, WindowId as RootWI}; +use crate::window::{CursorIcon, Fullscreen, WindowAttributes, WindowId as RootWI}; + +use raw_window_handle::{RawWindowHandle, web::WebHandle}; use super::{backend, monitor, EventLoopWindowTarget}; @@ -203,13 +205,13 @@ impl Window { } #[inline] - pub fn fullscreen(&self) -> Option { + pub fn fullscreen(&self) -> Option { // TODO: should there be a maximization / fullscreen API? None } #[inline] - pub fn set_fullscreen(&self, _monitor: Option) { + pub fn set_fullscreen(&self, _monitor: Option) { // TODO: should there be a maximization / fullscreen API? } @@ -254,6 +256,16 @@ impl Window { pub fn id(&self) -> Id { return self.id; } + + #[inline] + pub fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle { + let handle = WebHandle { + id: self.id.0, + ..WebHandle::empty() + }; + + raw_window_handle::RawWindowHandle::Web(handle) + } } #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]