Use embedded resource for window icon
This commit is contained in:
parent
f48c43f4d2
commit
f4689a1c36
|
@ -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
|
- Block cursor is no longer inverted at the start/end of a selection
|
||||||
- Preserve selection on non-LMB or mouse mode clicks
|
- Preserve selection on non-LMB or mouse mode clicks
|
||||||
- Wayland client side decorations are now based on config colorscheme
|
- Wayland client side decorations are now based on config colorscheme
|
||||||
|
- Low resolution window decoration icon on Windows
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Tabstops not being reset with `reset`
|
- Tabstops not being reset with `reset`
|
||||||
|
|
|
@ -24,13 +24,18 @@ use glutin::event_loop::EventLoop;
|
||||||
use glutin::platform::macos::{RequestUserAttentionType, WindowBuilderExtMacOS, WindowExtMacOS};
|
use glutin::platform::macos::{RequestUserAttentionType, WindowBuilderExtMacOS, WindowExtMacOS};
|
||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
use glutin::platform::unix::{EventLoopWindowTargetExtUnix, WindowBuilderExtUnix, WindowExtUnix};
|
use glutin::platform::unix::{EventLoopWindowTargetExtUnix, WindowBuilderExtUnix, WindowExtUnix};
|
||||||
|
#[cfg(windows)]
|
||||||
|
use glutin::platform::windows::IconExtWindows;
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
use glutin::window::Icon;
|
use glutin::window::Icon;
|
||||||
use glutin::window::{CursorIcon, Fullscreen, Window as GlutinWindow, WindowBuilder, WindowId};
|
use glutin::window::{CursorIcon, Fullscreen, Window as GlutinWindow, WindowBuilder, WindowId};
|
||||||
use glutin::{self, ContextBuilder, PossiblyCurrent, WindowedContext};
|
use glutin::{self, ContextBuilder, PossiblyCurrent, WindowedContext};
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
use image::ImageFormat;
|
use image::ImageFormat;
|
||||||
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
use log::error;
|
use log::error;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use winapi::shared::minwindef::WORD;
|
||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
use x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib};
|
use x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib};
|
||||||
|
|
||||||
|
@ -47,9 +52,13 @@ use crate::gl;
|
||||||
use crate::wayland_theme::AlacrittyWaylandTheme;
|
use crate::wayland_theme::AlacrittyWaylandTheme;
|
||||||
|
|
||||||
// It's required to be in this directory due to the `windows.rc` file
|
// 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");
|
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
|
/// Window errors
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
@ -252,11 +261,7 @@ impl Window {
|
||||||
_ => true,
|
_ => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let image = image::load_from_memory_with_format(WINDOW_ICON, ImageFormat::Ico)
|
let icon = Icon::from_resource(IDI_ICON, None);
|
||||||
.expect("loading icon")
|
|
||||||
.to_rgba();
|
|
||||||
let (width, height) = image.dimensions();
|
|
||||||
let icon = Icon::from_rgba(image.into_raw(), width, height);
|
|
||||||
|
|
||||||
WindowBuilder::new()
|
WindowBuilder::new()
|
||||||
.with_title(title)
|
.with_title(title)
|
||||||
|
|
Loading…
Reference in New Issue