summaryrefslogtreecommitdiff
path: root/src/window.rs
diff options
context:
space:
mode:
authorTed Yin <tederminant@gmail.com>2017-07-24 20:54:06 -0400
committerJoe Wilm <jwilm@users.noreply.github.com>2017-07-24 17:54:06 -0700
commit4c4c2f5f5c81e6efb580e50ea993606160809469 (patch)
treec7a1abe4b5e926e9dcf25f2c64965343ef738b05 /src/window.rs
parent49c73f6d55e5a681a0e0f836cd3e9fe6af30788f (diff)
downloadalacritty-4c4c2f5f5c81e6efb580e50ea993606160809469.tar.gz
alacritty-4c4c2f5f5c81e6efb580e50ea993606160809469.zip
add support for X input method (#691)
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;