1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/

//! This crate implements Wayland functionality.
//!
//! # Sketch of architecture
//!
//! The piece of code running all the business is `Engine`. It sets up everything and handles
//! requests from clients as well as the rests of application. Upon client connection `Engine`
//! creates new
//!
//! - `skylane::Client`, structure registering handlers (representing Wayland objects) and
//! dispatching client requests to them and
//! - `wayland_frontend::Proxy`, structure used for sharing information between handlers, a state
//! of client.
//!
//! `Proxy` is shared between handlers as `RefCell`.
//!
//! Two interfaces were introduced:
//!
//! - `Facade`, for requests from clients (downward?) which is implemented by `Proxy` and
//! - `Gateway`, for requests from application (upward?) which is implemented by `Engine`
//! (dispatching request to correct `Proxy`s) and `Proxy` (making actual request to client).
//!
//! So one `Engine` holds many `Client`s holding many (cell) references to `Proxy`, but at some
//! point `Engine` must be informed that client created surface. For this purpose `Engine` and all
//! `Proxy`s hold (cell) reference to single `Mediator`.
//!
//! Details of threading are left for application. `wayland_frontend` may be configured to receive
//! in one thread and send in other or do everything in one thread. What is however sure accepting
//! new client can not be done in `DisplayEventHandler` and handling requests can not be done in
//! `ClientEventHandler` as it may require mutating `dharma::Dispatcher`, so handling is decoupled
//! from processing using `dharma::DirectSender`.

// TODO: Move common DRM functionality to module.
extern crate drm as libdrm;
extern crate nix;

extern crate skylane;
extern crate skylane_protocols;

extern crate dharma;
extern crate cognitive_graphics;

#[macro_use]
extern crate timber;
#[macro_use]
extern crate cognitive_qualia as qualia;
extern crate cognitive_inputs as inputs;

pub mod constants;

#[macro_use]
mod macros;
mod mediator;
mod global;
mod facade;
mod gateway;
mod proxy;
mod event_handlers;

mod protocol;

pub mod engine;

pub use engine::Engine;
pub use gateway::Gateway;