Merge pull request #121 from Smithay/cleanup/reexports

Add reexports module
This commit is contained in:
Victor Brekenfeld 2018-12-14 18:52:20 +01:00 committed by GitHub
commit ed74862273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 98 additions and 58 deletions

View File

@ -19,7 +19,7 @@ use smithay::backend::egl::{EGLDisplay, EGLGraphicsBackend};
use smithay::{ use smithay::{
backend::{ backend::{
drm::{ drm::{
dev_t, device_bind, device_bind,
egl::{EglDevice, EglSurface}, egl::{EglDevice, EglSurface},
gbm::{egl::Gbm as EglGbmBackend, GbmDevice}, gbm::{egl::Gbm as EglGbmBackend, GbmDevice},
legacy::LegacyDrmDevice, legacy::LegacyDrmDevice,
@ -30,10 +30,11 @@ use smithay::{
libinput::{libinput_bind, LibinputInputBackend, LibinputSessionInterface}, libinput::{libinput_bind, LibinputInputBackend, LibinputSessionInterface},
session::{ session::{
auto::{auto_session_bind, AutoSession}, auto::{auto_session_bind, AutoSession},
notify_multiplexer, AsSessionObserver, OFlag, Session, SessionNotifier, notify_multiplexer, AsSessionObserver, Session, SessionNotifier,
}, },
udev::{primary_gpu, udev_backend_bind, UdevBackend, UdevHandler}, udev::{primary_gpu, udev_backend_bind, UdevBackend, UdevHandler},
}, },
reexports::{
drm::control::{ drm::control::{
connector::{Info as ConnectorInfo, State as ConnectorState}, connector::{Info as ConnectorInfo, State as ConnectorState},
crtc, crtc,
@ -41,13 +42,7 @@ use smithay::{
}, },
image::{ImageBuffer, Rgba}, image::{ImageBuffer, Rgba},
input::Libinput, input::Libinput,
wayland::{ nix::{fcntl::OFlag, sys::stat::dev_t},
compositor::CompositorToken,
data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent},
output::{Mode, Output, PhysicalProperties},
seat::{CursorImageStatus, Seat, XkbConfig},
shm::init_shm_global,
},
wayland_server::{ wayland_server::{
calloop::{ calloop::{
generic::{EventedFd, Generic}, generic::{EventedFd, Generic},
@ -56,6 +51,14 @@ use smithay::{
protocol::{wl_output, wl_surface}, protocol::{wl_output, wl_surface},
Display, Resource, Display, Resource,
}, },
},
wayland::{
compositor::CompositorToken,
data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent},
output::{Mode, Output, PhysicalProperties},
seat::{CursorImageStatus, Seat, XkbConfig},
shm::init_shm_global,
},
}; };
use glium_drawer::GliumDrawer; use glium_drawer::GliumDrawer;

View File

@ -8,12 +8,17 @@ use drm::{buffer::PixelFormat, control::dumbbuffer::DumbBuffer};
use slog::Drain; use slog::Drain;
use smithay::{ use smithay::{
backend::drm::{ backend::drm::{
connector::{self, State as ConnectorState}, device_bind,
crtc, device_bind, encoder, framebuffer,
legacy::{error::Error, LegacyDrmDevice, LegacyDrmSurface}, legacy::{error::Error, LegacyDrmDevice, LegacyDrmSurface},
ControlDevice, Device, DeviceHandler, RawSurface, ResourceInfo, Surface, Device, DeviceHandler, RawSurface, Surface,
},
reexports::{
drm::control::{
connector::{self, State as ConnectorState},
crtc, encoder, framebuffer, Device as ControlDevice, ResourceInfo,
}, },
wayland_server::calloop::EventLoop, wayland_server::calloop::EventLoop,
},
}; };
use std::{ use std::{
fs::{File, OpenOptions}, fs::{File, OpenOptions},

View File

@ -1,4 +1,4 @@
pub use drm::buffer::Buffer; use drm::buffer::Buffer;
use drm::control::{connector, crtc, encoder, framebuffer, Device as ControlDevice, Mode, ResourceInfo}; use drm::control::{connector, crtc, encoder, framebuffer, Device as ControlDevice, Mode, ResourceInfo};
use drm::Device as BasicDevice; use drm::Device as BasicDevice;

View File

@ -11,38 +11,35 @@
//! --- //! ---
//! //!
//! Initialization of surfaces happens through the types provided by //! Initialization of surfaces happens through the types provided by
//! [`drm-rs`](https://docs.rs/drm/0.3.4/drm/). //! [`drm-rs`](drm).
//! //!
//! Four entities are relevant for the initialization procedure. //! Four entities are relevant for the initialization procedure.
//! //!
//! [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html)s represent scanout engines //! [`crtc`](drm::control::crtc)s represent scanout engines
//! of the device pointer to one framebuffer. //! of the device pointer to one framebuffer.
//! Their responsibility is to read the data of the framebuffer and export it into an "Encoder". //! Their responsibility is to read the data of the framebuffer and export it into an "Encoder".
//! The number of crtc's represent the number of independant output devices the hardware may handle. //! The number of crtc's represent the number of independant output devices the hardware may handle.
//! //!
//! An [`encoder`](https://docs.rs/drm/0.3.4/drm/control/encoder/index.html) encodes the data of //! An [`encoder`](drm::control::encoder) encodes the data of
//! connected crtcs into a video signal for a fixed set of connectors. //! connected crtcs into a video signal for a fixed set of connectors.
//! E.g. you might have an analog encoder based on a DAG for VGA ports, but another one for digital ones. //! E.g. you might have an analog encoder based on a DAG for VGA ports, but another one for digital ones.
//! Also not every encoder might be connected to every crtc. //! Also not every encoder might be connected to every crtc.
//! //!
//! A [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html) represents a port //! A [`connector`](drm::control::connector) represents a port
//! on your computer, possibly with a connected monitor, TV, capture card, etc. //! on your computer, possibly with a connected monitor, TV, capture card, etc.
//! //!
//! On surface creation a matching encoder for your `encoder`-`connector` is automatically selected, //! On surface creation a matching encoder for your `encoder`-`connector` is automatically selected,
//! if it exists, which means you still need to check your configuration. //! if it exists, which means you still need to check your configuration.
//! //!
//! At last a [`Mode`](https://docs.rs/drm/0.3.4/drm/control/struct.Mode.html) needs to be selected, //! At last a [`Mode`](drm::control::Mode) needs to be selected,
//! supported by the `crtc` in question. //! supported by the `crtc` in question.
//! //!
pub use drm::{ use drm::{
buffer::Buffer, control::{connector, crtc, framebuffer, Device as ControlDevice, Mode, ResourceHandles, ResourceInfo},
control::{
connector, crtc, encoder, framebuffer, Device as ControlDevice, Mode, ResourceHandles, ResourceInfo,
},
Device as BasicDevice, Device as BasicDevice,
}; };
pub use nix::libc::dev_t; use nix::libc::dev_t;
use std::error::Error; use std::error::Error;
use std::iter::IntoIterator; use std::iter::IntoIterator;
@ -51,7 +48,7 @@ use std::path::PathBuf;
use wayland_server::calloop::generic::{EventedFd, Generic}; use wayland_server::calloop::generic::{EventedFd, Generic};
use wayland_server::calloop::mio::Ready; use wayland_server::calloop::mio::Ready;
pub use wayland_server::calloop::InsertError; use wayland_server::calloop::InsertError;
use wayland_server::calloop::{LoopHandle, Source}; use wayland_server::calloop::{LoopHandle, Source};
use super::graphics::SwapBuffersError; use super::graphics::SwapBuffersError;
@ -94,9 +91,9 @@ pub trait Device: AsRawFd + DevPath {
/// Creates a new rendering surface. /// Creates a new rendering surface.
/// ///
/// Initialization of surfaces happens through the types provided by /// Initialization of surfaces happens through the types provided by
/// [`drm-rs`](https://docs.rs/drm/0.3.4/drm/). /// [`drm-rs`](drm).
/// ///
/// [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html)s represent scanout engines /// [`crtc`](drm::control::crtc)s represent scanout engines
/// of the device pointer to one framebuffer. /// of the device pointer to one framebuffer.
/// Their responsibility is to read the data of the framebuffer and export it into an "Encoder". /// Their responsibility is to read the data of the framebuffer and export it into an "Encoder".
/// The number of crtc's represent the number of independant output devices the hardware may handle. /// The number of crtc's represent the number of independant output devices the hardware may handle.
@ -109,19 +106,19 @@ pub trait Device: AsRawFd + DevPath {
/// ///
/// You should not call this function manually, but rather use /// You should not call this function manually, but rather use
/// [`device_bind`] to register the device /// [`device_bind`] to register the device
/// to an [`EventLoop`](https://docs.rs/calloop/0.4.2/calloop/struct.EventLoop.html) /// to an [`EventLoop`](wayland_server::calloop::EventLoop)
/// to synchronize your rendering to the vblank events of the open crtc's /// to synchronize your rendering to the vblank events of the open crtc's
fn process_events(&mut self); fn process_events(&mut self);
/// Load the resource from a [`Device`] given its /// Load the resource from a [`Device`] given its
/// [`ResourceHandle`](https://docs.rs/drm/0.3.4/drm/control/trait.ResourceHandle.html) /// [`ResourceHandle`](drm::control::ResourceHandle)
fn resource_info<T: ResourceInfo>( fn resource_info<T: ResourceInfo>(
&self, &self,
handle: T::Handle, handle: T::Handle,
) -> Result<T, <Self::Surface as Surface>::Error>; ) -> Result<T, <Self::Surface as Surface>::Error>;
/// Attempts to acquire a copy of the [`Device`]'s /// Attempts to acquire a copy of the [`Device`]'s
/// [`ResourceHandles`](https://docs.rs/drm/0.3.4/drm/control/struct.ResourceHandles.html) /// [`ResourceHandle`](drm::control::ResourceHandle)
fn resource_handles(&self) -> Result<ResourceHandles, <Self::Surface as Surface>::Error>; fn resource_handles(&self) -> Result<ResourceHandles, <Self::Surface as Surface>::Error>;
} }
@ -134,48 +131,48 @@ pub trait RawDevice: Device<Surface = <Self as RawDevice>::Surface> {
/// An open crtc that can be used for rendering /// An open crtc that can be used for rendering
pub trait Surface { pub trait Surface {
/// Type repesenting a collection of /// Type repesenting a collection of
/// [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html)s /// [`connector`](drm::control::connector)s
/// returned by [`current_connectors`](Surface::current_connectors) and /// returned by [`current_connectors`](Surface::current_connectors) and
/// [`pending_connectors`](Surface::pending_connectors) /// [`pending_connectors`](Surface::pending_connectors)
type Connectors: IntoIterator<Item = connector::Handle>; type Connectors: IntoIterator<Item = connector::Handle>;
/// Error type returned by methods of this trait /// Error type returned by methods of this trait
type Error: Error + Send; type Error: Error + Send;
/// Returns the underlying [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html) of this surface /// Returns the underlying [`crtc`](drm::control::crtc) of this surface
fn crtc(&self) -> crtc::Handle; fn crtc(&self) -> crtc::Handle;
/// Currently used [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html)s of this `Surface` /// Currently used [`connector`](drm::control::connector)s of this `Surface`
fn current_connectors(&self) -> Self::Connectors; fn current_connectors(&self) -> Self::Connectors;
/// Returns the pending [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html)s /// Returns the pending [`connector`](drm::control::connector)s
/// used after the next [`commit`](RawSurface::commit) of this [`Surface`] /// used after the next [`commit`](RawSurface::commit) of this [`Surface`]
/// ///
/// *Note*: Only on a [`RawSurface`] you may directly trigger /// *Note*: Only on a [`RawSurface`] you may directly trigger
/// a [`commit`](RawSurface::commit). Other `Surface`s provide their /// a [`commit`](RawSurface::commit). Other `Surface`s provide their
/// own methods that *may* trigger a commit, you will need to read their docs. /// own methods that *may* trigger a commit, you will need to read their docs.
fn pending_connectors(&self) -> Self::Connectors; fn pending_connectors(&self) -> Self::Connectors;
/// Tries to add a new [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html) /// Tries to add a new [`connector`](drm::control::connector)
/// to be used after the next commit. /// to be used after the next commit.
/// ///
/// Fails if the `connector` is not compatible with the underlying [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html) /// Fails if the `connector` is not compatible with the underlying [`crtc`](drm::control::crtc)
/// (e.g. no suitable [`encoder`](https://docs.rs/drm/0.3.4/drm/control/encoder/index.html) may be found) /// (e.g. no suitable [`encoder`](drm::control::encoder) may be found)
/// or is not compatible with the currently pending /// or is not compatible with the currently pending
/// [`Mode`](https://docs.rs/drm/0.3.4/drm/control/struct.Mode.html). /// [`Mode`](drm::control::Mode).
fn add_connector(&self, connector: connector::Handle) -> Result<(), Self::Error>; fn add_connector(&self, connector: connector::Handle) -> Result<(), Self::Error>;
/// Tries to mark a [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html) /// Tries to mark a [`connector`](drm::control::connector)
/// for removal on the next commit. /// for removal on the next commit.
fn remove_connector(&self, connector: connector::Handle) -> Result<(), Self::Error>; fn remove_connector(&self, connector: connector::Handle) -> Result<(), Self::Error>;
/// Returns the currently active [`Mode`](https://docs.rs/drm/0.3.4/drm/control/struct.Mode.html) /// Returns the currently active [`Mode`](drm::control::Mode)
/// of the underlying [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html) /// of the underlying [`crtc`](drm::control::crtc)
/// if any. /// if any.
fn current_mode(&self) -> Option<Mode>; fn current_mode(&self) -> Option<Mode>;
/// Returns the currently pending [`Mode`](https://docs.rs/drm/0.3.4/drm/control/struct.Mode.html) /// Returns the currently pending [`Mode`](drm::control::Mode)
/// to be used after the next commit, if any. /// to be used after the next commit, if any.
fn pending_mode(&self) -> Option<Mode>; fn pending_mode(&self) -> Option<Mode>;
/// Tries to set a new [`Mode`](https://docs.rs/drm/0.3.4/drm/control/struct.Mode.html) /// Tries to set a new [`Mode`](drm::control::Mode)
/// to be used after the next commit. /// to be used after the next commit.
/// ///
/// Fails if the mode is not compatible with the underlying /// Fails if the mode is not compatible with the underlying
/// [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html) or any of the /// [`crtc`](drm::control::crtc) or any of the
/// pending [`connector`](https://docs.rs/drm/0.3.4/drm/control/connector/index.html)s. /// pending [`connector`](drm::control::connector)s.
/// ///
/// *Note*: Only on a [`RawSurface`] you may directly trigger /// *Note*: Only on a [`RawSurface`] you may directly trigger
/// a [`commit`](RawSurface::commit). Other [`Surface`]s provide their /// a [`commit`](RawSurface::commit). Other [`Surface`]s provide their
@ -200,7 +197,7 @@ pub trait RawSurface: Surface + ControlDevice + BasicDevice {
/// ///
/// This operation is blocking until the crtc is in the desired state. /// This operation is blocking until the crtc is in the desired state.
fn commit(&self, framebuffer: framebuffer::Handle) -> Result<(), <Self as Surface>::Error>; fn commit(&self, framebuffer: framebuffer::Handle) -> Result<(), <Self as Surface>::Error>;
/// Page-flip the underlying [`crtc`](https://docs.rs/drm/0.3.4/drm/control/crtc/index.html) /// Page-flip the underlying [`crtc`](drm::control::crtc)
/// to a new given [`framebuffer`]. /// to a new given [`framebuffer`].
/// ///
/// This will not cause the crtc to modeset. /// This will not cause the crtc to modeset.

View File

@ -1,6 +1,6 @@
#![allow(missing_docs)] #![allow(missing_docs)]
pub use nix::libc::{c_long, c_uint, c_void, int32_t, uint64_t}; use nix::libc::{c_long, c_uint, c_void, int32_t, uint64_t};
pub type khronos_utime_nanoseconds_t = khronos_uint64_t; pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
pub type khronos_uint64_t = uint64_t; pub type khronos_uint64_t = uint64_t;

View File

@ -10,7 +10,7 @@
//! The following mechanisms are currently provided: //! The following mechanisms are currently provided:
//! - direct - legacy tty / virtual terminal kernel API //! - direct - legacy tty / virtual terminal kernel API
//! //!
pub use nix::fcntl::OFlag; use nix::fcntl::OFlag;
use std::{ use std::{
cell::RefCell, cell::RefCell,
os::unix::io::RawFd, os::unix::io::RawFd,

View File

@ -7,28 +7,40 @@
// `error_chain!` can recurse deeply // `error_chain!` can recurse deeply
#![recursion_limit = "1024"] #![recursion_limit = "1024"]
#[cfg(feature = "backend_drm_gbm")]
#[doc(hidden)]
pub extern crate image; pub extern crate image;
#[cfg_attr(feature = "backend_session", macro_use)] #[cfg_attr(feature = "backend_session", macro_use)]
extern crate nix; #[doc(hidden)]
pub extern crate nix;
extern crate tempfile; extern crate tempfile;
#[doc(hidden)]
pub extern crate wayland_commons; pub extern crate wayland_commons;
#[doc(hidden)]
pub extern crate wayland_protocols; pub extern crate wayland_protocols;
#[doc(hidden)]
pub extern crate wayland_server; pub extern crate wayland_server;
#[cfg(feature = "native_lib")] #[cfg(feature = "native_lib")]
extern crate wayland_sys; extern crate wayland_sys;
extern crate xkbcommon; extern crate xkbcommon;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
#[doc(hidden)]
pub extern crate dbus; pub extern crate dbus;
#[cfg(feature = "backend_drm")] #[cfg(feature = "backend_drm")]
#[doc(hidden)]
pub extern crate drm; pub extern crate drm;
#[cfg(feature = "backend_drm_gbm")] #[cfg(feature = "backend_drm_gbm")]
#[doc(hidden)]
pub extern crate gbm; pub extern crate gbm;
#[cfg(feature = "backend_libinput")] #[cfg(feature = "backend_libinput")]
#[doc(hidden)]
pub extern crate input; pub extern crate input;
#[cfg(feature = "backend_session_logind")] #[cfg(feature = "backend_session_logind")]
#[doc(hidden)]
pub extern crate systemd; pub extern crate systemd;
#[cfg(feature = "backend_udev")] #[cfg(feature = "backend_udev")]
#[doc(hidden)]
pub extern crate udev; pub extern crate udev;
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
extern crate wayland_client; extern crate wayland_client;
@ -57,6 +69,8 @@ pub mod wayland;
#[cfg(feature = "xwayland")] #[cfg(feature = "xwayland")]
pub mod xwayland; pub mod xwayland;
pub mod reexports;
fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,

21
src/reexports.rs Normal file
View File

@ -0,0 +1,21 @@
//! Reexports of crates, that are part of the public api, for convenience
#[cfg(feature = "dbus")]
pub use dbus;
#[cfg(feature = "backend_drm")]
pub use drm;
#[cfg(feature = "backend_drm_gbm")]
pub use gbm;
#[cfg(feature = "backend_drm_gbm")]
pub use image;
#[cfg(feature = "backend_libinput")]
pub use input;
#[cfg(any(feature = "backend_udev", feature = "backend_drm"))]
pub use nix;
#[cfg(feature = "backend_session_logind")]
pub use systemd;
#[cfg(feature = "backend_udev")]
pub use udev;
pub use wayland_commons;
pub use wayland_protocols;
pub use wayland_server;

View File

@ -53,7 +53,7 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
pub use wayland_server::protocol::wl_output::{Subpixel, Transform}; use wayland_server::protocol::wl_output::{Subpixel, Transform};
use wayland_server::{ use wayland_server::{
protocol::wl_output::{Event, Mode as WMode, Request, WlOutput}, protocol::wl_output::{Event, Mode as WMode, Request, WlOutput},
Display, Global, NewResource, Resource, Display, Global, NewResource, Resource,