mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Set _NET_WM_ICON on X11
This commit is contained in:
parent
b321406908
commit
37b66a7cd2
3 changed files with 13 additions and 6 deletions
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- On macOS, there's a ToggleSimpleFullscreen action which allows switching to
|
- On macOS, there's a ToggleSimpleFullscreen action which allows switching to
|
||||||
fullscreen without occupying another space
|
fullscreen without occupying another space
|
||||||
- A new window option `startup_mode` which controls how the window is created
|
- A new window option `startup_mode` which controls how the window is created
|
||||||
|
- `_NET_WM_ICON` property is set on X11 now, allowing for WMs to show icons in titlebars
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ winapi = { version = "0.3.7", features = ["impl-default", "winuser", "synchapi",
|
||||||
dirs = "1.0"
|
dirs = "1.0"
|
||||||
widestring = "0.4"
|
widestring = "0.4"
|
||||||
mio-anonymous-pipes = "0.1"
|
mio-anonymous-pipes = "0.1"
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||||
image = "0.21.0"
|
image = "0.21.0"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
|
|
@ -18,19 +18,20 @@ use crate::gl;
|
||||||
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
use glutin::os::unix::EventsLoopExt;
|
use glutin::os::unix::EventsLoopExt;
|
||||||
#[cfg(windows)]
|
#[cfg(not(target_os = "macos"))]
|
||||||
use glutin::Icon;
|
use glutin::Icon;
|
||||||
use glutin::{
|
use glutin::{
|
||||||
self, ContextBuilder, ControlFlow, Event, EventsLoop, MouseCursor, PossiblyCurrent,
|
self, ContextBuilder, ControlFlow, Event, EventsLoop, MouseCursor, PossiblyCurrent,
|
||||||
WindowBuilder,
|
WindowBuilder,
|
||||||
};
|
};
|
||||||
#[cfg(windows)]
|
#[cfg(not(target_os = "macos"))]
|
||||||
use image::ImageFormat;
|
use image::ImageFormat;
|
||||||
|
|
||||||
use crate::cli::Options;
|
use crate::cli::Options;
|
||||||
use crate::config::{Decorations, StartupMode, WindowConfig};
|
use crate::config::{Decorations, StartupMode, WindowConfig};
|
||||||
|
|
||||||
#[cfg(windows)]
|
// It's required to be in this directory due to the `windows.rc` file
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
static WINDOW_ICON: &'static [u8] = include_bytes!("../../extra/windows/alacritty.ico");
|
static WINDOW_ICON: &'static [u8] = include_bytes!("../../extra/windows/alacritty.ico");
|
||||||
|
|
||||||
/// Default Alacritty name, used for window title and class.
|
/// Default Alacritty name, used for window title and class.
|
||||||
|
@ -288,12 +289,15 @@ impl Window {
|
||||||
_ => true,
|
_ => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let icon = Icon::from_bytes_with_format(WINDOW_ICON, ImageFormat::ICO);
|
||||||
|
|
||||||
WindowBuilder::new()
|
WindowBuilder::new()
|
||||||
.with_title(title)
|
.with_title(title)
|
||||||
.with_visibility(false)
|
.with_visibility(false)
|
||||||
.with_transparency(true)
|
.with_transparency(true)
|
||||||
.with_decorations(decorations)
|
.with_decorations(decorations)
|
||||||
.with_maximized(window_config.startup_mode() == StartupMode::Maximized)
|
.with_maximized(window_config.startup_mode() == StartupMode::Maximized)
|
||||||
|
.with_window_icon(icon.ok())
|
||||||
// X11
|
// X11
|
||||||
.with_class(class.into(), DEFAULT_NAME.into())
|
.with_class(class.into(), DEFAULT_NAME.into())
|
||||||
// Wayland
|
// Wayland
|
||||||
|
@ -306,20 +310,20 @@ impl Window {
|
||||||
_class: &str,
|
_class: &str,
|
||||||
window_config: &WindowConfig,
|
window_config: &WindowConfig,
|
||||||
) -> WindowBuilder {
|
) -> WindowBuilder {
|
||||||
let icon = Icon::from_bytes_with_format(WINDOW_ICON, ImageFormat::ICO).unwrap();
|
|
||||||
|
|
||||||
let decorations = match window_config.decorations() {
|
let decorations = match window_config.decorations() {
|
||||||
Decorations::None => false,
|
Decorations::None => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let icon = Icon::from_bytes_with_format(WINDOW_ICON, ImageFormat::ICO);
|
||||||
|
|
||||||
WindowBuilder::new()
|
WindowBuilder::new()
|
||||||
.with_title(title)
|
.with_title(title)
|
||||||
.with_visibility(cfg!(windows))
|
.with_visibility(cfg!(windows))
|
||||||
.with_decorations(decorations)
|
.with_decorations(decorations)
|
||||||
.with_transparency(true)
|
.with_transparency(true)
|
||||||
.with_maximized(window_config.startup_mode() == StartupMode::Maximized)
|
.with_maximized(window_config.startup_mode() == StartupMode::Maximized)
|
||||||
.with_window_icon(Some(icon))
|
.with_window_icon(icon.ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|
Loading…
Reference in a new issue