Skip to content

Commit

Permalink
Rename os to platform, add Ext trait postfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Osspial committed Nov 9, 2018
1 parent 7df59c6 commit dad24d0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod icon;
mod platform_impl;
mod window;

pub mod os;
pub mod platform;

/// Represents a window.
///
Expand Down
12 changes: 6 additions & 6 deletions src/os/android.rs → src/platform/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ 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()
}
}

/// Additional methods on `WindowBuilder` that are specific to Android.
pub trait WindowBuilderExt {
pub trait WindowBuilderExtAndroid {

}

impl WindowBuilderExt for WindowBuilder {
impl WindowBuilderExtAndroid for WindowBuilder {
}
12 changes: 6 additions & 6 deletions src/os/ios.rs → src/platform/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 _
Expand All @@ -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 _) };
Expand All @@ -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 _
Expand Down
12 changes: 6 additions & 6 deletions src/os/macos.rs → src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions src/os/unix.rs → src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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|
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand All @@ -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(
Expand Down Expand Up @@ -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()
Expand Down
20 changes: 10 additions & 10 deletions src/os/windows.rs → src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand All @@ -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 _
Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -81,15 +81,15 @@ 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;

/// Returns the handle of the monitor - `HMONITOR`.
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()
Expand All @@ -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()
Expand Down

0 comments on commit dad24d0

Please sign in to comment.