Move wayland utilities to their own module.

This commit is contained in:
Victor Berger 2017-09-28 21:57:02 +02:00 committed by Victor Berger
parent 262eaa8883
commit 15ce7134fc
19 changed files with 48 additions and 42 deletions

View File

@ -21,10 +21,10 @@ use helpers::{init_shell, GliumDrawer, MyWindowMap, Roles, SurfaceData};
use slog::{Drain, Logger};
use smithay::backend::drm::{drm_device_bind, DrmBackend, DrmDevice, DrmHandler};
use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::compositor::{CompositorToken, SubsurfaceRole, TraversalAction};
use smithay::compositor::roles::Role;
use smithay::shell::ShellState;
use smithay::shm::init_shm_global;
use smithay::wayland::compositor::{CompositorToken, SubsurfaceRole, TraversalAction};
use smithay::wayland::compositor::roles::Role;
use smithay::wayland::shell::ShellState;
use smithay::wayland::shm::init_shm_global;
use std::cell::RefCell;
use std::fs::OpenOptions;
use std::io::Error as IoError;

View File

@ -1,9 +1,9 @@
use super::WindowMap;
use rand;
use smithay::compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceUserImplementation};
use smithay::shell::{shell_init, PopupConfigure, ShellState, ShellSurfaceRole,
use smithay::wayland::compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceUserImplementation};
use smithay::wayland::shell::{shell_init, PopupConfigure, ShellState, ShellSurfaceRole,
ShellSurfaceUserImplementation, ToplevelConfigure};
use smithay::shm::with_buffer_contents;
use smithay::wayland::shm::with_buffer_contents;
use std::cell::RefCell;
use std::rc::Rc;
use wayland_server::{EventLoop, StateToken};

View File

@ -1,6 +1,6 @@
use smithay::compositor::{CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction};
use smithay::compositor::roles::Role;
use smithay::shell::{ShellSurfaceRole, ToplevelSurface};
use smithay::wayland::compositor::{CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction};
use smithay::wayland::compositor::roles::Role;
use smithay::wayland::shell::{ShellSurfaceRole, ToplevelSurface};
use smithay::utils::Rectangle;
use wayland_server::Resource;
use wayland_server::protocol::wl_surface;

View File

@ -18,10 +18,10 @@ use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardKeyEvent, PointerButtonEvent,
PointerMotionAbsoluteEvent};
use smithay::backend::winit;
use smithay::compositor::{SubsurfaceRole, TraversalAction};
use smithay::compositor::roles::Role;
use smithay::seat::{KeyboardHandle, PointerHandle, Seat};
use smithay::shm::init_shm_global;
use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction};
use smithay::wayland::compositor::roles::Role;
use smithay::wayland::seat::{KeyboardHandle, PointerHandle, Seat};
use smithay::wayland::shm::init_shm_global;
use std::cell::RefCell;
use std::rc::Rc;
use wayland_server::protocol::wl_pointer;

View File

@ -42,10 +42,7 @@ extern crate slog_stdlog;
extern crate error_chain;
pub mod backend;
pub mod compositor;
pub mod shm;
pub mod seat;
pub mod shell;
pub mod wayland;
pub mod utils;
fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger

View File

@ -31,7 +31,7 @@
//! # #[macro_use] extern crate smithay;
//! use wayland_server::protocol::wl_compositor::WlCompositor;
//! use wayland_server::protocol::wl_subcompositor::WlSubcompositor;
//! use smithay::compositor::{compositor_init, SurfaceUserImplementation};
//! use smithay::wayland::compositor::{compositor_init, SurfaceUserImplementation};
//!
//! // Define some user data to be associated with the surfaces.
//! // It must implement the Default trait, which will represent the state of a surface which

View File

@ -161,7 +161,7 @@ macro_rules! define_roles(
($enum_name:ident => $([ $role_name: ident, $role_data: ty])*) => {
define_roles!(__impl $enum_name =>
// add in subsurface role
[Subsurface, $crate::compositor::SubsurfaceRole]
[Subsurface, $crate::wayland::compositor::SubsurfaceRole]
$([$role_name, $role_data])*
);
};
@ -177,7 +177,7 @@ macro_rules! define_roles(
}
}
impl $crate::compositor::roles::RoleType for $enum_name {
impl $crate::wayland::compositor::roles::RoleType for $enum_name {
fn has_role(&self) -> bool {
if let $enum_name::NoRole = *self {
false
@ -188,7 +188,7 @@ macro_rules! define_roles(
}
$(
impl $crate::compositor::roles::Role<$role_data> for $enum_name {
impl $crate::wayland::compositor::roles::Role<$role_data> for $enum_name {
fn set_with(&mut self, data: $role_data) -> ::std::result::Result<(), $role_data> {
if let $enum_name::NoRole = *self {
*self = $enum_name::$role_name(data);
@ -206,23 +206,23 @@ macro_rules! define_roles(
}
}
fn data(&self) -> ::std::result::Result<&$role_data, $crate::compositor::roles::WrongRole> {
fn data(&self) -> ::std::result::Result<&$role_data, $crate::wayland::compositor::roles::WrongRole> {
if let $enum_name::$role_name(ref data) = *self {
Ok(data)
} else {
Err($crate::compositor::roles::WrongRole)
Err($crate::wayland::compositor::roles::WrongRole)
}
}
fn data_mut(&mut self) -> ::std::result::Result<&mut $role_data, $crate::compositor::roles::WrongRole> {
fn data_mut(&mut self) -> ::std::result::Result<&mut $role_data, $crate::wayland::compositor::roles::WrongRole> {
if let $enum_name::$role_name(ref mut data) = *self {
Ok(data)
} else {
Err($crate::compositor::roles::WrongRole)
Err($crate::wayland::compositor::roles::WrongRole)
}
}
fn unset(&mut self) -> ::std::result::Result<$role_data, $crate::compositor::roles::WrongRole> {
fn unset(&mut self) -> ::std::result::Result<$role_data, $crate::wayland::compositor::roles::WrongRole> {
// remove self to make borrow checker happy
let temp = ::std::mem::replace(self, $enum_name::NoRole);
if let $enum_name::$role_name(data) = temp {
@ -230,7 +230,7 @@ macro_rules! define_roles(
} else {
// put it back in place
::std::mem::replace(self, temp);
Err($crate::compositor::roles::WrongRole)
Err($crate::wayland::compositor::roles::WrongRole)
}
}
}

9
src/wayland/mod.rs Normal file
View File

@ -0,0 +1,9 @@
//! Protocol-related utilities
//!
//! This module contains several handlers to manage the wayland protocol
//! and the clients.
pub mod compositor;
pub mod seat;
pub mod shm;
pub mod shell;

View File

@ -11,7 +11,7 @@
//! # extern crate wayland_server;
//! # #[macro_use] extern crate smithay;
//!
//! use smithay::seat::Seat;
//! use smithay::wayland::seat::Seat;
//!
//! # fn main(){
//! # let (_display, mut event_loop) = wayland_server::create_display();
@ -38,7 +38,7 @@
//! # extern crate wayland_server;
//! # #[macro_use] extern crate smithay;
//! #
//! # use smithay::seat::Seat;
//! # use smithay::wayland::seat::Seat;
//! #
//! # fn main(){
//! # let (_display, mut event_loop) = wayland_server::create_display();

View File

@ -29,9 +29,9 @@
//! # #[macro_use] extern crate smithay;
//! # extern crate wayland_protocols;
//! #
//! use smithay::compositor::roles::*;
//! use smithay::compositor::CompositorToken;
//! use smithay::shell::{shell_init, ShellSurfaceRole, ShellSurfaceUserImplementation};
//! use smithay::wayland::compositor::roles::*;
//! use smithay::wayland::compositor::CompositorToken;
//! use smithay::wayland::shell::{shell_init, ShellSurfaceRole, ShellSurfaceUserImplementation};
//! use wayland_server::protocol::wl_shell::WlShell;
//! use wayland_protocols::unstable::xdg_shell::server::zxdg_shell_v6::ZxdgShellV6;
//! use wayland_server::{EventLoop, EventLoopHandle};
@ -52,7 +52,7 @@
//!
//! # fn main() {
//! # let (_display, mut event_loop) = wayland_server::create_display();
//! # let (compositor_token, _, _) = smithay::compositor::compositor_init::<(), MyRoles, _, _>(
//! # let (compositor_token, _, _) = smithay::wayland::compositor::compositor_init::<(), MyRoles, _, _>(
//! # &mut event_loop,
//! # unimplemented!(),
//! # (),
@ -105,8 +105,8 @@
//! access from the `state()` of the event loop and the token returned by the init
//! function.
use compositor::CompositorToken;
use compositor::roles::Role;
use wayland::compositor::CompositorToken;
use wayland::compositor::roles::Role;
use std::cell::RefCell;
use std::rc::Rc;
use utils::Rectangle;

View File

@ -1,8 +1,8 @@
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
ToplevelConfigure, ToplevelState};
use compositor::CompositorToken;
use compositor::roles::*;
use wayland::compositor::CompositorToken;
use wayland::compositor::roles::*;
use std::sync::Mutex;
use utils::Rectangle;
use wayland_protocols::unstable::xdg_shell::server::{zxdg_positioner_v6 as xdg_positioner, zxdg_toplevel_v6};

View File

@ -1,8 +1,8 @@
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
ToplevelConfigure, ToplevelState};
use compositor::CompositorToken;
use compositor::roles::*;
use wayland::compositor::CompositorToken;
use wayland::compositor::roles::*;
use std::sync::Mutex;
use utils::Rectangle;
use wayland_protocols::unstable::xdg_shell::server::{zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6,

View File

@ -19,7 +19,7 @@
//! extern crate wayland_server;
//! extern crate smithay;
//!
//! use smithay::shm::init_shm_global;
//! use smithay::wayland::shm::init_shm_global;
//! use wayland_server::protocol::wl_shm::Format;
//!
//! # fn main() {
@ -43,7 +43,7 @@
//! # extern crate smithay;
//! # use wayland_server::protocol::wl_buffer::WlBuffer;
//! # fn wrap(buffer: &WlBuffer) {
//! use smithay::shm::{with_buffer_contents, BufferData};
//! use smithay::wayland::shm::{with_buffer_contents, BufferData};
//!
//! with_buffer_contents(&buffer,
//! |slice: &[u8], buffer_metadata: BufferData| {