aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml16
-rw-r--r--build.rs4
-rw-r--r--examples/support/mod.rs19
-rw-r--r--src/api/android/mod.rs2
-rw-r--r--src/api/dlopen.rs2
-rw-r--r--src/api/egl/ffi.rs2
-rw-r--r--src/api/egl/mod.rs211
-rw-r--r--src/api/glx/mod.rs2
-rw-r--r--src/api/osmesa/mod.rs2
-rw-r--r--src/api/wayland/mod.rs2
-rw-r--r--src/api/win32/callback.rs6
-rw-r--r--src/api/win32/event.rs27
-rw-r--r--src/api/x11/mod.rs2
-rw-r--r--src/api/x11/window.rs2
-rw-r--r--src/lib.rs2
-rw-r--r--src/platform/linux/mod.rs2
-rw-r--r--src/platform/mod.rs6
17 files changed, 180 insertions, 129 deletions
diff --git a/Cargo.toml b/Cargo.toml
index a952eea..41bf084 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ keywords = ["windowing", "opengl"]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/tomaka/glutin"
-documentation = "http://tomaka.github.io/glutin/"
+documentation = "https://tomaka.github.io/glutin/"
build = "build.rs"
[features]
@@ -108,3 +108,17 @@ wayland-client = { version = "0.2.1", features = ["egl", "dlopen"] }
wayland-kbd = "0.2.0"
wayland-window = "0.1.0"
x11-dl = "~2.0"
+
+[target.x86_64-unknown-dragonfly.dependencies]
+osmesa-sys = "0.0.5"
+wayland-client = { version = "0.2.1", features = ["egl", "dlopen"] }
+wayland-kbd = "0.2.0"
+wayland-window = "0.1.0"
+x11-dl = "~2.0"
+
+[target.x86_64-unknown-freebsd.dependencies]
+osmesa-sys = "0.0.5"
+wayland-client = { version = "0.2.1", features = ["egl", "dlopen"] }
+wayland-kbd = "0.2.0"
+wayland-window = "0.1.0"
+x11-dl = "~2.0"
diff --git a/build.rs b/build.rs
index e15d270..eaa42b3 100644
--- a/build.rs
+++ b/build.rs
@@ -59,7 +59,7 @@ fn main() {
"1.5", "core", &mut file).unwrap();
}
- if target.contains("linux") {
+ if target.contains("linux") || target.contains("dragonfly") || target.contains("freebsd") {
let mut file = File::create(&dest.join("glx_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StructGenerator,
gl_generator::registry::Ns::Glx,
@@ -176,5 +176,5 @@ fn main() {
gl_generator::registry::Ns::Gles2,
gl_generator::Fallbacks::All,
khronos_api::GL_XML, vec![],
- "2.0", "core", &mut file).unwrap();
+ "3.0", "core", &mut file).unwrap();
}
diff --git a/examples/support/mod.rs b/examples/support/mod.rs
index 7e9aa4f..ab8e2a1 100644
--- a/examples/support/mod.rs
+++ b/examples/support/mod.rs
@@ -46,9 +46,12 @@ pub fn load(window: &glutin::Window) -> Context {
(VERTEX_DATA.len() * mem::size_of::<f32>()) as gl::types::GLsizeiptr,
VERTEX_DATA.as_ptr() as *const _, gl::STATIC_DRAW);
- /*let mut vao = mem::uninitialized();
- gl.GenVertexArrays(1, &mut vao);
- gl.BindVertexArray(vao);*/
+ if gl.BindVertexArray.is_loaded() {
+ let mut vao = mem::uninitialized();
+ gl.GenVertexArrays(1, &mut vao);
+ gl.BindVertexArray(vao);
+ }
+
let pos_attrib = gl.GetAttribLocation(program, b"position\0".as_ptr() as *const _);
let color_attrib = gl.GetAttribLocation(program, b"color\0".as_ptr() as *const _);
gl.VertexAttribPointer(pos_attrib as gl::types::GLuint, 2, gl::FLOAT, 0,
@@ -85,11 +88,12 @@ static VERTEX_DATA: [f32; 15] = [
const VS_SRC: &'static [u8] = b"
#version 100
+precision mediump float;
-lowp attribute vec2 position;
-lowp attribute vec3 color;
+attribute vec2 position;
+attribute vec3 color;
-lowp varying vec3 v_color;
+varying vec3 v_color;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
@@ -99,8 +103,9 @@ void main() {
const FS_SRC: &'static [u8] = b"
#version 100
+precision mediump float;
-lowp varying vec3 v_color;
+varying vec3 v_color;
void main() {
gl_FragColor = vec4(v_color, 1.0);
diff --git a/src/api/android/mod.rs b/src/api/android/mod.rs
index 1b52cc0..0f770c2 100644
--- a/src/api/android/mod.rs
+++ b/src/api/android/mod.rs
@@ -257,7 +257,7 @@ impl HeadlessContext {
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
let context = try!(EglContext::new(egl::ffi::egl::Egl, &builder, egl::NativeDisplay::Android));
let context = try!(context.finish_pbuffer());
- Ok(context)
+ Ok(HeadlessContext(context))
}
}
diff --git a/src/api/dlopen.rs b/src/api/dlopen.rs
index 945dfb0..1bb2a0a 100644
--- a/src/api/dlopen.rs
+++ b/src/api/dlopen.rs
@@ -1,4 +1,4 @@
-#![cfg(target_os = "linux")]
+#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
#![allow(dead_code)]
use libc;
diff --git a/src/api/egl/ffi.rs b/src/api/egl/ffi.rs
index 6a81ada..ae02e30 100644
--- a/src/api/egl/ffi.rs
+++ b/src/api/egl/ffi.rs
@@ -33,3 +33,5 @@ pub type EGLNativeWindowType = winapi::HWND;
pub type EGLNativeWindowType = *const libc::c_void;
#[cfg(target_os = "android")]
pub type EGLNativeWindowType = *const libc::c_void;
+#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
+pub type EGLNativeWindowType = *const libc::c_void;
diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs
index 015396e..4cd7a7c 100644
--- a/src/api/egl/mod.rs
+++ b/src/api/egl/mod.rs
@@ -1,4 +1,5 @@
-#![cfg(any(target_os = "windows", target_os = "linux", target_os = "android"))]
+#![cfg(any(target_os = "windows", target_os = "linux", target_os = "android",
+ target_os = "dragonfly", target_os = "freebsd"))]
#![allow(unused_variables)]
use BuilderAttribs;
@@ -41,6 +42,116 @@ pub struct Context {
pixel_format: PixelFormat,
}
+#[cfg(target_os = "android")]
+fn get_native_display(egl: &ffi::egl::Egl,
+ native_display: NativeDisplay) -> *const libc::c_void {
+ unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
+}
+
+#[cfg(not(target_os = "android"))]
+fn get_native_display(egl: &ffi::egl::Egl,
+ native_display: NativeDisplay) -> *const libc::c_void {
+ // the first step is to query the list of extensions without any display, if supported
+ let dp_extensions = unsafe {
+ let p = egl.QueryString(ffi::egl::NO_DISPLAY, ffi::egl::EXTENSIONS as i32);
+
+ // this possibility is available only with EGL 1.5 or EGL_EXT_platform_base, otherwise
+ // `eglQueryString` returns an error
+ if p.is_null() {
+ vec![]
+ } else {
+ let p = CStr::from_ptr(p);
+ let list = String::from_utf8(p.to_bytes().to_vec()).unwrap_or_else(|_| format!(""));
+ list.split(' ').map(|e| e.to_string()).collect::<Vec<_>>()
+ }
+ };
+
+ let has_dp_extension = |e: &str| dp_extensions.iter().find(|s| s == &e).is_some();
+
+ match native_display {
+ // Note: Some EGL implementations are missing the `eglGetPlatformDisplay(EXT)` symbol
+ // despite reporting `EGL_EXT_platform_base`. I'm pretty sure this is a bug.
+ // Therefore we detect whether the symbol is loaded in addition to checking for
+ // extensions.
+ NativeDisplay::X11(display) if has_dp_extension("EGL_KHR_platform_x11") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
+ let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
+ // TODO: `PLATFORM_X11_SCREEN_KHR`
+ unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_X11_KHR, d as *mut _,
+ ptr::null()) }
+ },
+
+ NativeDisplay::X11(display) if has_dp_extension("EGL_EXT_platform_x11") &&
+ egl.GetPlatformDisplayEXT.is_loaded() =>
+ {
+ let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
+ // TODO: `PLATFORM_X11_SCREEN_EXT`
+ unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_X11_EXT, d as *mut _,
+ ptr::null()) }
+ },
+
+ NativeDisplay::Gbm(display) if has_dp_extension("EGL_KHR_platform_gbm") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
+ let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
+ unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_GBM_KHR, d as *mut _,
+ ptr::null()) }
+ },
+
+ NativeDisplay::Gbm(display) if has_dp_extension("EGL_MESA_platform_gbm") &&
+ egl.GetPlatformDisplayEXT.is_loaded() =>
+ {
+ let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
+ unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_GBM_KHR, d as *mut _,
+ ptr::null()) }
+ },
+
+ NativeDisplay::Wayland(display) if has_dp_extension("EGL_KHR_platform_wayland") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
+ let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
+ unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_WAYLAND_KHR, d as *mut _,
+ ptr::null()) }
+ },
+
+ NativeDisplay::Wayland(display) if has_dp_extension("EGL_EXT_platform_wayland") &&
+ egl.GetPlatformDisplayEXT.is_loaded() =>
+ {
+ let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
+ unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_WAYLAND_EXT, d as *mut _,
+ ptr::null()) }
+ },
+
+ // TODO: This will never be reached right now, as the android egl bindings
+ // use the static generator, so can't rely on GetPlatformDisplay(EXT).
+ NativeDisplay::Android if has_dp_extension("EGL_KHR_platform_android") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
+ unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_ANDROID_KHR,
+ ffi::egl::DEFAULT_DISPLAY as *mut _, ptr::null()) }
+ },
+
+ NativeDisplay::Device(display) if has_dp_extension("EGL_EXT_platform_device") &&
+ egl.GetPlatformDisplay.is_loaded() =>
+ {
+ unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_DEVICE_EXT, display as *mut _,
+ ptr::null()) }
+ },
+
+ NativeDisplay::X11(Some(display)) | NativeDisplay::Gbm(Some(display)) |
+ NativeDisplay::Wayland(Some(display)) | NativeDisplay::Device(display) |
+ NativeDisplay::Other(Some(display)) => {
+ unsafe { egl.GetDisplay(display as *mut _) }
+ }
+
+ NativeDisplay::X11(None) | NativeDisplay::Gbm(None) | NativeDisplay::Wayland(None) |
+ NativeDisplay::Android | NativeDisplay::Other(None) => {
+ unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
+ },
+ }
+}
+
impl Context {
/// Start building an EGL context.
///
@@ -55,104 +166,8 @@ impl Context {
unimplemented!()
}
- // the first step is to query the list of extensions without any display, if supported
- let dp_extensions = unsafe {
- let p = egl.QueryString(ffi::egl::NO_DISPLAY, ffi::egl::EXTENSIONS as i32);
-
- // this possibility is available only with EGL 1.5 or EGL_EXT_platform_base, otherwise
- // `eglQueryString` returns an error
- if p.is_null() {
- vec![]
- } else {
- let p = CStr::from_ptr(p);
- let list = String::from_utf8(p.to_bytes().to_vec()).unwrap_or_else(|_| format!(""));
- list.split(' ').map(|e| e.to_string()).collect::<Vec<_>>()
- }
- };
-
- let has_dp_extension = |e: &str| dp_extensions.iter().find(|s| s == &e).is_some();
-
// calling `eglGetDisplay` or equivalent
- let display = match native_display {
- // Note: Some EGL implementations are missing the `eglGetPlatformDisplay(EXT)` symbol
- // despite reporting `EGL_EXT_platform_base`. I'm pretty sure this is a bug.
- // Therefore we detect whether the symbol is loaded in addition to checking for
- // extensions.
- NativeDisplay::X11(display) if has_dp_extension("EGL_KHR_platform_x11") &&
- egl.GetPlatformDisplay.is_loaded() =>
- {
- let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
- // TODO: `PLATFORM_X11_SCREEN_KHR`
- unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_X11_KHR, d as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::X11(display) if has_dp_extension("EGL_EXT_platform_x11") &&
- egl.GetPlatformDisplayEXT.is_loaded() =>
- {
- let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
- // TODO: `PLATFORM_X11_SCREEN_EXT`
- unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_X11_EXT, d as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::Gbm(display) if has_dp_extension("EGL_KHR_platform_gbm") &&
- egl.GetPlatformDisplay.is_loaded() =>
- {
- let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
- unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_GBM_KHR, d as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::Gbm(display) if has_dp_extension("EGL_MESA_platform_gbm") &&
- egl.GetPlatformDisplayEXT.is_loaded() =>
- {
- let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
- unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_GBM_KHR, d as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::Wayland(display) if has_dp_extension("EGL_KHR_platform_wayland") &&
- egl.GetPlatformDisplay.is_loaded() =>
- {
- let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
- unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_WAYLAND_KHR, d as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::Wayland(display) if has_dp_extension("EGL_EXT_platform_wayland") &&
- egl.GetPlatformDisplayEXT.is_loaded() =>
- {
- let d = display.unwrap_or(ffi::egl::DEFAULT_DISPLAY as *const _);
- unsafe { egl.GetPlatformDisplayEXT(ffi::egl::PLATFORM_WAYLAND_EXT, d as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::Android if has_dp_extension("EGL_KHR_platform_android") &&
- egl.GetPlatformDisplay.is_loaded() =>
- {
- unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_ANDROID_KHR,
- ffi::egl::DEFAULT_DISPLAY as *mut _, ptr::null()) }
- },
-
- NativeDisplay::Device(display) if has_dp_extension("EGL_EXT_platform_device") &&
- egl.GetPlatformDisplay.is_loaded() =>
- {
- unsafe { egl.GetPlatformDisplay(ffi::egl::PLATFORM_DEVICE_EXT, display as *mut _,
- ptr::null()) }
- },
-
- NativeDisplay::X11(Some(display)) | NativeDisplay::Gbm(Some(display)) |
- NativeDisplay::Wayland(Some(display)) | NativeDisplay::Device(display) |
- NativeDisplay::Other(Some(display)) => {
- unsafe { egl.GetDisplay(display as *mut _) }
- }
-
- NativeDisplay::X11(None) | NativeDisplay::Gbm(None) | NativeDisplay::Wayland(None) |
- NativeDisplay::Android | NativeDisplay::Other(None) => {
- unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
- },
- };
+ let display = get_native_display(&egl, native_display);
if display.is_null() {
return Err(CreationError::OsError("Could not create EGL display object".to_string()));
diff --git a/src/api/glx/mod.rs b/src/api/glx/mod.rs
index 72bdf03..0b2cf9f 100644
--- a/src/api/glx/mod.rs
+++ b/src/api/glx/mod.rs
@@ -1,4 +1,4 @@
-#![cfg(all(target_os = "linux", feature = "window"))]
+#![cfg(all(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "window"))]
use BuilderAttribs;
use ContextError;
diff --git a/src/api/osmesa/mod.rs b/src/api/osmesa/mod.rs
index 056e2d1..9bd24b6 100644
--- a/src/api/osmesa/mod.rs
+++ b/src/api/osmesa/mod.rs
@@ -1,4 +1,4 @@
-#![cfg(any(target_os = "linux", target_os = "freebsd"))]
+#![cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly"))]
extern crate osmesa_sys;
diff --git a/src/api/wayland/mod.rs b/src/api/wayland/mod.rs
index 0381f31..b46e2d1 100644
--- a/src/api/wayland/mod.rs
+++ b/src/api/wayland/mod.rs
@@ -1,4 +1,4 @@
-#![cfg(target_os = "linux")]
+#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
#![allow(unused_variables, dead_code)]
use self::wayland::egl::{EGLSurface, is_egl_available};
diff --git a/src/api/win32/callback.rs b/src/api/win32/callback.rs
index 5667ca8..c6e7763 100644
--- a/src/api/win32/callback.rs
+++ b/src/api/win32/callback.rs
@@ -129,8 +129,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
winapi::WM_KEYDOWN => {
use events::Event::KeyboardInput;
use events::ElementState::Pressed;
- let scancode = ((lparam >> 16) & 0xff) as u8;
- let vkey = event::vkeycode_to_element(wparam);
+ let (scancode, vkey) = event::vkeycode_to_element(wparam, lparam);
send_event(window, KeyboardInput(Pressed, scancode, vkey));
0
},
@@ -138,8 +137,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
winapi::WM_KEYUP => {
use events::Event::KeyboardInput;
use events::ElementState::Released;
- let scancode = ((lparam >> 16) & 0xff) as u8;
- let vkey = event::vkeycode_to_element(wparam);
+ let (scancode, vkey) = event::vkeycode_to_element(wparam, lparam);
send_event(window, KeyboardInput(Released, scancode, vkey));
0
},
diff --git a/src/api/win32/event.rs b/src/api/win32/event.rs
index 6fbde81..ad4598a 100644
--- a/src/api/win32/event.rs
+++ b/src/api/win32/event.rs
@@ -1,8 +1,20 @@
use events::VirtualKeyCode;
use winapi;
+use user32;
+use ScanCode;
-pub fn vkeycode_to_element(code: winapi::WPARAM) -> Option<VirtualKeyCode> {
- match code as i32 {
+const MAPVK_VSC_TO_VK_EX: u32 = 3;
+
+pub fn vkeycode_to_element(wparam: winapi::WPARAM, lparam: winapi::LPARAM) -> (ScanCode, Option<VirtualKeyCode>) {
+ let scancode = ((lparam >> 16) & 0xff) as u8;
+ let extended = (lparam & 0x01000000) != 0;
+ let vk = match wparam as i32 {
+ winapi::VK_SHIFT => unsafe { user32::MapVirtualKeyA(scancode as u32, MAPVK_VSC_TO_VK_EX) as i32 },
+ winapi::VK_CONTROL => if extended { winapi::VK_RCONTROL } else { winapi::VK_LCONTROL },
+ winapi::VK_MENU => if extended { winapi::VK_RMENU } else { winapi::VK_LMENU },
+ other => other
+ };
+ (scancode, match vk {
//winapi::VK_LBUTTON => Some(VirtualKeyCode::Lbutton),
//winapi::VK_RBUTTON => Some(VirtualKeyCode::Rbutton),
//winapi::VK_CANCEL => Some(VirtualKeyCode::Cancel),
@@ -13,9 +25,12 @@ pub fn vkeycode_to_element(code: winapi::WPARAM) -> Option<VirtualKeyCode> {
winapi::VK_TAB => Some(VirtualKeyCode::Tab),
//winapi::VK_CLEAR => Some(VirtualKeyCode::Clear),
winapi::VK_RETURN => Some(VirtualKeyCode::Return),
- //winapi::VK_SHIFT => Some(VirtualKeyCode::Shift),
- //winapi::VK_CONTROL => Some(VirtualKeyCode::Control),
- //winapi::VK_MENU => Some(VirtualKeyCode::Menu),
+ winapi::VK_LSHIFT => Some(VirtualKeyCode::LShift),
+ winapi::VK_RSHIFT => Some(VirtualKeyCode::RShift),
+ winapi::VK_LCONTROL => Some(VirtualKeyCode::LControl),
+ winapi::VK_RCONTROL => Some(VirtualKeyCode::RControl),
+ winapi::VK_LMENU => Some(VirtualKeyCode::LMenu),
+ winapi::VK_RMENU => Some(VirtualKeyCode::RMenu),
winapi::VK_PAUSE => Some(VirtualKeyCode::Pause),
winapi::VK_CAPITAL => Some(VirtualKeyCode::Capital),
winapi::VK_KANA => Some(VirtualKeyCode::Kana),
@@ -177,5 +192,5 @@ pub fn vkeycode_to_element(code: winapi::WPARAM) -> Option<VirtualKeyCode> {
winapi::VK_PA1 => Some(VirtualKeyCode::Pa1),
winapi::VK_OEM_CLEAR => Some(VirtualKeyCode::Oem_clear),*/
_ => None
- }
+ })
}
diff --git a/src/api/x11/mod.rs b/src/api/x11/mod.rs
index 1ba6bc7..39b99f3 100644
--- a/src/api/x11/mod.rs
+++ b/src/api/x11/mod.rs
@@ -1,4 +1,4 @@
-#![cfg(all(target_os = "linux", feature = "window"))]
+#![cfg(all(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "window"))]
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
pub use self::window::{Window, XWindow, PollEventsIterator, WaitEventsIterator, Context, WindowProxy};
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs
index 36b60e4..5bfbda9 100644
--- a/src/api/x11/window.rs
+++ b/src/api/x11/window.rs
@@ -186,7 +186,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
}
match xev.get_type() {
- ffi::KeymapNotify => {
+ ffi::MappingNotify => {
unsafe { (xlib.XRefreshKeyboardMapping)(mem::transmute(&xev)); }
},
diff --git a/src/lib.rs b/src/lib.rs
index 49b8d9a..94cd445 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -55,7 +55,7 @@ extern crate cocoa;
extern crate core_foundation;
#[cfg(target_os = "macos")]
extern crate core_graphics;
-#[cfg(any(target_os = "linux", target_os = "freebsd"))]
+#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly"))]
extern crate x11_dl;
pub use events::*;
diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs
index fc42f18..3525ce5 100644
--- a/src/platform/linux/mod.rs
+++ b/src/platform/linux/mod.rs
@@ -1,4 +1,4 @@
-#![cfg(target_os = "linux")]
+#![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
use Api;
use BuilderAttribs;
diff --git a/src/platform/mod.rs b/src/platform/mod.rs
index c4b2265..4855765 100644
--- a/src/platform/mod.rs
+++ b/src/platform/mod.rs
@@ -3,7 +3,7 @@ pub use self::platform::*;
#[cfg(target_os = "windows")]
#[path="windows/mod.rs"]
mod platform;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
#[path="linux/mod.rs"]
mod platform;
#[cfg(target_os = "macos")]
@@ -16,5 +16,7 @@ mod platform;
#[path="ios/mod.rs"]
mod platform;
-#[cfg(all(not(target_os = "ios"), not(target_os = "windows"), not(target_os = "linux"), not(target_os = "macos"), not(target_os = "android")))]
+#[cfg(all(not(target_os = "ios"), not(target_os = "windows"), not(target_os = "linux"),
+ not(target_os = "macos"), not(target_os = "android"), not(target_os = "dragonfly"),
+ not(target_os = "freebsd")))]
use this_platform_is_not_supported;