Add WINIT_UNIX_BACKEND documentation

This commit is contained in:
Alex Butler 2017-06-21 20:10:23 +01:00
parent eaa92a4282
commit 3a89843767
3 changed files with 34 additions and 8 deletions

View file

@ -1,4 +1,4 @@
//! Winit allows you to build a window on as many platforms as possible. //! Winit allows you to build a window on as many platforms as possible.
//! //!
//! # Building a window //! # Building a window
//! //!
@ -181,6 +181,14 @@ pub struct ButtonId(u32);
/// Provides a way to retreive events from the windows that were registered to it. /// Provides a way to retreive events from the windows that were registered to it.
/// ///
/// To wake up an `EventsLoop` from a another thread, see the `EventsLoopProxy` docs. /// To wake up an `EventsLoop` from a another thread, see the `EventsLoopProxy` docs.
///
/// 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 this variable is set only the named backend
/// > will be tried by winit. 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 struct EventsLoop { pub struct EventsLoop {
events_loop: platform::EventsLoop, events_loop: platform::EventsLoop,
} }

View file

@ -16,11 +16,13 @@ mod dlopen;
pub mod wayland; pub mod wayland;
pub mod x11; pub mod x11;
/// Environment variable that indicates a backend preference /// Environment variable specifying which backend should be used on unix platform.
/// `WINIT_UNIX_BACKEND=x11` : Will try to use an X11 backend ///
/// `WINIT_UNIX_BACKEND=wayland` : Will try to use a wayland backend /// Legal values are x11 and wayland. If this variable is set only the named backend
/// When the variable is present the indicated backend will not fallback to another /// will be tried by winit. If it is not set, winit will try to connect to a wayland connection,
/// (Current default behaviour, without the env var, is try wayland then fallback to X) /// and if it fails will fallback on x11.
///
/// If this variable is set with any other value, winit will panic.
const BACKEND_PREFERENCE_ENV_VAR: &str = "WINIT_UNIX_BACKEND"; const BACKEND_PREFERENCE_ENV_VAR: &str = "WINIT_UNIX_BACKEND";
#[derive(Clone, Default)] #[derive(Clone, Default)]

View file

@ -30,7 +30,7 @@ impl WindowBuilder {
self.window.dimensions = Some((width, height)); self.window.dimensions = Some((width, height));
self self
} }
/// Sets a minimum dimension size for the window /// Sets a minimum dimension size for the window
/// ///
/// Width and height are in pixels. /// Width and height are in pixels.
@ -197,7 +197,7 @@ impl Window {
pub fn get_inner_size(&self) -> Option<(u32, u32)> { pub fn get_inner_size(&self) -> Option<(u32, u32)> {
self.window.get_inner_size() self.window.get_inner_size()
} }
/// Returns the size in points of the client area of the window. /// Returns the size in points of the client area of the window.
/// ///
/// The client area is the content of the window, excluding the title bar and borders. /// The client area is the content of the window, excluding the title bar and borders.
@ -320,6 +320,14 @@ impl Iterator for AvailableMonitorsIter {
} }
/// Returns the list of all available monitors. /// Returns the list of all available monitors.
///
/// 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 this variable is set only the named backend
/// > will be tried by winit. 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.
#[inline] #[inline]
pub fn get_available_monitors() -> AvailableMonitorsIter { pub fn get_available_monitors() -> AvailableMonitorsIter {
let data = platform::get_available_monitors(); let data = platform::get_available_monitors();
@ -327,6 +335,14 @@ pub fn get_available_monitors() -> AvailableMonitorsIter {
} }
/// Returns the primary monitor of the system. /// Returns the primary monitor of the system.
///
/// 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 this variable is set only the named backend
/// > will be tried by winit. 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.
#[inline] #[inline]
pub fn get_primary_monitor() -> MonitorId { pub fn get_primary_monitor() -> MonitorId {
MonitorId(platform::get_primary_monitor()) MonitorId(platform::get_primary_monitor())