Move wayland utilities to their own module.
This commit is contained in:
parent
262eaa8883
commit
15ce7134fc
|
@ -21,10 +21,10 @@ use helpers::{init_shell, GliumDrawer, MyWindowMap, Roles, SurfaceData};
|
||||||
use slog::{Drain, Logger};
|
use slog::{Drain, Logger};
|
||||||
use smithay::backend::drm::{drm_device_bind, DrmBackend, DrmDevice, DrmHandler};
|
use smithay::backend::drm::{drm_device_bind, DrmBackend, DrmDevice, DrmHandler};
|
||||||
use smithay::backend::graphics::egl::EGLGraphicsBackend;
|
use smithay::backend::graphics::egl::EGLGraphicsBackend;
|
||||||
use smithay::compositor::{CompositorToken, SubsurfaceRole, TraversalAction};
|
use smithay::wayland::compositor::{CompositorToken, SubsurfaceRole, TraversalAction};
|
||||||
use smithay::compositor::roles::Role;
|
use smithay::wayland::compositor::roles::Role;
|
||||||
use smithay::shell::ShellState;
|
use smithay::wayland::shell::ShellState;
|
||||||
use smithay::shm::init_shm_global;
|
use smithay::wayland::shm::init_shm_global;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::Error as IoError;
|
use std::io::Error as IoError;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use super::WindowMap;
|
use super::WindowMap;
|
||||||
use rand;
|
use rand;
|
||||||
use smithay::compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceUserImplementation};
|
use smithay::wayland::compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceUserImplementation};
|
||||||
use smithay::shell::{shell_init, PopupConfigure, ShellState, ShellSurfaceRole,
|
use smithay::wayland::shell::{shell_init, PopupConfigure, ShellState, ShellSurfaceRole,
|
||||||
ShellSurfaceUserImplementation, ToplevelConfigure};
|
ShellSurfaceUserImplementation, ToplevelConfigure};
|
||||||
use smithay::shm::with_buffer_contents;
|
use smithay::wayland::shm::with_buffer_contents;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use wayland_server::{EventLoop, StateToken};
|
use wayland_server::{EventLoop, StateToken};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use smithay::compositor::{CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction};
|
use smithay::wayland::compositor::{CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction};
|
||||||
use smithay::compositor::roles::Role;
|
use smithay::wayland::compositor::roles::Role;
|
||||||
use smithay::shell::{ShellSurfaceRole, ToplevelSurface};
|
use smithay::wayland::shell::{ShellSurfaceRole, ToplevelSurface};
|
||||||
use smithay::utils::Rectangle;
|
use smithay::utils::Rectangle;
|
||||||
use wayland_server::Resource;
|
use wayland_server::Resource;
|
||||||
use wayland_server::protocol::wl_surface;
|
use wayland_server::protocol::wl_surface;
|
||||||
|
|
|
@ -18,10 +18,10 @@ use smithay::backend::graphics::egl::EGLGraphicsBackend;
|
||||||
use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardKeyEvent, PointerButtonEvent,
|
use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardKeyEvent, PointerButtonEvent,
|
||||||
PointerMotionAbsoluteEvent};
|
PointerMotionAbsoluteEvent};
|
||||||
use smithay::backend::winit;
|
use smithay::backend::winit;
|
||||||
use smithay::compositor::{SubsurfaceRole, TraversalAction};
|
use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction};
|
||||||
use smithay::compositor::roles::Role;
|
use smithay::wayland::compositor::roles::Role;
|
||||||
use smithay::seat::{KeyboardHandle, PointerHandle, Seat};
|
use smithay::wayland::seat::{KeyboardHandle, PointerHandle, Seat};
|
||||||
use smithay::shm::init_shm_global;
|
use smithay::wayland::shm::init_shm_global;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use wayland_server::protocol::wl_pointer;
|
use wayland_server::protocol::wl_pointer;
|
||||||
|
|
|
@ -42,10 +42,7 @@ extern crate slog_stdlog;
|
||||||
extern crate error_chain;
|
extern crate error_chain;
|
||||||
|
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
pub mod compositor;
|
pub mod wayland;
|
||||||
pub mod shm;
|
|
||||||
pub mod seat;
|
|
||||||
pub mod shell;
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger
|
fn slog_or_stdlog<L>(logger: L) -> ::slog::Logger
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
//! # #[macro_use] extern crate smithay;
|
//! # #[macro_use] extern crate smithay;
|
||||||
//! use wayland_server::protocol::wl_compositor::WlCompositor;
|
//! use wayland_server::protocol::wl_compositor::WlCompositor;
|
||||||
//! use wayland_server::protocol::wl_subcompositor::WlSubcompositor;
|
//! 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.
|
//! // 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
|
//! // It must implement the Default trait, which will represent the state of a surface which
|
|
@ -161,7 +161,7 @@ macro_rules! define_roles(
|
||||||
($enum_name:ident => $([ $role_name: ident, $role_data: ty])*) => {
|
($enum_name:ident => $([ $role_name: ident, $role_data: ty])*) => {
|
||||||
define_roles!(__impl $enum_name =>
|
define_roles!(__impl $enum_name =>
|
||||||
// add in subsurface role
|
// add in subsurface role
|
||||||
[Subsurface, $crate::compositor::SubsurfaceRole]
|
[Subsurface, $crate::wayland::compositor::SubsurfaceRole]
|
||||||
$([$role_name, $role_data])*
|
$([$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 {
|
fn has_role(&self) -> bool {
|
||||||
if let $enum_name::NoRole = *self {
|
if let $enum_name::NoRole = *self {
|
||||||
false
|
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> {
|
fn set_with(&mut self, data: $role_data) -> ::std::result::Result<(), $role_data> {
|
||||||
if let $enum_name::NoRole = *self {
|
if let $enum_name::NoRole = *self {
|
||||||
*self = $enum_name::$role_name(data);
|
*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 {
|
if let $enum_name::$role_name(ref data) = *self {
|
||||||
Ok(data)
|
Ok(data)
|
||||||
} else {
|
} 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 {
|
if let $enum_name::$role_name(ref mut data) = *self {
|
||||||
Ok(data)
|
Ok(data)
|
||||||
} else {
|
} 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
|
// remove self to make borrow checker happy
|
||||||
let temp = ::std::mem::replace(self, $enum_name::NoRole);
|
let temp = ::std::mem::replace(self, $enum_name::NoRole);
|
||||||
if let $enum_name::$role_name(data) = temp {
|
if let $enum_name::$role_name(data) = temp {
|
||||||
|
@ -230,7 +230,7 @@ macro_rules! define_roles(
|
||||||
} else {
|
} else {
|
||||||
// put it back in place
|
// put it back in place
|
||||||
::std::mem::replace(self, temp);
|
::std::mem::replace(self, temp);
|
||||||
Err($crate::compositor::roles::WrongRole)
|
Err($crate::wayland::compositor::roles::WrongRole)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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;
|
|
@ -11,7 +11,7 @@
|
||||||
//! # extern crate wayland_server;
|
//! # extern crate wayland_server;
|
||||||
//! # #[macro_use] extern crate smithay;
|
//! # #[macro_use] extern crate smithay;
|
||||||
//!
|
//!
|
||||||
//! use smithay::seat::Seat;
|
//! use smithay::wayland::seat::Seat;
|
||||||
//!
|
//!
|
||||||
//! # fn main(){
|
//! # fn main(){
|
||||||
//! # let (_display, mut event_loop) = wayland_server::create_display();
|
//! # let (_display, mut event_loop) = wayland_server::create_display();
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
//! # extern crate wayland_server;
|
//! # extern crate wayland_server;
|
||||||
//! # #[macro_use] extern crate smithay;
|
//! # #[macro_use] extern crate smithay;
|
||||||
//! #
|
//! #
|
||||||
//! # use smithay::seat::Seat;
|
//! # use smithay::wayland::seat::Seat;
|
||||||
//! #
|
//! #
|
||||||
//! # fn main(){
|
//! # fn main(){
|
||||||
//! # let (_display, mut event_loop) = wayland_server::create_display();
|
//! # let (_display, mut event_loop) = wayland_server::create_display();
|
|
@ -29,9 +29,9 @@
|
||||||
//! # #[macro_use] extern crate smithay;
|
//! # #[macro_use] extern crate smithay;
|
||||||
//! # extern crate wayland_protocols;
|
//! # extern crate wayland_protocols;
|
||||||
//! #
|
//! #
|
||||||
//! use smithay::compositor::roles::*;
|
//! use smithay::wayland::compositor::roles::*;
|
||||||
//! use smithay::compositor::CompositorToken;
|
//! use smithay::wayland::compositor::CompositorToken;
|
||||||
//! use smithay::shell::{shell_init, ShellSurfaceRole, ShellSurfaceUserImplementation};
|
//! use smithay::wayland::shell::{shell_init, ShellSurfaceRole, ShellSurfaceUserImplementation};
|
||||||
//! use wayland_server::protocol::wl_shell::WlShell;
|
//! use wayland_server::protocol::wl_shell::WlShell;
|
||||||
//! use wayland_protocols::unstable::xdg_shell::server::zxdg_shell_v6::ZxdgShellV6;
|
//! use wayland_protocols::unstable::xdg_shell::server::zxdg_shell_v6::ZxdgShellV6;
|
||||||
//! use wayland_server::{EventLoop, EventLoopHandle};
|
//! use wayland_server::{EventLoop, EventLoopHandle};
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
//!
|
//!
|
||||||
//! # fn main() {
|
//! # fn main() {
|
||||||
//! # let (_display, mut event_loop) = wayland_server::create_display();
|
//! # 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,
|
//! # &mut event_loop,
|
||||||
//! # unimplemented!(),
|
//! # unimplemented!(),
|
||||||
//! # (),
|
//! # (),
|
||||||
|
@ -105,8 +105,8 @@
|
||||||
//! access from the `state()` of the event loop and the token returned by the init
|
//! access from the `state()` of the event loop and the token returned by the init
|
||||||
//! function.
|
//! function.
|
||||||
|
|
||||||
use compositor::CompositorToken;
|
use wayland::compositor::CompositorToken;
|
||||||
use compositor::roles::Role;
|
use wayland::compositor::roles::Role;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use utils::Rectangle;
|
use utils::Rectangle;
|
|
@ -1,8 +1,8 @@
|
||||||
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
|
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
|
||||||
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
|
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
|
||||||
ToplevelConfigure, ToplevelState};
|
ToplevelConfigure, ToplevelState};
|
||||||
use compositor::CompositorToken;
|
use wayland::compositor::CompositorToken;
|
||||||
use compositor::roles::*;
|
use wayland::compositor::roles::*;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use utils::Rectangle;
|
use utils::Rectangle;
|
||||||
use wayland_protocols::unstable::xdg_shell::server::{zxdg_positioner_v6 as xdg_positioner, zxdg_toplevel_v6};
|
use wayland_protocols::unstable::xdg_shell::server::{zxdg_positioner_v6 as xdg_positioner, zxdg_toplevel_v6};
|
|
@ -1,8 +1,8 @@
|
||||||
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
|
use super::{make_shell_client_data, PopupConfigure, PopupState, PositionerState, ShellClient,
|
||||||
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
|
ShellClientData, ShellSurfaceIData, ShellSurfacePendingState, ShellSurfaceRole,
|
||||||
ToplevelConfigure, ToplevelState};
|
ToplevelConfigure, ToplevelState};
|
||||||
use compositor::CompositorToken;
|
use wayland::compositor::CompositorToken;
|
||||||
use compositor::roles::*;
|
use wayland::compositor::roles::*;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use utils::Rectangle;
|
use utils::Rectangle;
|
||||||
use wayland_protocols::unstable::xdg_shell::server::{zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6,
|
use wayland_protocols::unstable::xdg_shell::server::{zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6,
|
|
@ -19,7 +19,7 @@
|
||||||
//! extern crate wayland_server;
|
//! extern crate wayland_server;
|
||||||
//! extern crate smithay;
|
//! extern crate smithay;
|
||||||
//!
|
//!
|
||||||
//! use smithay::shm::init_shm_global;
|
//! use smithay::wayland::shm::init_shm_global;
|
||||||
//! use wayland_server::protocol::wl_shm::Format;
|
//! use wayland_server::protocol::wl_shm::Format;
|
||||||
//!
|
//!
|
||||||
//! # fn main() {
|
//! # fn main() {
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
//! # extern crate smithay;
|
//! # extern crate smithay;
|
||||||
//! # use wayland_server::protocol::wl_buffer::WlBuffer;
|
//! # use wayland_server::protocol::wl_buffer::WlBuffer;
|
||||||
//! # fn wrap(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,
|
//! with_buffer_contents(&buffer,
|
||||||
//! |slice: &[u8], buffer_metadata: BufferData| {
|
//! |slice: &[u8], buffer_metadata: BufferData| {
|
Loading…
Reference in New Issue