summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrancesca Frangipane <francesca@comfysoft.net>2018-05-14 23:21:06 -0400
committerJoe Wilm <jwilm@users.noreply.github.com>2018-05-29 09:50:49 -0700
commit765949f256aefcc513d0bfb46b64d315f9c2f3d2 (patch)
treec89b8a991ceaa849be9a9b21536927fc24ca92cb /src
parentf7172fd6e7a7eb1444007030efa39f2f21558342 (diff)
downloadalacritty-765949f256aefcc513d0bfb46b64d315f9c2f3d2.tar.gz
alacritty-765949f256aefcc513d0bfb46b64d315f9c2f3d2.zip
Update to glutin 0.16.0
Note that `WM_CLASS` is now set to `"alacritty", "Alacritty"` instead of the previous value of `"Alacritty", "Alacritty"`. This seems to be more standard. This also contains some revised recommendations for installing the `.desktop` file.
Diffstat (limited to 'src')
-rw-r--r--src/display.rs8
-rw-r--r--src/event.rs2
-rw-r--r--src/window.rs69
3 files changed, 18 insertions, 61 deletions
diff --git a/src/display.rs b/src/display.rs
index a237a10f..733c66e8 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -411,7 +411,7 @@ impl Display {
self.window.get_window_id()
}
- /// Adjust the XIM editor position according to the new location of the cursor
+ /// Adjust the IME editor position according to the new location of the cursor
pub fn update_ime_position(&mut self, terminal: &Term) {
use index::{Point, Line, Column};
use term::SizeInfo;
@@ -420,8 +420,8 @@ impl Display {
cell_height: ch,
padding_x: px,
padding_y: py, ..} = *terminal.size_info();
- let nspot_y = (py + (row + 1) as f32 * ch) as i16;
- let nspot_x = (px + col as f32 * cw) as i16;
- self.window().send_xim_spot(nspot_x, nspot_y);
+ let nspot_y = (py + (row + 1) as f32 * ch) as i32;
+ let nspot_x = (px + col as f32 * cw) as i32;
+ self.window().set_ime_spot(nspot_x, nspot_y);
}
}
diff --git a/src/event.rs b/src/event.rs
index a4ca5365..4ae25860 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -262,7 +262,7 @@ impl<N: Notify> Processor<N> {
Event::WindowEvent { event, .. } => {
use glutin::WindowEvent::*;
match event {
- Closed => {
+ CloseRequested => {
if ref_test {
// dump grid state
let grid = processor.ctx.terminal.grid();
diff --git a/src/window.rs b/src/window.rs
index 42a1785e..987332e0 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -204,14 +204,14 @@ impl Window {
) -> Result<Window> {
let event_loop = EventsLoop::new();
- Window::platform_window_init();
- let window = WindowBuilder::new()
+ let window_builder = WindowBuilder::new()
.with_title(title)
.with_visibility(false)
.with_transparency(true)
.with_decorations(window_config.decorations());
- let window = create_gl_window(window.clone(), &event_loop, false)
- .or_else(|_| create_gl_window(window, &event_loop, true))?;
+ let window_builder = Window::platform_builder_ext(window_builder);
+ let window = create_gl_window(window_builder.clone(), &event_loop, false)
+ .or_else(|_| create_gl_window(window_builder, &event_loop, true))?;
window.show();
// Text cursor
@@ -322,70 +322,27 @@ 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 _);
- }
+ fn platform_builder_ext(window_builder: WindowBuilder) -> WindowBuilder {
+ use glutin::os::unix::WindowBuilderExt;
+ window_builder.with_class("alacritty".to_owned(), "Alacritty".to_owned())
}
- /// 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() {
+ fn platform_builder_ext(window_builder: WindowBuilder) -> WindowBuilder {
+ window_builder
}
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
pub fn set_urgent(&self, is_urgent: bool) {
use glutin::os::unix::WindowExt;
- use std::os::raw;
- use x11_dl::xlib::{self, XUrgencyHint};
-
- let xlib_display = self.window.get_xlib_display();
- let xlib_window = self.window.get_xlib_window();
-
- if let (Some(xlib_window), Some(xlib_display)) = (xlib_window, xlib_display) {
- let xlib = xlib::Xlib::open().expect("get xlib");
-
- unsafe {
- let mut hints = (xlib.XGetWMHints)(xlib_display as _, xlib_window as _);
-
- if hints.is_null() {
- hints = (xlib.XAllocWMHints)();
- }
-
- if is_urgent {
- (*hints).flags |= XUrgencyHint;
- } else {
- (*hints).flags &= !XUrgencyHint;
- }
-
- (xlib.XSetWMHints)(xlib_display as _, xlib_window as _, hints);
-
- (xlib.XFree)(hints as *mut raw::c_void);
- }
- }
-
+ self.window.set_urgent(is_urgent);
}
#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")))]
- pub fn set_urgent(&self, _: bool) {
- }
+ pub fn set_urgent(&self, _is_urgent: bool) {}
- #[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) {
+ pub fn set_ime_spot(&self, x: i32, y: i32) {
+ self.window.set_ime_spot(x, y);
}
#[cfg(not(target_os = "macos"))]