aboutsummaryrefslogtreecommitdiff
path: root/src/window.rs
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/window.rs
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/window.rs')
-rw-r--r--src/window.rs69
1 files changed, 13 insertions, 56 deletions
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"))]