mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
parent
7eb0ea82ef
commit
a7a6bf53d4
3 changed files with 33 additions and 53 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
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 {
|
||||
pub fn get_platform_window(
|
||||
title: &str,
|
||||
class: &str,
|
||||
window_config: &WindowConfig
|
||||
) -> WindowBuilder {
|
||||
use glutin::os::unix::WindowBuilderExt;
|
||||
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue