aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/wayland/context.rs
diff options
context:
space:
mode:
authorVictor Berger <victor.berger@m4x.org>2015-12-08 23:30:17 +0100
committerVictor Berger <victor.berger@m4x.org>2015-12-22 14:36:41 +0100
commit741311b619c9738b3adb15213c442e47834a1c98 (patch)
tree7edefb46dc34bf9034f58c8bf90265865794e2fc /src/api/wayland/context.rs
parent1b25d705ce2110b097b98f37f5e7dd9dc3a9d82c (diff)
downloadglutin-741311b619c9738b3adb15213c442e47834a1c98.tar.gz
glutin-741311b619c9738b3adb15213c442e47834a1c98.zip
api/wayland: core context
Diffstat (limited to 'src/api/wayland/context.rs')
-rw-r--r--src/api/wayland/context.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/api/wayland/context.rs b/src/api/wayland/context.rs
new file mode 100644
index 0000000..4fc743b
--- /dev/null
+++ b/src/api/wayland/context.rs
@@ -0,0 +1,42 @@
+use wayland_client::EventIterator;
+use wayland_client::wayland::get_display;
+use wayland_client::wayland::compositor::WlCompositor;
+use wayland_client::wayland::seat::WlSeat;
+use wayland_client::wayland::shell::WlShell;
+use wayland_client::wayland::shm::WlShm;
+use wayland_client::wayland::subcompositor::WlSubcompositor;
+
+lazy_static! {
+ pub static ref WAYLAND_CONTEXT: Option<WaylandContext> = {
+ WaylandContext::init()
+ };
+}
+
+wayland_env!(InnerEnv,
+ compositor: WlCompositor,
+ seat: WlSeat,
+ shell: WlShell,
+ shm: WlShm,
+ subcompositor: WlSubcompositor
+);
+
+pub struct WaylandContext {
+ inner: InnerEnv,
+ iterator: EventIterator
+}
+
+impl WaylandContext {
+ fn init() -> Option<WaylandContext> {
+ let display = match get_display() {
+ Some(display) => display,
+ None => return None
+ };
+
+ let (inner_env, iterator) = InnerEnv::init(display);
+
+ Some(WaylandContext {
+ inner: inner_env,
+ iterator: iterator
+ })
+ }
+} \ No newline at end of file