aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTezkerek <andrei.ancuta@gmail.com>2018-06-07 19:53:16 +0300
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-06-07 16:53:16 +0000
commit66acf1e03da4d0206e3368bf58953b071887ccb2 (patch)
treebcdff68e708c02c75df6ffc0545d2fb5d13389d3
parent93780ef0929e08f3c5212e5451152ecaf1a28813 (diff)
downloadalacritty-66acf1e03da4d0206e3368bf58953b071887ccb2.tar.gz
alacritty-66acf1e03da4d0206e3368bf58953b071887ccb2.zip
Add working --class and --title CLI parameters
-rw-r--r--src/cli.rs11
-rw-r--r--src/display.rs2
-rw-r--r--src/window.rs13
3 files changed, 19 insertions, 7 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 532c46cd..e57caf0d 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -19,6 +19,7 @@ use std::path::{Path, PathBuf};
use std::borrow::Cow;
const DEFAULT_TITLE: &str = "Alacritty";
+const DEFAULT_CLASS: &str = "Alacritty";
/// Options specified on the command line
pub struct Options {
@@ -27,6 +28,7 @@ pub struct Options {
pub ref_test: bool,
pub dimensions: Option<Dimensions>,
pub title: String,
+ pub class: String,
pub log_level: log::LevelFilter,
pub command: Option<Shell<'static>>,
pub working_dir: Option<PathBuf>,
@@ -41,6 +43,7 @@ impl Default for Options {
ref_test: false,
dimensions: None,
title: DEFAULT_TITLE.to_owned(),
+ class: DEFAULT_CLASS.to_owned(),
log_level: log::LevelFilter::Warn,
command: None,
working_dir: None,
@@ -81,6 +84,10 @@ impl Options {
.short("t")
.default_value(DEFAULT_TITLE)
.help("Defines the window title"))
+ .arg(Arg::with_name("class")
+ .long("class")
+ .default_value(DEFAULT_CLASS)
+ .help("Defines window class on X11"))
.arg(Arg::with_name("q")
.short("q")
.multiple(true)
@@ -136,6 +143,10 @@ impl Options {
options.title = title.to_owned();
}
+ if let Some(class) = matches.value_of("class") {
+ options.class = class.to_owned();
+ }
+
match matches.occurrences_of("q") {
0 => {},
1 => options.log_level = log::LevelFilter::Error,
diff --git a/src/display.rs b/src/display.rs
index 2b87bf50..e0453f72 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -137,7 +137,7 @@ impl Display {
let render_timer = config.render_timer();
// Create the window where Alacritty will be displayed
- let mut window = Window::new(&options.title, config.window())?;
+ let mut window = Window::new(&options, config.window())?;
// get window properties for initializing the other subsystems
let mut viewport_size = window.inner_size_pixels()
diff --git a/src/window.rs b/src/window.rs
index 987332e0..ef0d9269 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -22,6 +22,7 @@ use glutin::GlContext;
use MouseCursor;
+use cli::Options;
use config::WindowConfig;
/// Window errors
@@ -199,17 +200,17 @@ impl Window {
///
/// This creates a window and fully initializes a window.
pub fn new(
- title: &str,
+ options: &Options,
window_config: &WindowConfig,
) -> Result<Window> {
let event_loop = EventsLoop::new();
let window_builder = WindowBuilder::new()
- .with_title(title)
+ .with_title(&*options.title)
.with_visibility(false)
.with_transparency(true)
.with_decorations(window_config.decorations());
- let window_builder = Window::platform_builder_ext(window_builder);
+ let window_builder = Window::platform_builder_ext(window_builder, &options.class);
let window = create_gl_window(window_builder.clone(), &event_loop, false)
.or_else(|_| create_gl_window(window_builder, &event_loop, true))?;
window.show();
@@ -322,13 +323,13 @@ impl Window {
}
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
- fn platform_builder_ext(window_builder: WindowBuilder) -> WindowBuilder {
+ fn platform_builder_ext(window_builder: WindowBuilder, wm_class: &str) -> WindowBuilder {
use glutin::os::unix::WindowBuilderExt;
- window_builder.with_class("alacritty".to_owned(), "Alacritty".to_owned())
+ 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) -> WindowBuilder {
+ fn platform_builder_ext(window_builder: WindowBuilder, _: &str) -> WindowBuilder {
window_builder
}