diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-12-20 07:57:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-20 07:57:03 +0000 |
commit | 37a3198d8882463c9873011c1d18c325ea46d7c8 (patch) | |
tree | 85ffd2da842823109fc50ce9b41c5c109e71068f /alacritty | |
parent | f016a209b4ac1bfa6625b9d30e6f69bc91bc7545 (diff) | |
download | r-alacritty-37a3198d8882463c9873011c1d18c325ea46d7c8.tar.gz r-alacritty-37a3198d8882463c9873011c1d18c325ea46d7c8.tar.bz2 r-alacritty-37a3198d8882463c9873011c1d18c325ea46d7c8.zip |
Fix embedded _NET_WM_ICON on X11
Previously the _NET_WM_ICON would use the .ico which was also used for
the Windows icon. This icon used the dimensions 256x256, but the maximum
supported image size is 192x192, so a new image with the dimensions
64x64 has been added.
Since we know the image format anyways, the `image` dependency could
also be easily replaced with `png`, which cuts out a few extra unused
dependencies.
Diffstat (limited to 'alacritty')
-rw-r--r-- | alacritty/Cargo.toml | 4 | ||||
l--------- | alacritty/alacritty.ico | 1 | ||||
l--------- | alacritty/alacritty.png | 1 | ||||
-rw-r--r-- | alacritty/src/window.rs | 25 |
4 files changed, 19 insertions, 12 deletions
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml index a4f774b1..b5ebefe2 100644 --- a/alacritty/Cargo.toml +++ b/alacritty/Cargo.toml @@ -39,7 +39,7 @@ gl_generator = "0.14.0" xdg = "2" [target.'cfg(not(target_os = "macos"))'.dependencies] -image = { version = "0.23.3", default-features = false, features = ["ico"], optional = true } +png = { version = "0.16.8", default-features = false, optional = true } [target.'cfg(target_os = "macos")'.dependencies] objc = "0.2.2" @@ -56,7 +56,7 @@ embed-resource = "1.3" [features] default = ["wayland", "x11"] -x11 = ["copypasta/x11", "glutin/x11", "x11-dl", "image"] +x11 = ["copypasta/x11", "glutin/x11", "x11-dl", "png"] wayland = ["copypasta/wayland", "glutin/wayland", "wayland-client"] winpty = ["alacritty_terminal/winpty"] nightly = [] diff --git a/alacritty/alacritty.ico b/alacritty/alacritty.ico deleted file mode 120000 index 55cd1859..00000000 --- a/alacritty/alacritty.ico +++ /dev/null @@ -1 +0,0 @@ -../extra/windows/alacritty.ico
\ No newline at end of file diff --git a/alacritty/alacritty.png b/alacritty/alacritty.png new file mode 120000 index 00000000..3865403a --- /dev/null +++ b/alacritty/alacritty.png @@ -0,0 +1 @@ +../extra/logo/compat/alacritty-term.png
\ No newline at end of file diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs index e43e5c95..1b9e7731 100644 --- a/alacritty/src/window.rs +++ b/alacritty/src/window.rs @@ -19,8 +19,15 @@ use { crate::wayland_theme::AlacrittyWaylandTheme, }; +#[rustfmt::skip] #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] -use x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib}; +use { + std::io::Cursor, + + x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib}, + glutin::window::Icon, + png::Decoder, +}; use std::fmt::{self, Display, Formatter}; @@ -44,11 +51,11 @@ use crate::config::window::{Decorations, WindowConfig}; use crate::config::Config; use crate::gl; -// It's required to be in this directory due to the `windows.rc` file. +/// Window icon for `_NET_WM_ICON` property. #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] -static WINDOW_ICON: &[u8] = include_bytes!("../alacritty.ico"); +static WINDOW_ICON: &[u8] = include_bytes!("../alacritty.png"); -// This should match the definition of IDI_ICON from `windows.rc`. +/// This should match the definition of IDI_ICON from `windows.rc`. #[cfg(windows)] const IDI_ICON: WORD = 0x101; @@ -257,11 +264,11 @@ impl Window { pub fn get_platform_window(title: &str, window_config: &WindowConfig) -> WindowBuilder { #[cfg(feature = "x11")] let icon = { - let image = image::load_from_memory_with_format(WINDOW_ICON, image::ImageFormat::Ico) - .expect("loading icon") - .to_rgba(); - let (width, height) = image.dimensions(); - glutin::window::Icon::from_rgba(image.into_raw(), width, height) + let decoder = Decoder::new(Cursor::new(WINDOW_ICON)); + let (info, mut reader) = decoder.read_info().expect("invalid embedded icon"); + let mut buf = vec![0; info.buffer_size()]; + let _ = reader.next_frame(&mut buf); + Icon::from_rgba(buf, info.width, info.height) }; let class = &window_config.class; |