From a56f37598c3f81eaf0f9c31ee31a04ae6faceff3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 24 Mar 2019 19:06:03 -0700 Subject: [PATCH] Embed icon into windows executable and titlebar This also applies to X11 when using the glutin frontend --- Cargo.toml | 5 ++++- assets/windows/manifest.manifest | 9 +++++++++ assets/windows/resource.rc | 5 +++++ assets/{icon => windows}/terminal.ico | Bin build.rs | 3 +++ src/frontend/glium/window.rs | 3 +++ 6 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 assets/windows/manifest.manifest create mode 100644 assets/windows/resource.rc rename assets/{icon => windows}/terminal.ico (100%) diff --git a/Cargo.toml b/Cargo.toml index 40bf946fb..6510c32f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,9 @@ build = "build.rs" [build-dependencies] vergen = "3" +[target.'cfg(windows)'.build-dependencies] +embed-resource = "1.1" + [dependencies] base91 = { path = "base91" } bitflags = "1.0" @@ -20,7 +23,7 @@ failure_derive = "0.1" foreign-types = "0.3" freetype = { path = "deps/freetype" } gl = "0.11" -glium = { version = "0.23", default-features = false, features = ["glutin"]} +glium = { version = "0.23", default-features = false, features = ["glutin", "icon_loading"]} harfbuzz = { path = "deps/harfbuzz" } lazy_static = "1.3" leb128 = "0.2" diff --git a/assets/windows/manifest.manifest b/assets/windows/manifest.manifest new file mode 100644 index 000000000..1eea409e7 --- /dev/null +++ b/assets/windows/manifest.manifest @@ -0,0 +1,9 @@ + + + + + PerMonitorV2, unaware + + + diff --git a/assets/windows/resource.rc b/assets/windows/resource.rc new file mode 100644 index 000000000..85f0b24c7 --- /dev/null +++ b/assets/windows/resource.rc @@ -0,0 +1,5 @@ +#define IDI_ICON 0x101 +IDI_ICON ICON "terminal.ico" +#define RT_MANIFEST 24 +#define APP_MANIFEST 1 +APP_MANIFEST RT_MANIFEST manifest.manifest diff --git a/assets/icon/terminal.ico b/assets/windows/terminal.ico similarity index 100% rename from assets/icon/terminal.ico rename to assets/windows/terminal.ico diff --git a/build.rs b/build.rs index 2257407a8..14408c9bf 100644 --- a/build.rs +++ b/build.rs @@ -7,4 +7,7 @@ fn main() { // Generate the 'cargo:' key output generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!"); + + #[cfg(windows)] + embed_resource::compile("assets/windows/resource.rc"); } diff --git a/src/frontend/glium/window.rs b/src/frontend/glium/window.rs index dbeafaa7f..f08455880 100644 --- a/src/frontend/glium/window.rs +++ b/src/frontend/glium/window.rs @@ -214,6 +214,9 @@ impl GliumTerminalWindow { .with_pixel_format(24, 8); let window = glutin::WindowBuilder::new() .with_dimensions(logical_size) + .with_window_icon(Some(glutin::Icon::from_bytes(include_bytes!( + "../../../assets/icon/terminal.png" + ))?)) .with_title("wezterm"); let mut_loop = event_loop.event_loop.borrow_mut();