Rename EventsLoop and associated types to EventLoop

This commit is contained in:
Osspial
2018-07-12 22:04:38 -04:00
parent 30aa5a5057
commit 529c08555f
38 changed files with 246 additions and 247 deletions

View File

@@ -3,7 +3,7 @@ extern crate winit;
use winit::{Event, ElementState, MouseCursor, WindowEvent, KeyboardInput, ControlFlow};
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
window.set_title("A fantastic window!");

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let window = winit::WindowBuilder::new()
.with_title("Super Cursor Grab'n'Hide Simulator 9000")

View File

@@ -4,7 +4,7 @@ use std::io::{self, Write};
use winit::{ControlFlow, Event, WindowEvent};
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
// enumerating monitors
let monitor = {

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let _window = winit::WindowBuilder::new()
.with_title("Your faithful window")

View File

@@ -3,7 +3,7 @@ extern crate winit;
use winit::dpi::LogicalSize;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let window = winit::WindowBuilder::new()
.build(&events_loop)

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let event_loop = winit::EventsLoop::new();
let event_loop = winit::EventLoop::new();
let window = winit::WindowBuilder::new().build(&event_loop).unwrap();
println!("{:#?}\nPrimary: {:#?}", window.get_available_monitors(), window.get_primary_monitor());
}

View File

@@ -3,7 +3,7 @@ extern crate winit;
use std::collections::HashMap;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let mut windows = HashMap::new();
for _ in 0..3 {

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let _window = winit::WindowBuilder::new()
.with_title("A fantastic window!")

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let mut resizable = false;

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let window = winit::WindowBuilder::new().with_decorations(false)
.with_transparency(true)

View File

@@ -1,7 +1,7 @@
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let _window = winit::WindowBuilder::new()
.with_title("A fantastic window!")

View File

@@ -20,7 +20,7 @@ fn main() {
// feature enabled).
let icon = Icon::from_path(path).expect("Failed to open icon");
let mut events_loop = winit::EventsLoop::new();
let mut events_loop = winit::EventLoop::new();
let window = winit::WindowBuilder::new()
.with_title("An iconic window!")

View File

@@ -2,12 +2,12 @@
//!
//! # Building a window
//!
//! Before you can build a window, you first need to build an `EventsLoop`. This is done with the
//! `EventsLoop::new()` function. Example:
//! Before you can build a window, you first need to build an `EventLoop`. This is done with the
//! `EventLoop::new()` function. Example:
//!
//! ```no_run
//! use winit::EventsLoop;
//! let events_loop = EventsLoop::new();
//! use winit::EventLoop;
//! let events_loop = EventLoop::new();
//! ```
//!
//! Once this is done there are two ways to create a window:
@@ -25,7 +25,7 @@
//! Once a window has been created, it will *generate events*. For example whenever the user moves
//! the window, resizes the window, moves the mouse, etc. an event is generated.
//!
//! The events generated by a window can be retrieved from the `EventsLoop` the window was created
//! The events generated by a window can be retreived from the `EventLoop` the window was created
//! with.
//!
//! There are two ways to do so. The first is to call `events_loop.poll_events(...)`, which will
@@ -36,8 +36,8 @@
//! ```no_run
//! use winit::{Event, WindowEvent};
//! use winit::dpi::LogicalSize;
//! # use winit::EventsLoop;
//! # let mut events_loop = EventsLoop::new();
//! # use winit::EventLoop;
//! # let mut events_loop = EventLoop::new();
//!
//! loop {
//! events_loop.poll_events(|event| {
@@ -59,8 +59,8 @@
//!
//! ```no_run
//! use winit::{ControlFlow, Event, WindowEvent};
//! # use winit::EventsLoop;
//! # let mut events_loop = EventsLoop::new();
//! # use winit::EventLoop;
//! # let mut events_loop = EventLoop::new();
//!
//! events_loop.run_forever(|event| {
//! match event {
@@ -134,9 +134,9 @@ pub mod os;
/// # Example
///
/// ```no_run
/// use winit::{Event, EventsLoop, Window, WindowEvent, ControlFlow};
/// use winit::{Event, EventLoop, Window, WindowEvent, ControlFlow};
///
/// let mut events_loop = EventsLoop::new();
/// let mut events_loop = EventLoop::new();
/// let window = Window::new(&events_loop).unwrap();
///
/// events_loop.run_forever(|event| {
@@ -178,28 +178,28 @@ pub struct DeviceId(platform::DeviceId);
/// Provides a way to retrieve events from the system and from the windows that were registered to
/// the events loop.
///
/// An `EventsLoop` can be seen more or less as a "context". Calling `EventsLoop::new()`
/// An `EventLoop` can be seen more or less as a "context". Calling `EventLoop::new()`
/// initializes everything that will be required to create windows. For example on Linux creating
/// an events loop opens a connection to the X or Wayland server.
///
/// To wake up an `EventsLoop` from a another thread, see the `EventsLoopProxy` docs.
/// To wake up an `EventLoop` from a another thread, see the `EventLoopProxy` docs.
///
/// Note that the `EventsLoop` cannot be shared accross threads (due to platform-dependant logic
/// Note that the `EventLoop` cannot be shared accross threads (due to platform-dependant logic
/// forbiding it), as such it is neither `Send` nor `Sync`. If you need cross-thread access, the
/// `Window` created from this `EventsLoop` _can_ be sent to an other thread, and the
/// `EventsLoopProxy` allows you to wakeup an `EventsLoop` from an other thread.
pub struct EventsLoop {
events_loop: platform::EventsLoop,
/// `Window` created from this `EventLoop` _can_ be sent to an other thread, and the
/// `EventLoopProxy` allows you to wakeup an `EventLoop` from an other thread.
pub struct EventLoop {
events_loop: platform::EventLoop,
_marker: ::std::marker::PhantomData<*mut ()> // Not Send nor Sync
}
impl std::fmt::Debug for EventsLoop {
impl std::fmt::Debug for EventLoop {
fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result {
fmtr.pad("EventsLoop { .. }")
fmtr.pad("EventLoop { .. }")
}
}
/// Returned by the user callback given to the `EventsLoop::run_forever` method.
/// Returned by the user callback given to the `EventLoop::run_forever` method.
///
/// Indicates whether the `run_forever` method should continue or complete.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
@@ -211,16 +211,16 @@ pub enum ControlFlow {
Break,
}
impl EventsLoop {
impl EventLoop {
/// Builds a new events loop.
///
/// Usage will result in display backend initialisation, this can be controlled on linux
/// using an environment variable `WINIT_UNIX_BACKEND`. Legal values are `x11` and `wayland`.
/// If it is not set, winit will try to connect to a wayland connection, and if it fails will
/// fallback on x11. If this variable is set with any other value, winit will panic.
pub fn new() -> EventsLoop {
EventsLoop {
events_loop: platform::EventsLoop::new(),
pub fn new() -> EventLoop {
EventLoop {
events_loop: platform::EventLoop::new(),
_marker: ::std::marker::PhantomData,
}
}
@@ -264,52 +264,52 @@ impl EventsLoop {
self.events_loop.run_forever(callback)
}
/// Creates an `EventsLoopProxy` that can be used to wake up the `EventsLoop` from another
/// Creates an `EventLoopProxy` that can be used to wake up the `EventLoop` from another
/// thread.
pub fn create_proxy(&self) -> EventsLoopProxy {
EventsLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy {
events_loop_proxy: self.events_loop.create_proxy(),
}
}
}
/// Used to wake up the `EventsLoop` from another thread.
/// Used to wake up the `EventLoop` from another thread.
#[derive(Clone)]
pub struct EventsLoopProxy {
events_loop_proxy: platform::EventsLoopProxy,
pub struct EventLoopProxy {
events_loop_proxy: platform::EventLoopProxy,
}
impl std::fmt::Debug for EventsLoopProxy {
impl std::fmt::Debug for EventLoopProxy {
fn fmt(&self, fmtr: &mut std::fmt::Formatter) -> std::fmt::Result {
fmtr.pad("EventsLoopProxy { .. }")
fmtr.pad("EventLoopProxy { .. }")
}
}
impl EventsLoopProxy {
/// Wake up the `EventsLoop` from which this proxy was created.
impl EventLoopProxy {
/// Wake up the `EventLoop` from which this proxy was created.
///
/// This causes the `EventsLoop` to emit an `Awakened` event.
/// This causes the `EventLoop` to emit an `Awakened` event.
///
/// Returns an `Err` if the associated `EventsLoop` no longer exists.
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
/// Returns an `Err` if the associated `EventLoop` no longer exists.
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
self.events_loop_proxy.wakeup()
}
}
/// The error that is returned when an `EventsLoopProxy` attempts to wake up an `EventsLoop` that
/// The error that is returned when an `EventLoopProxy` attempts to wake up an `EventLoop` that
/// no longer exists.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct EventsLoopClosed;
pub struct EventLoopClosed;
impl std::fmt::Display for EventsLoopClosed {
impl std::fmt::Display for EventLoopClosed {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", std::error::Error::description(self))
}
}
impl std::error::Error for EventsLoopClosed {
impl std::error::Error for EventLoopClosed {
fn description(&self) -> &str {
"Tried to wake up a closed `EventsLoop`"
"Tried to wake up a closed `EventLoop`"
}
}

View File

@@ -1,17 +1,17 @@
#![cfg(any(target_os = "android"))]
use std::os::raw::c_void;
use EventsLoop;
use EventLoop;
use Window;
use WindowBuilder;
/// Additional methods on `EventsLoop` that are specific to Android.
pub trait EventsLoopExt {
/// Additional methods on `EventLoop` that are specific to Android.
pub trait EventLoopExt {
/// Makes it possible for glutin to register a callback when a suspend event happens on Android
fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>);
}
impl EventsLoopExt for EventsLoop {
impl EventLoopExt for EventLoop {
fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>) {
self.events_loop.set_suspend_callback(cb);
}

View File

@@ -5,14 +5,14 @@ use std::ptr;
use std::sync::Arc;
use {
EventsLoop,
EventLoop,
LogicalSize,
MonitorId,
Window,
WindowBuilder,
};
use platform::{
EventsLoop as LinuxEventsLoop,
EventLoop as LinuxEventLoop,
Window as LinuxWindow,
};
use platform::x11::XConnection;
@@ -25,31 +25,31 @@ pub use platform::x11;
pub use platform::XNotSupported;
pub use platform::x11::util::WindowType as XWindowType;
/// Additional methods on `EventsLoop` that are specific to Linux.
pub trait EventsLoopExt {
/// Builds a new `EventsLoop` that is forced to use X11.
/// Additional methods on `EventLoop` that are specific to Linux.
pub trait EventLoopExt {
/// Builds a new `EventLoop` that is forced to use X11.
fn new_x11() -> Result<Self, XNotSupported>
where Self: Sized;
/// Builds a new `EventsLoop` that is forced to use Wayland.
/// Builds a new `EventLoop` that is forced to use Wayland.
fn new_wayland() -> Self
where Self: Sized;
/// True if the `EventsLoop` uses Wayland.
/// True if the `EventLoop` uses Wayland.
fn is_wayland(&self) -> bool;
/// True if the `EventsLoop` uses X11.
/// True if the `EventLoop` uses X11.
fn is_x11(&self) -> bool;
#[doc(hidden)]
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
}
impl EventsLoopExt for EventsLoop {
impl EventLoopExt for EventLoop {
#[inline]
fn new_x11() -> Result<Self, XNotSupported> {
LinuxEventsLoop::new_x11().map(|ev|
EventsLoop {
LinuxEventLoop::new_x11().map(|ev|
EventLoop {
events_loop: ev,
_marker: ::std::marker::PhantomData,
}
@@ -58,8 +58,8 @@ impl EventsLoopExt for EventsLoop {
#[inline]
fn new_wayland() -> Self {
EventsLoop {
events_loop: match LinuxEventsLoop::new_wayland() {
EventLoop {
events_loop: match LinuxEventLoop::new_wayland() {
Ok(e) => e,
Err(_) => panic!() // TODO: propagate
},

View File

@@ -5,21 +5,21 @@ use std::os::raw::c_void;
use libc;
use winapi::shared::windef::HWND;
use {DeviceId, EventsLoop, Icon, MonitorId, Window, WindowBuilder};
use platform::EventsLoop as WindowsEventsLoop;
use {DeviceId, EventLoop, Icon, MonitorId, Window, WindowBuilder};
use platform::EventLoop as WindowsEventLoop;
/// Additional methods on `EventsLoop` that are specific to Windows.
pub trait EventsLoopExt {
/// Additional methods on `EventLoop` that are specific to Windows.
pub trait EventLoopExt {
/// By default, winit on Windows will attempt to enable process-wide DPI awareness. If that's
/// undesirable, you can create an `EventsLoop` using this function instead.
/// undesirable, you can create an `EventLoop` using this function instead.
fn new_dpi_unaware() -> Self where Self: Sized;
}
impl EventsLoopExt for EventsLoop {
impl EventLoopExt for EventLoop {
#[inline]
fn new_dpi_unaware() -> Self {
EventsLoop {
events_loop: WindowsEventsLoop::with_dpi_awareness(false),
EventLoop {
events_loop: WindowsEventLoop::with_dpi_awareness(false),
_marker: ::std::marker::PhantomData,
}
}

View File

@@ -26,19 +26,19 @@ use CreationError::OsError;
use events::{Touch, TouchPhase};
use window::MonitorId as RootMonitorId;
pub struct EventsLoop {
pub struct EventLoop {
event_rx: Receiver<android_glue::Event>,
suspend_callback: RefCell<Option<Box<Fn(bool) -> ()>>>,
}
#[derive(Clone)]
pub struct EventsLoopProxy;
pub struct EventLoopProxy;
impl EventsLoop {
pub fn new() -> EventsLoop {
impl EventLoop {
pub fn new() -> EventLoop {
let (tx, rx) = channel();
android_glue::add_sender(tx);
EventsLoop {
EventLoop {
event_rx: rx,
suspend_callback: Default::default(),
}
@@ -155,13 +155,13 @@ impl EventsLoop {
}
}
pub fn create_proxy(&self) -> EventsLoopProxy {
EventsLoopProxy
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy
}
}
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), ::EventsLoopClosed> {
impl EventLoopProxy {
pub fn wakeup(&self) -> Result<(), ::EventLoopClosed> {
android_glue::wake_event_loop();
Ok(())
}
@@ -236,7 +236,7 @@ pub struct PlatformSpecificWindowBuilderAttributes;
pub struct PlatformSpecificHeadlessBuilderAttributes;
impl Window {
pub fn new(_: &EventsLoop, win_attribs: WindowAttributes,
pub fn new(_: &EventLoop, win_attribs: WindowAttributes,
_: PlatformSpecificWindowBuilderAttributes)
-> Result<Window, CreationError>
{

View File

@@ -75,22 +75,22 @@ pub fn set_main_loop_callback<F>(callback : F) where F : FnMut() {
}
#[derive(Clone)]
pub struct EventsLoopProxy;
pub struct EventLoopProxy;
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), ::EventsLoopClosed> {
impl EventLoopProxy {
pub fn wakeup(&self) -> Result<(), ::EventLoopClosed> {
unimplemented!()
}
}
pub struct EventsLoop {
pub struct EventLoop {
window: Mutex<Option<Arc<Window2>>>,
interrupted: AtomicBool,
}
impl EventsLoop {
pub fn new() -> EventsLoop {
EventsLoop {
impl EventLoop {
pub fn new() -> EventLoop {
EventLoop {
window: Mutex::new(None),
interrupted: AtomicBool::new(false),
}
@@ -102,7 +102,7 @@ impl EventsLoop {
}
#[inline]
pub fn create_proxy(&self) -> EventsLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy {
unimplemented!()
}
@@ -366,7 +366,7 @@ fn em_try(res: ffi::EMSCRIPTEN_RESULT) -> Result<(), String> {
}
impl Window {
pub fn new(events_loop: &EventsLoop, attribs: ::WindowAttributes,
pub fn new(events_loop: &EventLoop, attribs: ::WindowAttributes,
_pl_attribs: PlatformSpecificWindowBuilderAttributes)
-> Result<Window, ::CreationError>
{

View File

@@ -204,13 +204,13 @@ pub struct EventsLoop {
}
#[derive(Clone)]
pub struct EventsLoopProxy;
pub struct EventLoopProxy;
impl EventsLoop {
pub fn new() -> EventsLoop {
impl EventLoop {
pub fn new() -> EventLoop {
unsafe {
if !msg_send![class!(NSThread), isMainThread] {
panic!("`EventsLoop` can only be created on the main thread on iOS");
panic!("`EventLoop` can only be created on the main thread on iOS");
}
}
EventsLoop { events_queue: Default::default() }
@@ -276,13 +276,13 @@ impl EventsLoop {
}
}
pub fn create_proxy(&self) -> EventsLoopProxy {
EventsLoopProxy
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy
}
}
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), ::EventsLoopClosed> {
impl EventLoopProxy {
pub fn wakeup(&self) -> Result<(), ::EventLoopClosed> {
unimplemented!()
}
}
@@ -310,7 +310,7 @@ impl Default for PlatformSpecificWindowBuilderAttributes {
// so to be consistent with other platforms we have to change that.
impl Window {
pub fn new(
ev: &EventsLoop,
ev: &EventLoop,
_attributes: WindowAttributes,
pl_attributes: PlatformSpecificWindowBuilderAttributes,
) -> Result<Window, CreationError> {

View File

@@ -11,7 +11,7 @@ use sctk::reexports::client::ConnectError;
use {
CreationError,
EventsLoopClosed,
EventLoopClosed,
Icon,
MouseCursor,
ControlFlow,
@@ -122,15 +122,15 @@ impl MonitorId {
impl Window {
#[inline]
pub fn new(
events_loop: &EventsLoop,
events_loop: &EventLoop,
attribs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes,
) -> Result<Self, CreationError> {
match *events_loop {
EventsLoop::Wayland(ref events_loop) => {
EventLoop::Wayland(ref events_loop) => {
wayland::Window::new(events_loop, attribs).map(Window::Wayland)
},
EventsLoop::X(ref events_loop) => {
EventLoop::X(ref events_loop) => {
x11::Window::new(events_loop, attribs, pl_attribs).map(Window::X)
},
}
@@ -389,27 +389,27 @@ unsafe extern "C" fn x_error_callback(
0
}
pub enum EventsLoop {
Wayland(wayland::EventsLoop),
X(x11::EventsLoop)
pub enum EventLoop {
Wayland(wayland::EventLoop),
X(x11::EventLoop)
}
#[derive(Clone)]
pub enum EventsLoopProxy {
X(x11::EventsLoopProxy),
Wayland(wayland::EventsLoopProxy),
pub enum EventLoopProxy {
X(x11::EventLoopProxy),
Wayland(wayland::EventLoopProxy),
}
impl EventsLoop {
pub fn new() -> EventsLoop {
impl EventLoop {
pub fn new() -> EventLoop {
if let Ok(env_var) = env::var(BACKEND_PREFERENCE_ENV_VAR) {
match env_var.as_str() {
"x11" => {
// TODO: propagate
return EventsLoop::new_x11().expect("Failed to initialize X11 backend");
return EventLoop::new_x11().expect("Failed to initialize X11 backend");
},
"wayland" => {
return EventsLoop::new_wayland()
return EventLoop::new_wayland()
.expect("Failed to initialize Wayland backend");
},
_ => panic!(
@@ -419,12 +419,12 @@ impl EventsLoop {
}
}
let wayland_err = match EventsLoop::new_wayland() {
let wayland_err = match EventLoop::new_wayland() {
Ok(event_loop) => return event_loop,
Err(err) => err,
};
let x11_err = match EventsLoop::new_x11() {
let x11_err = match EventLoop::new_x11() {
Ok(event_loop) => return event_loop,
Err(err) => err,
};
@@ -437,30 +437,30 @@ impl EventsLoop {
panic!(err_string);
}
pub fn new_wayland() -> Result<EventsLoop, ConnectError> {
wayland::EventsLoop::new()
.map(EventsLoop::Wayland)
pub fn new_wayland() -> Result<EventLoop, ConnectError> {
wayland::EventLoop::new()
.map(EventLoop::Wayland)
}
pub fn new_x11() -> Result<EventsLoop, XNotSupported> {
pub fn new_x11() -> Result<EventLoop, XNotSupported> {
X11_BACKEND
.lock()
.as_ref()
.map(Arc::clone)
.map(x11::EventsLoop::new)
.map(EventsLoop::X)
.map(x11::EventLoop::new)
.map(EventLoop::X)
.map_err(|err| err.clone())
}
#[inline]
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
match *self {
EventsLoop::Wayland(ref evlp) => evlp
EventLoop::Wayland(ref evlp) => evlp
.get_available_monitors()
.into_iter()
.map(MonitorId::Wayland)
.collect(),
EventsLoop::X(ref evlp) => evlp
EventLoop::X(ref evlp) => evlp
.x_connection()
.get_available_monitors()
.into_iter()
@@ -472,15 +472,15 @@ impl EventsLoop {
#[inline]
pub fn get_primary_monitor(&self) -> MonitorId {
match *self {
EventsLoop::Wayland(ref evlp) => MonitorId::Wayland(evlp.get_primary_monitor()),
EventsLoop::X(ref evlp) => MonitorId::X(evlp.x_connection().get_primary_monitor()),
EventLoop::Wayland(ref evlp) => MonitorId::Wayland(evlp.get_primary_monitor()),
EventLoop::X(ref evlp) => MonitorId::X(evlp.x_connection().get_primary_monitor()),
}
}
pub fn create_proxy(&self) -> EventsLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy {
match *self {
EventsLoop::Wayland(ref evlp) => EventsLoopProxy::Wayland(evlp.create_proxy()),
EventsLoop::X(ref evlp) => EventsLoopProxy::X(evlp.create_proxy()),
EventLoop::Wayland(ref evlp) => EventLoopProxy::Wayland(evlp.create_proxy()),
EventLoop::X(ref evlp) => EventLoopProxy::X(evlp.create_proxy()),
}
}
@@ -488,8 +488,8 @@ impl EventsLoop {
where F: FnMut(::Event)
{
match *self {
EventsLoop::Wayland(ref mut evlp) => evlp.poll_events(callback),
EventsLoop::X(ref mut evlp) => evlp.poll_events(callback)
EventLoop::Wayland(ref mut evlp) => evlp.poll_events(callback),
EventLoop::X(ref mut evlp) => evlp.poll_events(callback)
}
}
@@ -497,33 +497,33 @@ impl EventsLoop {
where F: FnMut(::Event) -> ControlFlow
{
match *self {
EventsLoop::Wayland(ref mut evlp) => evlp.run_forever(callback),
EventsLoop::X(ref mut evlp) => evlp.run_forever(callback)
EventLoop::Wayland(ref mut evlp) => evlp.run_forever(callback),
EventLoop::X(ref mut evlp) => evlp.run_forever(callback)
}
}
#[inline]
pub fn is_wayland(&self) -> bool {
match *self {
EventsLoop::Wayland(_) => true,
EventsLoop::X(_) => false,
EventLoop::Wayland(_) => true,
EventLoop::X(_) => false,
}
}
#[inline]
pub fn x_connection(&self) -> Option<&Arc<XConnection>> {
match *self {
EventsLoop::Wayland(_) => None,
EventsLoop::X(ref ev) => Some(ev.x_connection()),
EventLoop::Wayland(_) => None,
EventLoop::X(ref ev) => Some(ev.x_connection()),
}
}
}
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
impl EventLoopProxy {
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
match *self {
EventsLoopProxy::Wayland(ref proxy) => proxy.wakeup(),
EventsLoopProxy::X(ref proxy) => proxy.wakeup(),
EventLoopProxy::Wayland(ref proxy) => proxy.wakeup(),
EventLoopProxy::X(ref proxy) => proxy.wakeup(),
}
}
}

View File

@@ -4,7 +4,7 @@ use std::fmt;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, Weak};
use {ControlFlow, EventsLoopClosed, PhysicalPosition, PhysicalSize};
use {ControlFlow, EventLoopClosed, PhysicalPosition, PhysicalSize};
use super::window::WindowStore;
use super::WindowId;
@@ -21,13 +21,13 @@ use sctk::reexports::client::protocol::wl_surface::RequestsTrait;
use ModifiersState;
pub struct EventsLoopSink {
pub struct EventLoopSink {
buffer: VecDeque<::Event>,
}
impl EventsLoopSink {
pub fn new() -> EventsLoopSink {
EventsLoopSink {
impl EventLoopSink {
pub fn new() -> EventLoopSink {
EventLoopSink {
buffer: VecDeque::new(),
}
}
@@ -54,11 +54,11 @@ impl EventsLoopSink {
}
}
pub struct EventsLoop {
pub struct EventLoop {
// The Event Queue
pub evq: RefCell<EventQueue>,
// our sink, shared with some handlers, buffering the events
sink: Arc<Mutex<EventsLoopSink>>,
sink: Arc<Mutex<EventLoopSink>>,
// Whether or not there is a pending `Awakened` event to be emitted.
pending_wakeup: Arc<AtomicBool>,
// The window store
@@ -73,43 +73,43 @@ pub struct EventsLoop {
pub seats: Arc<Mutex<Vec<(u32, Proxy<wl_seat::WlSeat>)>>>,
}
// A handle that can be sent across threads and used to wake up the `EventsLoop`.
// A handle that can be sent across threads and used to wake up the `EventLoop`.
//
// We should only try and wake up the `EventsLoop` if it still exists, so we hold Weak ptrs.
// We should only try and wake up the `EventLoop` if it still exists, so we hold Weak ptrs.
#[derive(Clone)]
pub struct EventsLoopProxy {
pub struct EventLoopProxy {
display: Weak<Display>,
pending_wakeup: Weak<AtomicBool>,
}
impl EventsLoopProxy {
// Causes the `EventsLoop` to stop blocking on `run_forever` and emit an `Awakened` event.
impl EventLoopProxy {
// Causes the `EventLoop` to stop blocking on `run_forever` and emit an `Awakened` event.
//
// Returns `Err` if the associated `EventsLoop` no longer exists.
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
// Returns `Err` if the associated `EventLoop` no longer exists.
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
let display = self.display.upgrade();
let wakeup = self.pending_wakeup.upgrade();
match (display, wakeup) {
(Some(display), Some(wakeup)) => {
// Update the `EventsLoop`'s `pending_wakeup` flag.
// Update the `EventLoop`'s `pending_wakeup` flag.
wakeup.store(true, Ordering::Relaxed);
// Cause the `EventsLoop` to break from `dispatch` if it is currently blocked.
// Cause the `EventLoop` to break from `dispatch` if it is currently blocked.
let _ = display.sync(|callback| callback.implement(|_, _| {}, ()));
display.flush().map_err(|_| EventsLoopClosed)?;
display.flush().map_err(|_| EventLoopClosed)?;
Ok(())
}
_ => Err(EventsLoopClosed),
_ => Err(EventLoopClosed),
}
}
}
impl EventsLoop {
pub fn new() -> Result<EventsLoop, ConnectError> {
impl EventLoop {
pub fn new() -> Result<EventLoop, ConnectError> {
let (display, mut event_queue) = Display::connect_to_env()?;
let display = Arc::new(display);
let pending_wakeup = Arc::new(AtomicBool::new(false));
let sink = Arc::new(Mutex::new(EventsLoopSink::new()));
let sink = Arc::new(Mutex::new(EventLoopSink::new()));
let store = Arc::new(Mutex::new(WindowStore::new()));
let seats = Arc::new(Mutex::new(Vec::new()));
@@ -126,7 +126,7 @@ impl EventsLoop {
let env = Environment::from_display_with_cb(
&display,
&mut event_queue,
move |event, registry| {
move |event, registry| {
seat_manager.receive(event, registry)
},
).unwrap();
@@ -143,8 +143,8 @@ impl EventsLoop {
})
}
pub fn create_proxy(&self) -> EventsLoopProxy {
EventsLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy {
display: Arc::downgrade(&self.display),
pending_wakeup: Arc::downgrade(&self.pending_wakeup),
}
@@ -221,10 +221,10 @@ impl EventsLoop {
}
/*
* Private EventsLoop Internals
* Private EventLoop Internals
*/
impl EventsLoop {
impl EventLoop {
fn post_dispatch_triggers(&mut self) {
let mut sink = self.sink.lock().unwrap();
// process a possible pending wakeup call
@@ -279,7 +279,7 @@ impl EventsLoop {
*/
struct SeatManager {
sink: Arc<Mutex<EventsLoopSink>>,
sink: Arc<Mutex<EventLoopSink>>,
store: Arc<Mutex<WindowStore>>,
seats: Arc<Mutex<Vec<(u32, Proxy<wl_seat::WlSeat>)>>>,
events_loop_proxy: EventsLoopProxy,
@@ -332,7 +332,7 @@ impl SeatManager {
}
struct SeatData {
sink: Arc<Mutex<EventsLoopSink>>,
sink: Arc<Mutex<EventLoopSink>>,
store: Arc<Mutex<WindowStore>>,
pointer: Option<Proxy<wl_pointer::WlPointer>>,
keyboard: Option<Proxy<wl_keyboard::WlKeyboard>>,

View File

@@ -13,8 +13,8 @@ use {ElementState, KeyboardInput, ModifiersState, VirtualKeyCode, WindowEvent};
pub fn init_keyboard(
seat: &Proxy<wl_seat::WlSeat>,
sink: Arc<Mutex<EventsLoopSink>>,
events_loop_proxy: EventsLoopProxy,
sink: Arc<Mutex<EventLoopSink>>,
events_loop_proxy: EventLoopProxy,
modifiers_tracker: Arc<Mutex<ModifiersState>>,
) -> Proxy<wl_keyboard::WlKeyboard> {
// { variables to be captured by the closures

View File

@@ -2,7 +2,7 @@
target_os = "netbsd", target_os = "openbsd"))]
pub use self::window::Window;
pub use self::event_loop::{EventsLoop, EventsLoopProxy, EventsLoopSink, MonitorId};
pub use self::event_loop::{EventLoop, EventLoopProxy, EventLoopSink, MonitorId};
use sctk::reexports::client::protocol::wl_surface;
use sctk::reexports::client::Proxy;

View File

@@ -4,7 +4,7 @@ use {ElementState, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent};
use events::ModifiersState;
use super::DeviceId;
use super::event_loop::EventsLoopSink;
use super::event_loop::EventLoopSink;
use super::window::WindowStore;
use sctk::reexports::client::Proxy;
@@ -14,7 +14,7 @@ use sctk::reexports::client::protocol::wl_seat::RequestsTrait as SeatRequests;
pub fn implement_pointer(
seat: &Proxy<wl_seat::WlSeat>,
sink: Arc<Mutex<EventsLoopSink>>,
sink: Arc<Mutex<EventLoopSink>>,
store: Arc<Mutex<WindowStore>>,
modifiers_tracker: Arc<Mutex<ModifiersState>>,
) -> Proxy<WlPointer> {

View File

@@ -3,7 +3,7 @@ use std::sync::{Arc, Mutex};
use {TouchPhase, WindowEvent};
use super::{DeviceId, WindowId};
use super::event_loop::EventsLoopSink;
use super::event_loop::EventLoopSink;
use super::window::WindowStore;
use sctk::reexports::client::Proxy;
@@ -19,7 +19,7 @@ struct TouchPoint {
pub(crate) fn implement_touch(
seat: &Proxy<wl_seat::WlSeat>,
sink: Arc<Mutex<EventsLoopSink>>,
sink: Arc<Mutex<EventLoopSink>>,
store: Arc<Mutex<WindowStore>>,
) -> Proxy<WlTouch> {
let mut pending_ids = Vec::new();

View File

@@ -13,7 +13,7 @@ use sctk::reexports::client::protocol::wl_compositor::RequestsTrait as Composito
use sctk::reexports::client::protocol::wl_surface::RequestsTrait as SurfaceRequests;
use sctk::output::OutputMgr;
use super::{make_wid, EventsLoop, MonitorId, WindowId};
use super::{make_wid, EventLoop, MonitorId, WindowId};
use platform::platform::wayland::event_loop::{get_available_monitors, get_primary_monitor};
pub struct Window {
@@ -28,7 +28,7 @@ pub struct Window {
}
impl Window {
pub fn new(evlp: &EventsLoop, attributes: WindowAttributes) -> Result<Window, CreationError> {
pub fn new(evlp: &EventLoop, attributes: WindowAttributes) -> Result<Window, CreationError> {
let (width, height) = attributes.dimensions.map(Into::into).unwrap_or((800, 600));
// Create the window
let size = Arc::new(Mutex::new((width, height)));

View File

@@ -29,7 +29,7 @@ use {
CreationError,
DeviceEvent,
Event,
EventsLoopClosed,
EventLoopClosed,
KeyboardInput,
LogicalPosition,
LogicalSize,
@@ -41,7 +41,7 @@ use platform::PlatformSpecificWindowBuilderAttributes;
use self::dnd::{Dnd, DndState};
use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime};
pub struct EventsLoop {
pub struct EventLoop {
xconn: Arc<XConnection>,
wm_delete_window: ffi::Atom,
dnd: Dnd,
@@ -60,14 +60,14 @@ pub struct EventsLoop {
}
#[derive(Clone)]
pub struct EventsLoopProxy {
pub struct EventLoopProxy {
pending_wakeup: Weak<AtomicBool>,
xconn: Weak<XConnection>,
wakeup_dummy_window: ffi::Window,
}
impl EventsLoop {
pub fn new(xconn: Arc<XConnection>) -> EventsLoop {
impl EventLoop {
pub fn new(xconn: Arc<XConnection>) -> EventLoop {
let root = unsafe { (xconn.xlib.XDefaultRootWindow)(xconn.display) };
let wm_delete_window = unsafe { xconn.get_atom_unchecked(b"WM_DELETE_WINDOW\0") };
@@ -142,7 +142,7 @@ impl EventsLoop {
)
};
let result = EventsLoop {
let result = EventLoop {
xconn,
wm_delete_window,
dnd,
@@ -177,8 +177,8 @@ impl EventsLoop {
&self.xconn
}
pub fn create_proxy(&self) -> EventsLoopProxy {
EventsLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy {
pending_wakeup: Arc::downgrade(&self.pending_wakeup),
xconn: Arc::downgrade(&self.xconn),
wakeup_dummy_window: self.wakeup_dummy_window,
@@ -1181,15 +1181,15 @@ impl EventsLoop {
}
}
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
// Update the `EventsLoop`'s `pending_wakeup` flag.
impl EventLoopProxy {
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
// Update the `EventLoop`'s `pending_wakeup` flag.
let display = match (self.pending_wakeup.upgrade(), self.xconn.upgrade()) {
(Some(wakeup), Some(display)) => {
wakeup.store(true, atomic::Ordering::Relaxed);
display
},
_ => return Err(EventsLoopClosed),
_ => return Err(EventLoopClosed),
};
// Push an event on the X event queue so that methods run_forever will advance.
@@ -1269,7 +1269,7 @@ impl Deref for Window {
impl Window {
pub fn new(
event_loop: &EventsLoop,
event_loop: &EventLoop,
attribs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes
) -> Result<Self, CreationError> {
@@ -1354,7 +1354,7 @@ enum ScrollOrientation {
}
impl Device {
fn new(el: &EventsLoop, info: &ffi::XIDeviceInfo) -> Self {
fn new(el: &EventLoop, info: &ffi::XIDeviceInfo) -> Self {
let name = unsafe { CStr::from_ptr(info.name).to_string_lossy() };
let mut scroll_axes = Vec::new();

View File

@@ -15,7 +15,7 @@ use platform::PlatformSpecificWindowBuilderAttributes;
use platform::x11::MonitorId as X11MonitorId;
use window::MonitorId as RootMonitorId;
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventsLoop};
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventLoop};
unsafe extern "C" fn visibility_predicate(
_display: *mut ffi::Display,
@@ -70,7 +70,7 @@ pub struct UnownedWindow {
impl UnownedWindow {
pub fn new(
event_loop: &EventsLoop,
event_loop: &EventLoop,
window_attrs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes,
) -> Result<UnownedWindow, CreationError> {

View File

@@ -1,4 +1,4 @@
use {ControlFlow, EventsLoopClosed};
use {ControlFlow, EventLoopClosed};
use cocoa::{self, appkit, foundation};
use cocoa::appkit::{NSApplication, NSEvent, NSEventMask, NSEventModifierFlags, NSEventPhase, NSView, NSWindow};
use events::{self, ElementState, Event, TouchPhase, WindowEvent, DeviceEvent, ModifiersState, KeyboardInput};
@@ -9,12 +9,12 @@ use std;
use std::os::raw::*;
use super::DeviceId;
pub struct EventsLoop {
pub struct EventLoop {
modifiers: Modifiers,
pub shared: Arc<Shared>,
}
// State shared between the `EventsLoop` and its registered windows.
// State shared between the `EventLoop` and its registered windows.
pub struct Shared {
pub windows: Mutex<Vec<Weak<Window2>>>,
pub pending_events: Mutex<VecDeque<Event>>,
@@ -42,7 +42,7 @@ struct Modifiers {
// Wrapping the user callback in a type allows us to:
//
// - ensure the callback pointer is never accidentally cloned
// - ensure that only the `EventsLoop` can `store` and `drop` the callback pointer
// - ensure that only the `EventLoop` can `store` and `drop` the callback pointer
// - Share access to the user callback with the NSWindow callbacks.
pub struct UserCallback {
mutex: Mutex<Option<*mut FnMut(Event)>>,
@@ -160,17 +160,17 @@ impl UserCallback {
}
impl EventsLoop {
impl EventLoop {
pub fn new() -> Self {
// Mark this thread as the main thread of the Cocoa event system.
//
// This must be done before any worker threads get a chance to call it
// (e.g., via `EventsLoopProxy::wakeup()`), causing a wrong thread to be
// (e.g., via `EventLoopProxy::wakeup()`), causing a wrong thread to be
// marked as the main thread.
unsafe { appkit::NSApp(); }
EventsLoop {
EventLoop {
shared: Arc::new(Shared::new()),
modifiers: Modifiers::new(),
}
@@ -521,7 +521,7 @@ impl EventsLoop {
}
impl Proxy {
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
// Awaken the event loop by triggering `NSApplicationActivatedEventType`.
unsafe {
let pool = foundation::NSAutoreleasePool::new(cocoa::base::nil);

View File

@@ -1,6 +1,6 @@
#![cfg(target_os = "macos")]
pub use self::events_loop::{EventsLoop, Proxy as EventsLoopProxy};
pub use self::events_loop::{EventLoop, Proxy as EventLoopProxy};
pub use self::monitor::MonitorId;
pub use self::window::{Id as WindowId, PlatformSpecificWindowBuilderAttributes, Window2};
use std::sync::Arc;
@@ -24,7 +24,7 @@ impl ::std::ops::Deref for Window {
impl Window {
pub fn new(events_loop: &EventsLoop,
pub fn new(events_loop: &EventLoop,
attributes: ::WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes) -> Result<Self, CreationError>
{

View File

@@ -7,7 +7,7 @@ use cocoa::foundation::{NSString, NSUInteger};
use core_graphics::display::{CGDirectDisplayID, CGDisplay, CGDisplayBounds};
use {PhysicalPosition, PhysicalSize};
use super::EventsLoop;
use super::EventLoop;
use super::window::{IdRef, Window2};
#[derive(Clone, PartialEq)]
@@ -30,7 +30,7 @@ pub fn get_primary_monitor() -> MonitorId {
id
}
impl EventsLoop {
impl EventLoop {
#[inline]
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
get_available_monitors()

View File

@@ -42,7 +42,7 @@ use {
use CreationError::OsError;
use os::macos::{ActivationPolicy, WindowExt};
use platform::platform::{ffi, util};
use platform::platform::events_loop::{EventsLoop, Shared};
use platform::platform::events_loop::{EventLoop, Shared};
use platform::platform::view::{new_view, set_ime_spot};
use window::MonitorId as RootMonitorId;
@@ -169,7 +169,7 @@ pub struct WindowDelegate {
}
impl WindowDelegate {
// Emits an event via the `EventsLoop`'s callback or stores it in the pending queue.
// Emits an event via the `EventLoop`'s callback or stores it in the pending queue.
pub fn emit_event(state: &mut DelegateState, window_event: WindowEvent) {
let window_id = get_window_id(*state.window);
let event = Event::WindowEvent {
@@ -543,7 +543,7 @@ unsafe fn get_current_monitor(window: id) -> RootMonitorId {
let key = IdRef::new(NSString::alloc(nil).init_str("NSScreenNumber"));
let value = NSDictionary::valueForKey_(desc, *key);
let display_id = msg_send![value, unsignedIntegerValue];
RootMonitorId { inner: EventsLoop::make_monitor_from_display(display_id) }
RootMonitorId { inner: EventLoop::make_monitor_from_display(display_id) }
}
impl Drop for Window2 {

View File

@@ -40,7 +40,7 @@ use winapi::um::winnt::{LONG, LPCSTR, SHORT};
use {
ControlFlow,
Event,
EventsLoopClosed,
EventLoopClosed,
KeyboardInput,
LogicalPosition,
LogicalSize,
@@ -133,19 +133,19 @@ impl Inserter {
}
}
pub struct EventsLoop {
pub struct EventLoop {
// Id of the background thread from the Win32 API.
thread_id: DWORD,
// Receiver for the events. The sender is in the background thread.
receiver: mpsc::Receiver<Event>,
}
impl EventsLoop {
pub fn new() -> EventsLoop {
impl EventLoop {
pub fn new() -> EventLoop {
Self::with_dpi_awareness(true)
}
pub fn with_dpi_awareness(dpi_aware: bool) -> EventsLoop {
pub fn with_dpi_awareness(dpi_aware: bool) -> EventLoop {
become_dpi_aware(dpi_aware);
// The main events transfer channel.
@@ -211,7 +211,7 @@ impl EventsLoop {
processthreadsapi::GetThreadId(handle)
};
EventsLoop {
EventLoop {
thread_id,
receiver: rx,
}
@@ -247,8 +247,8 @@ impl EventsLoop {
}
}
pub fn create_proxy(&self) -> EventsLoopProxy {
EventsLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy {
EventLoopProxy {
thread_id: self.thread_id,
}
}
@@ -267,7 +267,7 @@ impl EventsLoop {
}
}
impl Drop for EventsLoop {
impl Drop for EventLoop {
fn drop(&mut self) {
unsafe {
// Posting `WM_QUIT` will cause `GetMessage` to stop.
@@ -277,12 +277,12 @@ impl Drop for EventsLoop {
}
#[derive(Clone)]
pub struct EventsLoopProxy {
pub struct EventLoopProxy {
thread_id: DWORD,
}
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
impl EventLoopProxy {
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
unsafe {
if winuser::PostThreadMessageA(self.thread_id, *WAKEUP_MSG_ID, 0, 0) != 0 {
Ok(())
@@ -294,7 +294,7 @@ impl EventsLoopProxy {
// > idThread does not have a message queue. GetLastError returns
// > ERROR_NOT_ENOUGH_QUOTA when the message limit is hit.
// TODO: handle ERROR_NOT_ENOUGH_QUOTA
Err(EventsLoopClosed)
Err(EventLoopClosed)
}
}
}
@@ -335,7 +335,7 @@ impl EventsLoopProxy {
}
lazy_static! {
// Message sent by the `EventsLoopProxy` when we want to wake up the thread.
// Message sent by the `EventLoopProxy` when we want to wake up the thread.
// WPARAM and LPARAM are unused.
static ref WAKEUP_MSG_ID: u32 = {
unsafe {

View File

@@ -3,7 +3,7 @@
use winapi;
use winapi::shared::windef::HWND;
pub use self::events_loop::{EventsLoop, EventsLoopProxy};
pub use self::events_loop::{EventLoop, EventLoopProxy};
pub use self::monitor::MonitorId;
pub use self::window::Window;

View File

@@ -6,7 +6,7 @@ use winapi::um::winuser;
use std::{mem, ptr};
use std::collections::VecDeque;
use super::{EventsLoop, util};
use super::{EventLoop, util};
use dpi::{PhysicalPosition, PhysicalSize};
use platform::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi};
use platform::platform::window::Window;
@@ -71,7 +71,7 @@ pub fn get_primary_monitor() -> MonitorId {
MonitorId::from_hmonitor(hmonitor)
}
impl EventsLoop {
impl EventLoop {
// TODO: Investigate opportunities for caching
pub fn get_available_monitors(&self) -> VecDeque<MonitorId> {
get_available_monitors()

View File

@@ -28,8 +28,7 @@ use {
};
use platform::platform::{Cursor, PlatformSpecificWindowBuilderAttributes, WindowId};
use platform::platform::dpi::{dpi_to_scale_factor, get_hwnd_dpi};
use platform::platform::events_loop::{self, EventsLoop, DESTROY_MSG_ID, INITIAL_DPI_MSG_ID};
use platform::platform::events_loop::WindowState;
use platform::platform::events_loop::{self, DESTROY_MSG_ID, EventLoop, INITIAL_DPI_MSG_ID, WindowState};
use platform::platform::icon::{self, IconType, WinIcon};
use platform::platform::monitor::get_available_monitors;
use platform::platform::raw_input::register_all_mice_and_keyboards_for_raw_input;
@@ -46,7 +45,7 @@ pub struct Window {
window_state: Arc<Mutex<WindowState>>,
// The events loop proxy.
events_loop_proxy: events_loop::EventsLoopProxy,
events_loop_proxy: events_loop::EventLoopProxy,
}
// https://blogs.msdn.microsoft.com/oldnewthing/20131017-00/?p=2903
@@ -73,7 +72,7 @@ unsafe fn unjust_window_rect(prc: &mut RECT, style: DWORD, ex_style: DWORD) -> B
impl Window {
pub fn new(
events_loop: &EventsLoop,
events_loop: &EventLoop,
w_attr: WindowAttributes,
pl_attr: PlatformSpecificWindowBuilderAttributes,
) -> Result<Window, CreationError> {
@@ -728,7 +727,7 @@ impl Window {
#[inline]
pub fn get_current_monitor(&self) -> RootMonitorId {
RootMonitorId {
inner: EventsLoop::get_current_monitor(self.window.0),
inner: EventLoop::get_current_monitor(self.window.0),
}
}
@@ -807,7 +806,7 @@ unsafe fn init(
mut attributes: WindowAttributes,
mut pl_attribs: PlatformSpecificWindowBuilderAttributes,
inserter: events_loop::Inserter,
events_loop_proxy: events_loop::EventsLoopProxy,
events_loop_proxy: events_loop::EventLoopProxy,
) -> Result<Window, CreationError> {
let title = OsStr::new(&attributes.title)
.encode_wide()

View File

@@ -2,7 +2,7 @@ use std::collections::vec_deque::IntoIter as VecDequeIter;
use {
CreationError,
EventsLoop,
EventLoop,
Icon,
LogicalPosition,
LogicalSize,
@@ -142,7 +142,7 @@ impl WindowBuilder {
/// Error should be very rare and only occur in case of permission denied, incompatible system,
/// out of memory, etc.
#[inline]
pub fn build(mut self, events_loop: &EventsLoop) -> Result<Window, CreationError> {
pub fn build(mut self, events_loop: &EventLoop) -> Result<Window, CreationError> {
self.window.dimensions = Some(self.window.dimensions.unwrap_or_else(|| {
if let Some(ref monitor) = self.window.fullscreen {
// resizing the window to the dimensions of the monitor when fullscreen
@@ -170,7 +170,7 @@ impl Window {
/// Error should be very rare and only occur in case of permission denied, incompatible system,
/// out of memory, etc.
#[inline]
pub fn new(events_loop: &EventsLoop) -> Result<Window, CreationError> {
pub fn new(events_loop: &EventLoop) -> Result<Window, CreationError> {
let builder = WindowBuilder::new();
builder.build(events_loop)
}
@@ -408,7 +408,7 @@ impl Window {
/// Returns the list of all the monitors available on the system.
///
/// This is the same as `EventsLoop::get_available_monitors`, and is provided for convenience.
/// This is the same as `EventLoop::get_available_monitors`, and is provided for convenience.
#[inline]
pub fn get_available_monitors(&self) -> AvailableMonitorsIter {
let data = self.window.get_available_monitors();
@@ -417,7 +417,7 @@ impl Window {
/// Returns the primary monitor of the system.
///
/// This is the same as `EventsLoop::get_primary_monitor`, and is provided for convenience.
/// This is the same as `EventLoop::get_primary_monitor`, and is provided for convenience.
#[inline]
pub fn get_primary_monitor(&self) -> MonitorId {
MonitorId { inner: self.window.get_primary_monitor() }

View File

@@ -4,8 +4,8 @@ fn needs_send<T:Send>() {}
#[test]
fn events_loop_proxy_send() {
// ensures that `winit::EventsLoopProxy` implements `Send`
needs_send::<winit::EventsLoopProxy>();
// ensures that `winit::EventLoopProxy` implements `Send`
needs_send::<winit::EventLoopProxy>();
}
#[test]