aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-12-20 07:57:03 +0000
committerGitHub <noreply@github.com>2020-12-20 07:57:03 +0000
commit37a3198d8882463c9873011c1d18c325ea46d7c8 (patch)
tree85ffd2da842823109fc50ce9b41c5c109e71068f /alacritty/src
parentf016a209b4ac1bfa6625b9d30e6f69bc91bc7545 (diff)
downloadr-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/src')
-rw-r--r--alacritty/src/window.rs25
1 files changed, 16 insertions, 9 deletions
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;