aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-02-06 21:10:45 +0000
committerGitHub <noreply@github.com>2019-02-06 21:10:45 +0000
commita7a6bf53d4bbb50940559f3a411aba5c474b3409 (patch)
tree877dd17e0dfd0c738e6010a69a6a260384ef8843
parent7eb0ea82ef491f277b8278b64272dd7f245c5953 (diff)
downloadalacritty-a7a6bf53d4bbb50940559f3a411aba5c474b3409.tar.gz
alacritty-a7a6bf53d4bbb50940559f3a411aba5c474b3409.zip
Set window title on Wayland
Fixes #1582. Fixes #1875.
-rw-r--r--CHANGELOG.md4
-rw-r--r--src/cli.rs6
-rw-r--r--src/window.rs74
3 files changed, 32 insertions, 52 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01208769..cd7ab1de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- Window class on Wayland is set to `Alacritty` by default
+
### Changed
- Improve scrolling accuracy with devices sending fractional updates (like touchpads)
diff --git a/src/cli.rs b/src/cli.rs
index af8346f9..1d16b6bc 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -16,7 +16,7 @@ use clap::{Arg, App, crate_name, crate_version, crate_authors, crate_description
use crate::index::{Line, Column};
use crate::config::{Dimensions, Shell};
-use crate::window::{DEFAULT_TITLE, DEFAULT_CLASS};
+use crate::window::{DEFAULT_NAME};
use std::path::{Path, PathBuf};
use std::borrow::Cow;
@@ -87,11 +87,11 @@ impl Options {
.long("title")
.short("t")
.takes_value(true)
- .help(&format!("Defines the window title [default: {}]", DEFAULT_TITLE)))
+ .help(&format!("Defines the window title [default: {}]", DEFAULT_NAME)))
.arg(Arg::with_name("class")
.long("class")
.takes_value(true)
- .help(&format!("Defines window class on X11 [default: {}]", DEFAULT_CLASS)))
+ .help(&format!("Defines window class on X11 [default: {}]", DEFAULT_NAME)))
.arg(Arg::with_name("q")
.short("q")
.multiple(true)
diff --git a/src/window.rs b/src/window.rs
index 0f401528..cdc3bdc7 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -33,22 +33,8 @@ use crate::MouseCursor;
#[cfg(windows)]
static WINDOW_ICON: &'static [u8] = include_bytes!("../assets/windows/alacritty.ico");
-/// Default text for the window's title bar, if not overriden.
-///
-/// In X11, this the default value for the `WM_NAME` property.
-pub const DEFAULT_TITLE: &str = "Alacritty";
-
-/// Default text for general window class, X11 specific.
-///
-/// In X11, this is the default value for the `WM_CLASS` property. The
-/// second value of `WM_CLASS` is **never** changed to anything but
-/// the default value.
-///
-/// ```ignore
-/// $ xprop | grep WM_CLASS
-/// WM_CLASS(STRING) = "Alacritty", "Alacritty"
-/// ```
-pub const DEFAULT_CLASS: &str = "Alacritty";
+/// Default Alacritty name, used for window title and class.
+pub const DEFAULT_NAME: &str = "Alacritty";
/// Window errors
#[derive(Debug)]
@@ -148,10 +134,9 @@ impl Window {
pub fn new(options: &Options, window_config: &WindowConfig) -> Result<Window> {
let event_loop = EventsLoop::new();
- let title = options.title.as_ref().map_or(DEFAULT_TITLE, |t| t);
- let class = options.class.as_ref().map_or(DEFAULT_TITLE, |c| c);
- let window_builder = Window::get_platform_window(title, window_config);
- let window_builder = Window::platform_builder_ext(window_builder, &class);
+ let title = options.title.as_ref().map_or(DEFAULT_NAME, |t| t);
+ let class = options.class.as_ref().map_or(DEFAULT_NAME, |c| c);
+ let window_builder = Window::get_platform_window(title, class, window_config);
let window = create_gl_window(window_builder.clone(), &event_loop, false)
.or_else(|_| create_gl_window(window_builder, &event_loop, true))?;
window.show();
@@ -262,35 +247,14 @@ impl Window {
}
}
- #[cfg(
- any(
- target_os = "linux",
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "openbsd"
- )
- )]
- fn platform_builder_ext(window_builder: WindowBuilder, wm_class: &str) -> WindowBuilder {
+ #[cfg(not(any(target_os = "macos", windows)))]
+ pub fn get_platform_window(
+ title: &str,
+ class: &str,
+ window_config: &WindowConfig
+ ) -> WindowBuilder {
use glutin::os::unix::WindowBuilderExt;
- window_builder.with_class(wm_class.to_owned(), "Alacritty".to_owned())
- }
-
- #[cfg(
- not(
- any(
- target_os = "linux",
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "openbsd"
- )
- )
- )]
- fn platform_builder_ext(window_builder: WindowBuilder, _: &str) -> WindowBuilder {
- window_builder
- }
- #[cfg(not(any(target_os = "macos", windows)))]
- pub fn get_platform_window(title: &str, window_config: &WindowConfig) -> WindowBuilder {
let decorations = match window_config.decorations() {
Decorations::None => false,
_ => true,
@@ -302,10 +266,18 @@ impl Window {
.with_transparency(true)
.with_maximized(window_config.start_maximized())
.with_decorations(decorations)
+ // X11
+ .with_class(class.into(), DEFAULT_NAME.into())
+ // Wayland
+ .with_app_id(class.into())
}
#[cfg(windows)]
- pub fn get_platform_window(title: &str, window_config: &WindowConfig) -> WindowBuilder {
+ pub fn get_platform_window(
+ title: &str,
+ _class: &str,
+ window_config: &WindowConfig
+ ) -> WindowBuilder {
let icon = Icon::from_bytes_with_format(WINDOW_ICON, ImageFormat::ICO).unwrap();
let decorations = match window_config.decorations() {
@@ -323,7 +295,11 @@ impl Window {
}
#[cfg(target_os = "macos")]
- pub fn get_platform_window(title: &str, window_config: &WindowConfig) -> WindowBuilder {
+ pub fn get_platform_window(
+ title: &str,
+ _class: &str,
+ window_config: &WindowConfig
+ ) -> WindowBuilder {
use glutin::os::macos::WindowBuilderExt;
let window = WindowBuilder::new()