aboutsummaryrefslogtreecommitdiff
path: root/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.rs')
-rw-r--r--src/window.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/window.rs b/src/window.rs
index 4fbe8631..8126454d 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -183,6 +183,8 @@ impl Window {
title: &str
) -> Result<Window> {
let event_loop = EventsLoop::new();
+
+ Window::platform_window_init();
let window = WindowBuilder::new()
.with_title(title);
let context = ContextBuilder::new()
@@ -282,6 +284,36 @@ impl Window {
}
}
+ #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
+ pub fn platform_window_init() {
+ /// Set up env to make XIM work correctly
+ use x11_dl::xlib;
+ use libc::{setlocale, LC_CTYPE};
+ let xlib = xlib::Xlib::open().expect("get xlib");
+ unsafe {
+ /// Use empty c string to fallback to LC_CTYPE in environment variables
+ setlocale(LC_CTYPE, b"\0".as_ptr() as *const _);
+ /// Use empty c string for implementation dependent behavior,
+ /// which might be the XMODIFIERS set in env
+ (xlib.XSetLocaleModifiers)(b"\0".as_ptr() as *const _);
+ }
+ }
+
+ /// TODO: change this directive when adding functions for other platforms
+ #[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")))]
+ pub fn platform_window_init() {
+ }
+
+ #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
+ pub fn send_xim_spot(&self, x: i16, y: i16) {
+ use glutin::os::unix::WindowExt;
+ self.window.send_xim_spot(x, y);
+ }
+
+ #[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")))]
+ pub fn send_xim_spot(&self, x: i16, y: i16) {
+ }
+
#[cfg(not(target_os = "macos"))]
pub fn get_window_id(&self) -> Option<usize> {
use glutin::os::unix::WindowExt;