Commit 765949f2 authored by Francesca Frangipane's avatar Francesca Frangipane Committed by Joe Wilm

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.
parent f7172fd6
This diff is collapsed.
......@@ -33,7 +33,7 @@ clap = "2"
fnv = "1"
unicode-width = "0.1"
arraydeque = "0.4"
glutin = "0.13"
glutin = "0.16"
clippy = { version = "*", optional = true }
env_logger = "0.5"
base64 = "0.9.0"
......
......@@ -246,7 +246,8 @@ system menus. To install the desktop entry for Alacritty, run
```sh
sudo cp target/release/alacritty /usr/local/bin # or anywhere else in $PATH
cp Alacritty.desktop ~/.local/share/applications
sudo desktop-file-install alacritty.desktop
sudo update-desktop-database
```
#### MacOS
......
......@@ -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);
}
}
......@@ -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();
......
......@@ -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"))]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment