Rename os to platform, add Ext trait postfixes

This commit is contained in:
Osspial
2018-08-22 18:03:41 -04:00
parent 7df59c60a0
commit dad24d086a
7 changed files with 37 additions and 37 deletions

View File

@@ -105,7 +105,7 @@ mod icon;
mod platform_impl;
mod window;
pub mod os;
pub mod platform;
/// Represents a window.
///

View File

@@ -6,23 +6,23 @@ use Window;
use WindowBuilder;
/// Additional methods on `EventLoop` that are specific to Android.
pub trait EventLoopExt {
pub trait EventLoopExtAndroid {
/// 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 EventLoopExt for EventLoop {
impl EventLoopExtAndroid for EventLoop {
fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>) {
self.events_loop.set_suspend_callback(cb);
}
}
/// Additional methods on `Window` that are specific to Android.
pub trait WindowExt {
pub trait WindowExtAndroid {
fn get_native_window(&self) -> *const c_void;
}
impl WindowExt for Window {
impl WindowExtAndroid for Window {
#[inline]
fn get_native_window(&self) -> *const c_void {
self.window.get_native_window()
@@ -30,9 +30,9 @@ impl WindowExt for Window {
}
/// Additional methods on `WindowBuilder` that are specific to Android.
pub trait WindowBuilderExt {
pub trait WindowBuilderExtAndroid {
}
impl WindowBuilderExt for WindowBuilder {
impl WindowBuilderExtAndroid for WindowBuilder {
}

View File

@@ -5,7 +5,7 @@ use std::os::raw::c_void;
use {MonitorId, Window, WindowBuilder};
/// Additional methods on `Window` that are specific to iOS.
pub trait WindowExt {
pub trait WindowExtIOS {
/// Returns a pointer to the `UIWindow` that is used by this window.
///
/// The pointer will become invalid when the `Window` is destroyed.
@@ -17,7 +17,7 @@ pub trait WindowExt {
fn get_uiview(&self) -> *mut c_void;
}
impl WindowExt for Window {
impl WindowExtIOS for Window {
#[inline]
fn get_uiwindow(&self) -> *mut c_void {
self.window.get_uiwindow() as _
@@ -30,14 +30,14 @@ impl WindowExt for Window {
}
/// Additional methods on `WindowBuilder` that are specific to iOS.
pub trait WindowBuilderExt {
pub trait WindowBuilderExtIOS {
/// Sets the root view class used by the `Window`, otherwise a barebones `UIView` is provided.
///
/// The class will be initialized by calling `[root_view initWithFrame:CGRect]`
fn with_root_view_class(self, root_view_class: *const c_void) -> WindowBuilder;
}
impl WindowBuilderExt for WindowBuilder {
impl WindowBuilderExtIOS for WindowBuilder {
#[inline]
fn with_root_view_class(mut self, root_view_class: *const c_void) -> WindowBuilder {
self.platform_specific.root_view_class = unsafe { &*(root_view_class as *const _) };
@@ -46,12 +46,12 @@ impl WindowBuilderExt for WindowBuilder {
}
/// Additional methods on `MonitorId` that are specific to iOS.
pub trait MonitorIdExt {
pub trait MonitorIdExtIOS {
/// Returns a pointer to the `UIScreen` that is used by this monitor.
fn get_uiscreen(&self) -> *mut c_void;
}
impl MonitorIdExt for MonitorId {
impl MonitorIdExtIOS for MonitorId {
#[inline]
fn get_uiscreen(&self) -> *mut c_void {
self.inner.get_uiscreen() as _

View File

@@ -4,7 +4,7 @@ use std::os::raw::c_void;
use {LogicalSize, MonitorId, Window, WindowBuilder};
/// Additional methods on `Window` that are specific to MacOS.
pub trait WindowExt {
pub trait WindowExtMacOS {
/// Returns a pointer to the cocoa `NSWindow` that is used by this window.
///
/// The pointer will become invalid when the `Window` is destroyed.
@@ -24,7 +24,7 @@ pub trait WindowExt {
fn request_user_attention(&self, is_critical: bool);
}
impl WindowExt for Window {
impl WindowExtMacOS for Window {
#[inline]
fn get_nswindow(&self) -> *mut c_void {
self.window.get_nswindow()
@@ -68,7 +68,7 @@ impl Default for ActivationPolicy {
/// - `with_titlebar_hidden`
/// - `with_titlebar_buttons_hidden`
/// - `with_fullsize_content_view`
pub trait WindowBuilderExt {
pub trait WindowBuilderExtMacOS {
/// Sets the activation policy for the window being built.
fn with_activation_policy(self, activation_policy: ActivationPolicy) -> WindowBuilder;
/// Enables click-and-drag behavior for the entire window, not just the titlebar.
@@ -87,7 +87,7 @@ pub trait WindowBuilderExt {
fn with_resize_increments(self, increments: LogicalSize) -> WindowBuilder;
}
impl WindowBuilderExt for WindowBuilder {
impl WindowBuilderExtMacOS for WindowBuilder {
#[inline]
fn with_activation_policy(mut self, activation_policy: ActivationPolicy) -> WindowBuilder {
self.platform_specific.activation_policy = activation_policy;
@@ -138,14 +138,14 @@ impl WindowBuilderExt for WindowBuilder {
}
/// Additional methods on `MonitorId` that are specific to MacOS.
pub trait MonitorIdExt {
pub trait MonitorIdExtMacOS {
/// Returns the identifier of the monitor for Cocoa.
fn native_id(&self) -> u32;
/// Returns a pointer to the NSScreen representing this monitor.
fn get_nsscreen(&self) -> Option<*mut c_void>;
}
impl MonitorIdExt for MonitorId {
impl MonitorIdExtMacOS for MonitorId {
#[inline]
fn native_id(&self) -> u32 {
self.inner.get_native_identifier()

View File

@@ -26,7 +26,7 @@ pub use platform_impl::XNotSupported;
pub use platform_impl::x11::util::WindowType as XWindowType;
/// Additional methods on `EventLoop` that are specific to Linux.
pub trait EventLoopExt {
pub trait EventLoopExtUnix {
/// Builds a new `EventLoop` that is forced to use X11.
fn new_x11() -> Result<Self, XNotSupported>
where Self: Sized;
@@ -45,7 +45,7 @@ pub trait EventLoopExt {
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
}
impl EventLoopExt for EventLoop {
impl EventLoopExtUnix for EventLoop {
#[inline]
fn new_x11() -> Result<Self, XNotSupported> {
LinuxEventLoop::new_x11().map(|ev|
@@ -85,7 +85,7 @@ impl EventLoopExt for EventLoop {
}
/// Additional methods on `Window` that are specific to Unix.
pub trait WindowExt {
pub trait WindowExtUnix {
/// Returns the ID of the `Window` xlib object that is used by this window.
///
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
@@ -137,7 +137,7 @@ pub trait WindowExt {
fn is_ready(&self) -> bool;
}
impl WindowExt for Window {
impl WindowExtUnix for Window {
#[inline]
fn get_xlib_window(&self) -> Option<raw::c_ulong> {
match self.window {
@@ -209,7 +209,7 @@ impl WindowExt for Window {
}
/// Additional methods on `WindowBuilder` that are specific to Unix.
pub trait WindowBuilderExt {
pub trait WindowBuilderExtUnix {
fn with_x11_visual<T>(self, visual_infos: *const T) -> WindowBuilder;
fn with_x11_screen(self, screen_id: i32) -> WindowBuilder;
@@ -227,7 +227,7 @@ pub trait WindowBuilderExt {
fn with_base_size(self, base_size: LogicalSize) -> WindowBuilder;
}
impl WindowBuilderExt for WindowBuilder {
impl WindowBuilderExtUnix for WindowBuilder {
#[inline]
fn with_x11_visual<T>(mut self, visual_infos: *const T) -> WindowBuilder {
self.platform_specific.visual_infos = Some(
@@ -280,12 +280,12 @@ impl WindowBuilderExt for WindowBuilder {
}
/// Additional methods on `MonitorId` that are specific to Linux.
pub trait MonitorIdExt {
pub trait MonitorIdExtUnix {
/// Returns the inner identifier of the monitor.
fn native_id(&self) -> u32;
}
impl MonitorIdExt for MonitorId {
impl MonitorIdExtUnix for MonitorId {
#[inline]
fn native_id(&self) -> u32 {
self.inner.get_native_identifier()

View File

@@ -9,13 +9,13 @@ use {DeviceId, EventLoop, Icon, MonitorId, Window, WindowBuilder};
use platform_impl::EventLoop as WindowsEventLoop;
/// Additional methods on `EventLoop` that are specific to Windows.
pub trait EventLoopExt {
pub trait EventLoopExtWindows {
/// By default, winit on Windows will attempt to enable process-wide DPI awareness. If that's
/// undesirable, you can create an `EventLoop` using this function instead.
fn new_dpi_unaware() -> Self where Self: Sized;
}
impl<T> EventLoopExt for EventLoop<T> {
impl<T> EventLoopExtWindows for EventLoop<T> {
#[inline]
fn new_dpi_unaware() -> Self {
EventLoop {
@@ -26,7 +26,7 @@ impl<T> EventLoopExt for EventLoop<T> {
}
/// Additional methods on `Window` that are specific to Windows.
pub trait WindowExt {
pub trait WindowExtWindows {
/// Returns the native handle that is used by this window.
///
/// The pointer will become invalid when the native window was destroyed.
@@ -36,7 +36,7 @@ pub trait WindowExt {
fn set_taskbar_icon(&self, taskbar_icon: Option<Icon>);
}
impl WindowExt for Window {
impl WindowExtWindows for Window {
#[inline]
fn get_hwnd(&self) -> *mut libc::c_void {
self.window.hwnd() as *mut _
@@ -49,7 +49,7 @@ impl WindowExt for Window {
}
/// Additional methods on `WindowBuilder` that are specific to Windows.
pub trait WindowBuilderExt {
pub trait WindowBuilderExtWindows {
/// Sets a parent to the window to be created.
fn with_parent_window(self, parent: HWND) -> WindowBuilder;
@@ -60,7 +60,7 @@ pub trait WindowBuilderExt {
fn with_no_redirection_bitmap(self, flag: bool) -> WindowBuilder;
}
impl WindowBuilderExt for WindowBuilder {
impl WindowBuilderExtWindows for WindowBuilder {
#[inline]
fn with_parent_window(mut self, parent: HWND) -> WindowBuilder {
self.platform_specific.parent = Some(parent);
@@ -81,7 +81,7 @@ impl WindowBuilderExt for WindowBuilder {
}
/// Additional methods on `MonitorId` that are specific to Windows.
pub trait MonitorIdExt {
pub trait MonitorIdExtWindows {
/// Returns the name of the monitor adapter specific to the Win32 API.
fn native_id(&self) -> String;
@@ -89,7 +89,7 @@ pub trait MonitorIdExt {
fn hmonitor(&self) -> *mut c_void;
}
impl MonitorIdExt for MonitorId {
impl MonitorIdExtWindows for MonitorId {
#[inline]
fn native_id(&self) -> String {
self.inner.get_native_identifier()
@@ -102,14 +102,14 @@ impl MonitorIdExt for MonitorId {
}
/// Additional methods on `DeviceId` that are specific to Windows.
pub trait DeviceIdExt {
pub trait DeviceIdExtWindows {
/// Returns an identifier that persistently refers to this specific device.
///
/// Will return `None` if the device is no longer available.
fn get_persistent_identifier(&self) -> Option<String>;
}
impl DeviceIdExt for DeviceId {
impl DeviceIdExtWindows for DeviceId {
#[inline]
fn get_persistent_identifier(&self) -> Option<String> {
self.0.get_persistent_identifier()