summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2020-11-14 21:10:26 +0300
committerGitHub <noreply@github.com>2020-11-14 21:10:26 +0300
commit9531e661b1cf777fc24d011e6116a501bd1b75e5 (patch)
tree5eb7f289690f5cc0ae572a985aeaf1f8206c7f60
parentc63bdf5cb966a5dd0afa3ed0327efca691abf504 (diff)
downloadalacritty-9531e661b1cf777fc24d011e6116a501bd1b75e5.tar.gz
alacritty-9531e661b1cf777fc24d011e6116a501bd1b75e5.zip
Feature gate 'image' when building without x11 feature
On Wayland there's no way to embed icon into the window, thus there's no point in loading it when x11 feature is disabled.
-rw-r--r--alacritty/Cargo.toml4
-rw-r--r--alacritty/src/window.rs26
2 files changed, 16 insertions, 14 deletions
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index 873c3da6..7a56f90c 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -37,7 +37,7 @@ gl_generator = "0.14.0"
xdg = "2"
[target.'cfg(not(target_os = "macos"))'.dependencies]
-image = { version = "0.23.3", default-features = false, features = ["ico"] }
+image = { version = "0.23.3", default-features = false, features = ["ico"], optional = true }
[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2.2"
@@ -57,7 +57,7 @@ embed-resource = "1.3"
[features]
default = ["wayland", "x11"]
-x11 = ["copypasta/x11", "glutin/x11", "x11-dl"]
+x11 = ["copypasta/x11", "glutin/x11", "x11-dl", "image"]
wayland = ["copypasta/wayland", "glutin/wayland", "wayland-client"]
winpty = ["alacritty_terminal/winpty"]
# Enabling this feature makes shaders automatically reload when changed
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 38e29328..953fffd9 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -5,7 +5,6 @@ use {
std::sync::Arc,
glutin::platform::unix::{WindowBuilderExtUnix, WindowExtUnix},
- image::ImageFormat,
};
#[rustfmt::skip]
@@ -31,8 +30,6 @@ use glutin::event_loop::EventLoop;
use glutin::platform::macos::{RequestUserAttentionType, WindowBuilderExtMacOS, WindowExtMacOS};
#[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(windows)]
@@ -46,7 +43,7 @@ use crate::config::Config;
use crate::gl;
// It's required to be in this directory due to the `windows.rc` file.
-#[cfg(not(any(target_os = "macos", windows)))]
+#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
static WINDOW_ICON: &[u8] = include_bytes!("../alacritty.ico");
// This should match the definition of IDI_ICON from `windows.rc`.
@@ -256,11 +253,14 @@ impl Window {
#[cfg(not(any(target_os = "macos", windows)))]
pub fn get_platform_window(title: &str, window_config: &WindowConfig) -> WindowBuilder {
- 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);
+ #[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 class = &window_config.class;
@@ -270,8 +270,10 @@ impl Window {
.with_transparent(true)
.with_decorations(window_config.decorations != Decorations::None)
.with_maximized(window_config.maximized())
- .with_fullscreen(window_config.fullscreen())
- .with_window_icon(icon.ok());
+ .with_fullscreen(window_config.fullscreen());
+
+ #[cfg(feature = "x11")]
+ let builder = builder.with_window_icon(icon.ok());
#[cfg(feature = "wayland")]
let builder = builder.with_app_id(class.instance.clone());
@@ -290,7 +292,7 @@ impl Window {
#[cfg(windows)]
pub fn get_platform_window(title: &str, window_config: &WindowConfig) -> WindowBuilder {
- let icon = Icon::from_resource(IDI_ICON, None);
+ let icon = glutin::window::Icon::from_resource(IDI_ICON, None);
WindowBuilder::new()
.with_title(title)