diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-05-17 11:19:06 +0200 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-05-17 19:33:07 +0200 |
commit | 3376332a851e16801a4f27347c8d6170c9008e73 (patch) | |
tree | 6d5c67882424ce84aeb5338b555c86f1f760d155 /src/platform/linux | |
parent | 7fe85cbc4931c8d81b0e363eeb90686d8afc8ed8 (diff) | |
download | glutin-3376332a851e16801a4f27347c8d6170c9008e73.tar.gz glutin-3376332a851e16801a4f27347c8d6170c9008e73.zip |
Rework the X implementation to use only one X connection
Diffstat (limited to 'src/platform/linux')
-rw-r--r-- | src/platform/linux/api_dispatch.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/platform/linux/api_dispatch.rs b/src/platform/linux/api_dispatch.rs index e04cff5..d04a1fb 100644 --- a/src/platform/linux/api_dispatch.rs +++ b/src/platform/linux/api_dispatch.rs @@ -4,6 +4,7 @@ pub use api::x11::{Window, WindowProxy, MonitorID, get_available_monitors, get_p pub use api::x11::{WaitEventsIterator, PollEventsIterator};*/ use std::collections::VecDeque; +use std::sync::Arc; use BuilderAttribs; use CreationError; @@ -16,9 +17,10 @@ use libc; use api::wayland; use api::x11; +use api::x11::XConnection; enum Backend { - X, + X(Arc<XConnection>), Wayland } @@ -28,7 +30,7 @@ lazy_static!( if false && wayland::is_available() { Backend::Wayland } else { - Backend::X + Backend::X(Arc::new(XConnection::new().unwrap())) } }; ); @@ -70,16 +72,17 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> { .into_iter() .map(MonitorID::Wayland) .collect(), - Backend::X => x11::get_available_monitors() - .into_iter() - .map(MonitorID::X) - .collect(), + Backend::X(ref connec) => x11::get_available_monitors(connec) + .into_iter() + .map(MonitorID::X) + .collect(), } } + pub fn get_primary_monitor() -> MonitorID { match *BACKEND { Backend::Wayland => MonitorID::Wayland(wayland::get_primary_monitor()), - Backend::X => MonitorID::X(x11::get_primary_monitor()), + Backend::X(ref connec) => MonitorID::X(x11::get_primary_monitor(connec)), } } @@ -147,7 +150,7 @@ impl Window { pub fn new(builder: BuilderAttribs) -> Result<Window, CreationError> { match *BACKEND { Backend::Wayland => wayland::Window::new(builder).map(Window::Wayland), - Backend::X => x11::Window::new(builder).map(Window::X), + Backend::X(ref connec) => x11::Window::new(connec, builder).map(Window::X), } } @@ -286,7 +289,6 @@ impl Window { } impl GlContext for Window { - unsafe fn make_current(&self) { match self { &Window::X(ref w) => w.make_current(), @@ -328,4 +330,4 @@ impl GlContext for Window { &Window::Wayland(ref w) => w.get_pixel_format() } } -}
\ No newline at end of file +} |