Format everything and add rustfmt to travis (#951)
* Format everything and add rustfmt to travis * Remove extern crate winit from examples and add force_multiline_blocks * Format the code properly * Fix inconsistent period in PULL_REQUEST_TEMPLATE.md * Only run rustfmt on nightly * Travis fixings
This commit is contained in:
parent
b1b5aefc4b
commit
e2c84725de
109 changed files with 4787 additions and 3679 deletions
|
|
@ -1,9 +1,7 @@
|
|||
#![cfg(any(target_os = "android"))]
|
||||
|
||||
use crate::{EventLoop, Window, WindowBuilder};
|
||||
use std::os::raw::c_void;
|
||||
use crate::EventLoop;
|
||||
use crate::Window;
|
||||
use crate::WindowBuilder;
|
||||
|
||||
/// Additional methods on `EventLoop` that are specific to Android.
|
||||
pub trait EventLoopExtAndroid {
|
||||
|
|
@ -30,9 +28,6 @@ impl WindowExtAndroid for Window {
|
|||
}
|
||||
|
||||
/// Additional methods on `WindowBuilder` that are specific to Android.
|
||||
pub trait WindowBuilderExtAndroid {
|
||||
pub trait WindowBuilderExtAndroid {}
|
||||
|
||||
}
|
||||
|
||||
impl WindowBuilderExtAndroid for WindowBuilder {
|
||||
}
|
||||
impl WindowBuilderExtAndroid for WindowBuilder {}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@
|
|||
target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"
|
||||
))]
|
||||
|
||||
use crate::event::Event;
|
||||
use crate::event_loop::{EventLoop, EventLoopWindowTarget, ControlFlow};
|
||||
use crate::{
|
||||
event::Event,
|
||||
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
|
||||
};
|
||||
|
||||
/// Additional methods on `EventLoop` that are specific to desktop platforms.
|
||||
pub trait EventLoopExtDesktop {
|
||||
|
|
@ -27,14 +29,16 @@ pub trait EventLoopExtDesktop {
|
|||
///
|
||||
/// You are strongly encouraged to use `run`, unless the use of this is absolutely necessary.
|
||||
fn run_return<F>(&mut self, event_handler: F)
|
||||
where F: FnMut(Event<Self::UserEvent>, &EventLoopWindowTarget<Self::UserEvent>, &mut ControlFlow);
|
||||
where
|
||||
F: FnMut(Event<Self::UserEvent>, &EventLoopWindowTarget<Self::UserEvent>, &mut ControlFlow);
|
||||
}
|
||||
|
||||
impl<T> EventLoopExtDesktop for EventLoop<T> {
|
||||
type UserEvent = T;
|
||||
|
||||
fn run_return<F>(&mut self, event_handler: F)
|
||||
where F: FnMut(Event<T>, &EventLoopWindowTarget<T>, &mut ControlFlow)
|
||||
where
|
||||
F: FnMut(Event<T>, &EventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
self.event_loop.run_return(event_handler)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Window, WindowBuilder};
|
||||
use crate::{
|
||||
event_loop::EventLoop,
|
||||
monitor::MonitorHandle,
|
||||
window::{Window, WindowBuilder},
|
||||
};
|
||||
|
||||
/// Additional methods on `EventLoop` that are specific to iOS.
|
||||
pub trait EventLoopExtIOS {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use crate::dpi::LogicalSize;
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Window, WindowBuilder};
|
||||
use crate::{
|
||||
dpi::LogicalSize,
|
||||
monitor::MonitorHandle,
|
||||
window::{Window, WindowBuilder},
|
||||
};
|
||||
|
||||
/// Additional methods on `Window` that are specific to MacOS.
|
||||
pub trait WindowExtMacOS {
|
||||
|
|
@ -97,7 +99,8 @@ 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.
|
||||
fn with_movable_by_window_background(self, movable_by_window_background: bool) -> WindowBuilder;
|
||||
fn with_movable_by_window_background(self, movable_by_window_background: bool)
|
||||
-> WindowBuilder;
|
||||
/// Makes the titlebar transparent and allows the content to appear behind it.
|
||||
fn with_titlebar_transparent(self, titlebar_transparent: bool) -> WindowBuilder;
|
||||
/// Hides the window title.
|
||||
|
|
@ -120,7 +123,10 @@ impl WindowBuilderExtMacOS for WindowBuilder {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn with_movable_by_window_background(mut self, movable_by_window_background: bool) -> WindowBuilder {
|
||||
fn with_movable_by_window_background(
|
||||
mut self,
|
||||
movable_by_window_background: bool,
|
||||
) -> WindowBuilder {
|
||||
self.platform_specific.movable_by_window_background = movable_by_window_background;
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,26 @@
|
|||
#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
||||
|
||||
use std::os::raw;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use std::{os::raw, ptr, sync::Arc};
|
||||
|
||||
use smithay_client_toolkit::window::{ButtonState, Theme};
|
||||
|
||||
use crate::dpi::LogicalSize;
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::window::{Window, WindowBuilder};
|
||||
use crate::{
|
||||
dpi::LogicalSize,
|
||||
event_loop::EventLoop,
|
||||
monitor::MonitorHandle,
|
||||
window::{Window, WindowBuilder},
|
||||
};
|
||||
|
||||
use crate::platform_impl::{
|
||||
EventLoop as LinuxEventLoop,
|
||||
Window as LinuxWindow,
|
||||
x11::{ffi::XVisualInfo, XConnection},
|
||||
EventLoop as LinuxEventLoop, Window as LinuxWindow,
|
||||
};
|
||||
use crate::platform_impl::x11::XConnection;
|
||||
use crate::platform_impl::x11::ffi::XVisualInfo;
|
||||
|
||||
// TODO: stupid hack so that glutin can do its work
|
||||
#[doc(hidden)]
|
||||
pub use crate::platform_impl::x11;
|
||||
|
||||
pub use crate::platform_impl::XNotSupported;
|
||||
pub use crate::platform_impl::x11::util::WindowType as XWindowType;
|
||||
pub use crate::platform_impl::{x11::util::WindowType as XWindowType, XNotSupported};
|
||||
|
||||
/// Theme for wayland client side decorations
|
||||
///
|
||||
|
|
@ -97,11 +94,13 @@ impl Theme for WaylandThemeObject {
|
|||
pub trait EventLoopExtUnix {
|
||||
/// Builds a new `EventLoops` that is forced to use X11.
|
||||
fn new_x11() -> Result<Self, XNotSupported>
|
||||
where Self: Sized;
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
/// Builds a new `EventLoop` that is forced to use Wayland.
|
||||
fn new_wayland() -> Self
|
||||
where Self: Sized;
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
/// True if the `EventLoop` uses Wayland.
|
||||
fn is_wayland(&self) -> bool;
|
||||
|
|
@ -123,12 +122,12 @@ pub trait EventLoopExtUnix {
|
|||
impl<T> EventLoopExtUnix for EventLoop<T> {
|
||||
#[inline]
|
||||
fn new_x11() -> Result<Self, XNotSupported> {
|
||||
LinuxEventLoop::new_x11().map(|ev|
|
||||
LinuxEventLoop::new_x11().map(|ev| {
|
||||
EventLoop {
|
||||
event_loop: ev,
|
||||
_marker: ::std::marker::PhantomData,
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -136,7 +135,7 @@ impl<T> EventLoopExtUnix for EventLoop<T> {
|
|||
EventLoop {
|
||||
event_loop: match LinuxEventLoop::new_wayland() {
|
||||
Ok(e) => e,
|
||||
Err(_) => panic!() // TODO: propagate
|
||||
Err(_) => panic!(), // TODO: propagate
|
||||
},
|
||||
_marker: ::std::marker::PhantomData,
|
||||
}
|
||||
|
|
@ -157,7 +156,7 @@ impl<T> EventLoopExtUnix for EventLoop<T> {
|
|||
fn xlib_xconnection(&self) -> Option<Arc<XConnection>> {
|
||||
match self.event_loop {
|
||||
LinuxEventLoop::X(ref e) => Some(e.x_connection().clone()),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +164,7 @@ impl<T> EventLoopExtUnix for EventLoop<T> {
|
|||
fn wayland_display(&self) -> Option<*mut raw::c_void> {
|
||||
match self.event_loop {
|
||||
LinuxEventLoop::Wayland(ref e) => Some(e.display().get_display_ptr() as *mut _),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -231,7 +230,7 @@ impl WindowExtUnix for Window {
|
|||
fn xlib_window(&self) -> Option<raw::c_ulong> {
|
||||
match self.window {
|
||||
LinuxWindow::X(ref w) => Some(w.xlib_window()),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +238,7 @@ impl WindowExtUnix for Window {
|
|||
fn xlib_display(&self) -> Option<*mut raw::c_void> {
|
||||
match self.window {
|
||||
LinuxWindow::X(ref w) => Some(w.xlib_display()),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +246,7 @@ impl WindowExtUnix for Window {
|
|||
fn xlib_screen_id(&self) -> Option<raw::c_int> {
|
||||
match self.window {
|
||||
LinuxWindow::X(ref w) => Some(w.xlib_screen_id()),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +255,7 @@ impl WindowExtUnix for Window {
|
|||
fn xlib_xconnection(&self) -> Option<Arc<XConnection>> {
|
||||
match self.window {
|
||||
LinuxWindow::X(ref w) => Some(w.xlib_xconnection()),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +263,7 @@ impl WindowExtUnix for Window {
|
|||
fn xcb_connection(&self) -> Option<*mut raw::c_void> {
|
||||
match self.window {
|
||||
LinuxWindow::X(ref w) => Some(w.xcb_connection()),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +278,7 @@ impl WindowExtUnix for Window {
|
|||
fn wayland_surface(&self) -> Option<*mut raw::c_void> {
|
||||
match self.window {
|
||||
LinuxWindow::Wayland(ref w) => Some(w.surface().as_ref().c_ptr() as *mut _),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +286,7 @@ impl WindowExtUnix for Window {
|
|||
fn wayland_display(&self) -> Option<*mut raw::c_void> {
|
||||
match self.window {
|
||||
LinuxWindow::Wayland(ref w) => Some(w.display().as_ref().c_ptr() as *mut _),
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +294,7 @@ impl WindowExtUnix for Window {
|
|||
fn set_wayland_theme(&self, theme: WaylandTheme) {
|
||||
match self.window {
|
||||
LinuxWindow::Wayland(ref w) => w.set_theme(WaylandThemeObject(theme)),
|
||||
_ => {}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -334,9 +333,8 @@ pub trait WindowBuilderExtUnix {
|
|||
impl WindowBuilderExtUnix for WindowBuilder {
|
||||
#[inline]
|
||||
fn with_x11_visual<T>(mut self, visual_infos: *const T) -> WindowBuilder {
|
||||
self.platform_specific.visual_infos = Some(
|
||||
unsafe { ptr::read(visual_infos as *const XVisualInfo) }
|
||||
);
|
||||
self.platform_specific.visual_infos =
|
||||
Some(unsafe { ptr::read(visual_infos as *const XVisualInfo) });
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,21 @@ use std::os::raw::c_void;
|
|||
use libc;
|
||||
use winapi::shared::windef::HWND;
|
||||
|
||||
use crate::event::DeviceId;
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::window::{Icon, Window, WindowBuilder};
|
||||
use crate::platform_impl::EventLoop as WindowsEventLoop;
|
||||
use crate::{
|
||||
event::DeviceId,
|
||||
event_loop::EventLoop,
|
||||
monitor::MonitorHandle,
|
||||
platform_impl::EventLoop as WindowsEventLoop,
|
||||
window::{Icon, Window, WindowBuilder},
|
||||
};
|
||||
|
||||
/// Additional methods on `EventLoop` that are specific to Windows.
|
||||
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;
|
||||
fn new_dpi_unaware() -> Self
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
impl<T> EventLoopExtWindows for EventLoop<T> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue