aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/window.rs
diff options
context:
space:
mode:
authorDavid Hewitt <1939362+davidhewitt@users.noreply.github.com>2020-04-25 15:39:27 +0100
committerGitHub <noreply@github.com>2020-04-25 14:39:27 +0000
commitf4689a1c362f851e37b0f9a2fa32fe0f5e9ef3b8 (patch)
tree73f942b70b9a5aa79b6b9ba047d89e2b51c8a171 /alacritty/src/window.rs
parentf48c43f4d2fcac35fe2777a3f0f155c275d0204e (diff)
downloadr-alacritty-f4689a1c362f851e37b0f9a2fa32fe0f5e9ef3b8.tar.gz
r-alacritty-f4689a1c362f851e37b0f9a2fa32fe0f5e9ef3b8.tar.bz2
r-alacritty-f4689a1c362f851e37b0f9a2fa32fe0f5e9ef3b8.zip
Use embedded resource for window icon
Diffstat (limited to 'alacritty/src/window.rs')
-rw-r--r--alacritty/src/window.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 4169814b..042ec87d 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -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)