1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Use embedded resource for window icon

This commit is contained in:
David Hewitt 2020-04-25 15:39:27 +01:00 committed by GitHub
parent f48c43f4d2
commit f4689a1c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View file

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Block cursor is no longer inverted at the start/end of a selection
- Preserve selection on non-LMB or mouse mode clicks
- Wayland client side decorations are now based on config colorscheme
- Low resolution window decoration icon on Windows
### Fixed
- Tabstops not being reset with `reset`

View file

@ -24,13 +24,18 @@ use glutin::event_loop::EventLoop;
use glutin::platform::macos::{RequestUserAttentionType, WindowBuilderExtMacOS, WindowExtMacOS};
#[cfg(not(any(target_os = "macos", windows)))]
use glutin::platform::unix::{EventLoopWindowTargetExtUnix, WindowBuilderExtUnix, WindowExtUnix};
#[cfg(windows)]
use glutin::platform::windows::IconExtWindows;
#[cfg(not(target_os = "macos"))]
use glutin::window::Icon;
use glutin::window::{CursorIcon, Fullscreen, Window as GlutinWindow, WindowBuilder, WindowId};
use glutin::{self, ContextBuilder, PossiblyCurrent, WindowedContext};
#[cfg(not(target_os = "macos"))]
#[cfg(not(any(target_os = "macos", windows)))]
use image::ImageFormat;
#[cfg(not(any(target_os = "macos", windows)))]
use log::error;
#[cfg(windows)]
use winapi::shared::minwindef::WORD;
#[cfg(not(any(target_os = "macos", windows)))]
use x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib};
@ -47,9 +52,13 @@ use crate::gl;
use crate::wayland_theme::AlacrittyWaylandTheme;
// It's required to be in this directory due to the `windows.rc` file
#[cfg(not(target_os = "macos"))]
#[cfg(not(any(target_os = "macos", windows)))]
static WINDOW_ICON: &[u8] = include_bytes!("../../extra/windows/alacritty.ico");
// This should match the definition of IDI_ICON from `windows.rc`
#[cfg(windows)]
const IDI_ICON: WORD = 0x101;
/// Window errors
#[derive(Debug)]
pub enum Error {
@ -252,11 +261,7 @@ impl Window {
_ => true,
};
let image = image::load_from_memory_with_format(WINDOW_ICON, ImageFormat::Ico)
.expect("loading icon")
.to_rgba();
let (width, height) = image.dimensions();
let icon = Icon::from_rgba(image.into_raw(), width, height);
let icon = Icon::from_resource(IDI_ICON, None);
WindowBuilder::new()
.with_title(title)