From dad24d086aaaff60e557efc4f41d1ae7e3c71738 Mon Sep 17 00:00:00 2001 From: Osspial Date: Wed, 22 Aug 2018 18:03:41 -0400 Subject: [PATCH] Rename os to platform, add Ext trait postfixes --- src/lib.rs | 2 +- src/{os => platform}/android.rs | 12 ++++++------ src/{os => platform}/ios.rs | 12 ++++++------ src/{os => platform}/macos.rs | 12 ++++++------ src/{os => platform}/mod.rs | 0 src/{os => platform}/unix.rs | 16 ++++++++-------- src/{os => platform}/windows.rs | 20 ++++++++++---------- 7 files changed, 37 insertions(+), 37 deletions(-) rename src/{os => platform}/android.rs (78%) rename src/{os => platform}/ios.rs (89%) rename src/{os => platform}/macos.rs (96%) rename src/{os => platform}/mod.rs (100%) rename src/{os => platform}/unix.rs (97%) rename src/{os => platform}/windows.rs (89%) diff --git a/src/lib.rs b/src/lib.rs index c5378a3ec1..a06315cf30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,7 +105,7 @@ mod icon; mod platform_impl; mod window; -pub mod os; +pub mod platform; /// Represents a window. /// diff --git a/src/os/android.rs b/src/platform/android.rs similarity index 78% rename from src/os/android.rs rename to src/platform/android.rs index 2efe95c1d3..67ce262688 100644 --- a/src/os/android.rs +++ b/src/platform/android.rs @@ -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 ()>>); } -impl EventLoopExt for EventLoop { +impl EventLoopExtAndroid for EventLoop { fn set_suspend_callback(&self, cb: Option ()>>) { 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 { } diff --git a/src/os/ios.rs b/src/platform/ios.rs similarity index 89% rename from src/os/ios.rs rename to src/platform/ios.rs index 62c2c2470f..3e7a3e2a7b 100644 --- a/src/os/ios.rs +++ b/src/platform/ios.rs @@ -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 _ diff --git a/src/os/macos.rs b/src/platform/macos.rs similarity index 96% rename from src/os/macos.rs rename to src/platform/macos.rs index 7118eeb946..24bdc426bd 100644 --- a/src/os/macos.rs +++ b/src/platform/macos.rs @@ -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() diff --git a/src/os/mod.rs b/src/platform/mod.rs similarity index 100% rename from src/os/mod.rs rename to src/platform/mod.rs diff --git a/src/os/unix.rs b/src/platform/unix.rs similarity index 97% rename from src/os/unix.rs rename to src/platform/unix.rs index 7b2640030a..7a0929d8e6 100644 --- a/src/os/unix.rs +++ b/src/platform/unix.rs @@ -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 where Self: Sized; @@ -45,7 +45,7 @@ pub trait EventLoopExt { fn get_xlib_xconnection(&self) -> Option>; } -impl EventLoopExt for EventLoop { +impl EventLoopExtUnix for EventLoop { #[inline] fn new_x11() -> Result { 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 { 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(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(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() diff --git a/src/os/windows.rs b/src/platform/windows.rs similarity index 89% rename from src/os/windows.rs rename to src/platform/windows.rs index 96a178041c..b792d9aa85 100644 --- a/src/os/windows.rs +++ b/src/platform/windows.rs @@ -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 EventLoopExt for EventLoop { +impl EventLoopExtWindows for EventLoop { #[inline] fn new_dpi_unaware() -> Self { EventLoop { @@ -26,7 +26,7 @@ impl EventLoopExt for EventLoop { } /// 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); } -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; } -impl DeviceIdExt for DeviceId { +impl DeviceIdExtWindows for DeviceId { #[inline] fn get_persistent_identifier(&self) -> Option { self.0.get_persistent_identifier()