From 37a3198d8882463c9873011c1d18c325ea46d7c8 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 20 Dec 2020 07:57:03 +0000 Subject: [PATCH] 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. --- Cargo.lock | 69 ++------------------------- alacritty/Cargo.toml | 4 +- alacritty/alacritty.ico | 1 - alacritty/alacritty.png | 1 + alacritty/src/window.rs | 25 ++++++---- extra/logo/compat/alacritty-term.png | Bin 0 -> 3612 bytes 6 files changed, 22 insertions(+), 78 deletions(-) delete mode 120000 alacritty/alacritty.ico create mode 120000 alacritty/alacritty.png create mode 100644 extra/logo/compat/alacritty-term.png diff --git a/Cargo.lock b/Cargo.lock index da881a72..68d0782b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,12 +35,12 @@ dependencies = [ "fnv", "gl_generator", "glutin", - "image", "libc", "log", "notify", "objc", "parking_lot", + "png", "serde", "serde_json", "serde_yaml", @@ -196,12 +196,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "bytemuck" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac" - [[package]] name = "byteorder" version = "1.3.4" @@ -564,16 +558,6 @@ dependencies = [ "syn", ] -[[package]] -name = "deflate" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" -dependencies = [ - "adler32", - "byteorder", -] - [[package]] name = "derivative" version = "2.1.1" @@ -952,20 +936,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "image" -version = "0.23.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "985fc06b1304d19c28d5c562ed78ef5316183f2b0053b46763a0b94862373c34" -dependencies = [ - "bytemuck", - "byteorder", - "num-iter", - "num-rational", - "num-traits", - "png", -] - [[package]] name = "inotify" version = "0.7.1" @@ -1340,38 +1310,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "num-integer" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.12" @@ -1573,13 +1511,12 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "png" -version = "0.16.7" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970" +checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" dependencies = [ "bitflags", "crc32fast", - "deflate", "miniz_oxide", ] 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; diff --git a/extra/logo/compat/alacritty-term.png b/extra/logo/compat/alacritty-term.png new file mode 100644 index 0000000000000000000000000000000000000000..b8117882848a00a1c27ffae08af48db5d14da946 GIT binary patch literal 3612 zcmZ{ncRbba`^Vph93mql>ttqR9(xPfdnMyIiV(7eW1W*#ga`>oL^(z>Pxek$MkJ%p zu}9|NWb5!f_22K0-}Cjjuh-)q*M0qU-;euFFgMksrRJap0D#s&U)z%88h;xDm=sS> zD)LBn$z9V#69B4T(EPbiLF)6k=v$fqK$su^pkhg@NJFS!0Pq+J02}uJK>0NQu==5! zEL2GoU}qyeZIY8Xx!sH;*=0X{yFilP``328v_?p!xeT;5twU$FVGib2cUjL(hYhsI zUgyGe-oiawlkBrS9Xbk~CCRzyw{n_!iYzAPwNsQ&*!NbC zo9bMzK$RRs-$9lX3WK5tH_%M9H##FEX@U>!!nbRGz{4wAkES&s z{-5`jqZ!LO{2Lol)}GiVn1KRJyjn-6;fSy+&PO3LhP<7`9vHirf2=Z zpE<%1eu&uowT8U~8o;`K8HwuFoRDfKG)9kn-wfAZ;vfLJ)%{G{lna_B9t2|##b?+VZE?}+g4?dun0rkJ8$d(cB{ zcC)-M7(xf1yKnC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