From 04ecd164930be3509c2b304ed35f6fee51650ca3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 27 Feb 2021 23:59:04 -0800 Subject: [PATCH] remove `--front-end` CLI option Can use `--config front_end="Software"` instead. --- docs/changelog.md | 2 +- wezterm-gui-subcommands/src/lib.rs | 30 +----------------------------- wezterm-gui/src/gui/mod.rs | 26 ++------------------------ wezterm-gui/src/main.rs | 20 ++++++++------------ wezterm-gui/src/window_config.rs | 13 +++++++++++++ window/src/configuration.rs | 4 ++++ window/src/egl.rs | 9 ++++++--- window/src/lib.rs | 11 ----------- 8 files changed, 35 insertions(+), 80 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index b311e3803..16fbf5916 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -33,7 +33,7 @@ brief notes about them may accumulate here. * Windows: Fixed [ToggleFullScreen](config/lua/keyassignment/ToggleFullScreen.md) so that it once again toggles between full screen and normal placement. [#177](https://github.com/wez/wezterm/issues/177) * New: [exit_behavior](config/lua/config/exit_behavior.md) config option to keep panes open after the program has completed. [#499](https://github.com/wez/wezterm/issues/499) * Closing the configuration error window no longer requires confirmation -* New: added `--config name=value` options to `wezterm`, `wezterm-gui` and `wezterm-mux-server`. The `--font-locator`, `--font-rasterizer` and `--font-shaper` CLI options have been removed in favor of this new mechanism. +* New: added `--config name=value` options to `wezterm`, `wezterm-gui` and `wezterm-mux-server`. The `--front-end`, `--font-locator`, `--font-rasterizer` and `--font-shaper` CLI options have been removed in favor of this new mechanism. * New: [window:set_config_overrides](config/lua/window/set_config_overrides.md) method that can be used to override GUI related configuration options on a per-window basis. Click through to see examples of dynamically toggling ligatures and window opacity. [#469](https://github.com/wez/wezterm/issues/469) [#329](https://github.com/wez/wezterm/issues/329) ### 20210203-095643-70a364eb diff --git a/wezterm-gui-subcommands/src/lib.rs b/wezterm-gui-subcommands/src/lib.rs index d56e47f80..0507717e1 100644 --- a/wezterm-gui-subcommands/src/lib.rs +++ b/wezterm-gui-subcommands/src/lib.rs @@ -1,4 +1,4 @@ -use config::{FrontEndSelection, SshParameters}; +use config::SshParameters; use std::ffi::OsString; use structopt::StructOpt; @@ -22,13 +22,6 @@ pub fn name_equals_value(arg: &str) -> Result<(String, String), String> { #[derive(Debug, StructOpt, Default, Clone)] pub struct StartCommand { - #[structopt( - long = "front-end", - possible_values = &FrontEndSelection::variants(), - case_insensitive = true - )] - pub front_end: Option, - /// If true, do not connect to domains marked as connect_automatically /// in your wezterm.toml configuration file. #[structopt(long = "no-auto-connect")] @@ -58,13 +51,6 @@ pub struct StartCommand { #[derive(Debug, StructOpt, Clone)] pub struct SshCommand { - #[structopt( - long = "front-end", - possible_values = &FrontEndSelection::variants(), - case_insensitive = true - )] - pub front_end: Option, - /// Specifies the remote system using the form: /// `[username@]host[:port]`. /// If `username@` is omitted, then your local $USER is used @@ -82,13 +68,6 @@ pub struct SshCommand { #[derive(Debug, StructOpt, Clone)] pub struct SerialCommand { - #[structopt( - long = "front-end", - possible_values = &FrontEndSelection::variants(), - case_insensitive = true - )] - pub front_end: Option, - /// Set the baud rate. The default is 9600 baud. #[structopt(long = "baud")] pub baud: Option, @@ -102,13 +81,6 @@ pub struct SerialCommand { #[derive(Debug, StructOpt, Clone)] pub struct ConnectCommand { - #[structopt( - long = "front-end", - possible_values = &FrontEndSelection::variants(), - case_insensitive = true - )] - pub front_end: Option, - /// Name of the multiplexer domain section from the configuration /// to which you'd like to connect pub domain_name: String, diff --git a/wezterm-gui/src/gui/mod.rs b/wezterm-gui/src/gui/mod.rs index e7d9dfd06..8f0daf933 100644 --- a/wezterm-gui/src/gui/mod.rs +++ b/wezterm-gui/src/gui/mod.rs @@ -34,22 +34,7 @@ impl Drop for GuiFrontEnd { } impl GuiFrontEnd { - pub fn try_new_swrast() -> anyhow::Result> { - ::window::prefer_swrast(); - Self::try_new() - } - pub fn try_new() -> anyhow::Result> { - #[cfg(windows)] - { - if is_running_in_rdp_session() { - // Using OpenGL in RDP has problematic behavior upon - // disconnect, so we force the use of software rendering. - log::trace!("Running in an RDP session, use SWRAST"); - prefer_swrast(); - } - } - let connection = Connection::init()?; let front_end = Rc::new(GuiFrontEnd { connection }); let mux = Mux::get().expect("mux started and running on main thread"); @@ -131,15 +116,8 @@ pub fn shutdown() { FRONT_END.with(|f| drop(f.borrow_mut().take())); } -pub fn try_new(sel: FrontEndSelection) -> Result, Error> { - let front_end = match sel { - FrontEndSelection::Software => GuiFrontEnd::try_new_swrast(), - FrontEndSelection::OpenGL => GuiFrontEnd::try_new(), - }; - - let front_end = front_end?; - +pub fn try_new() -> Result, Error> { + let front_end = GuiFrontEnd::try_new()?; FRONT_END.with(|f| *f.borrow_mut() = Some(Rc::clone(&front_end))); - Ok(front_end) } diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index 1698213bc..72606b68f 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -105,7 +105,7 @@ async fn async_run_ssh(opts: SshCommand) -> anyhow::Result<()> { Ok(()) } -fn run_ssh(config: config::ConfigHandle, opts: SshCommand) -> anyhow::Result<()> { +fn run_ssh(opts: SshCommand) -> anyhow::Result<()> { // Set up the mux with no default domain; there's a good chance that // we'll need to show authentication UI and we don't want its domain // to become the default domain. @@ -113,8 +113,7 @@ fn run_ssh(config: config::ConfigHandle, opts: SshCommand) -> anyhow::Result<()> Mux::set_mux(&mux); crate::update::load_last_release_info_and_set_banner(); - let front_end_selection = opts.front_end.unwrap_or(config.front_end); - let gui = crate::gui::try_new(front_end_selection)?; + let gui = crate::gui::try_new()?; // Keep the frontend alive until we've run through the ssh authentication // phase. This is passed into the thread and dropped when it is done. @@ -149,8 +148,7 @@ fn run_serial(config: config::ConfigHandle, opts: &SerialCommand) -> anyhow::Res Mux::set_mux(&mux); crate::update::load_last_release_info_and_set_banner(); - let front_end = opts.front_end.unwrap_or(config.front_end); - let gui = crate::gui::try_new(front_end)?; + let gui = crate::gui::try_new()?; block_on(domain.attach())?; // FIXME: blocking { @@ -195,8 +193,7 @@ fn run_mux_client(config: config::ConfigHandle, opts: &ConnectCommand) -> anyhow Mux::set_mux(&mux); crate::update::load_last_release_info_and_set_banner(); - let front_end_selection = opts.front_end.unwrap_or(config.front_end); - let gui = crate::gui::try_new(front_end_selection)?; + let gui = crate::gui::try_new()?; let opts = opts.clone(); let cmd = if !opts.prog.is_empty() { @@ -268,7 +265,7 @@ async fn async_run_terminal_gui( spawn_tab_in_default_domain_if_mux_is_empty(cmd).await } -fn run_terminal_gui(config: config::ConfigHandle, opts: StartCommand) -> anyhow::Result<()> { +fn run_terminal_gui(opts: StartCommand) -> anyhow::Result<()> { if let Some(cls) = opts.class.as_ref() { crate::gui::set_window_class(cls); } @@ -310,8 +307,7 @@ fn run_terminal_gui(config: config::ConfigHandle, opts: StartCommand) -> anyhow: Mux::set_mux(&mux); crate::update::load_last_release_info_and_set_banner(); - let front_end_selection = opts.front_end.unwrap_or(config.front_end); - let gui = crate::gui::try_new(front_end_selection)?; + let gui = crate::gui::try_new()?; let activity = Activity::new(); let do_auto_connect = !opts.no_auto_connect; @@ -462,9 +458,9 @@ fn run() -> anyhow::Result<()> { { SubCommand::Start(start) => { log::trace!("Using configuration: {:#?}\nopts: {:#?}", config, opts); - run_terminal_gui(config, start) + run_terminal_gui(start) } - SubCommand::Ssh(ssh) => run_ssh(config, ssh), + SubCommand::Ssh(ssh) => run_ssh(ssh), SubCommand::Serial(serial) => run_serial(config, &serial), SubCommand::Connect(connect) => run_mux_client(config, &connect), } diff --git a/wezterm-gui/src/window_config.rs b/wezterm-gui/src/window_config.rs index 40453c1d6..1ffc34ac9 100644 --- a/wezterm-gui/src/window_config.rs +++ b/wezterm-gui/src/window_config.rs @@ -28,6 +28,19 @@ impl WindowConfiguration for ConfigBridge { configuration().prefer_egl } + fn prefer_swrast(&self) -> bool { + #[cfg(windows)] + { + if is_running_in_rdp_session() { + // Using OpenGL in RDP has problematic behavior upon + // disconnect, so we force the use of software rendering. + log::trace!("Running in an RDP session, use SWRAST"); + return true; + } + } + configuration().front_end == config::FrontEndSelection::Software + } + fn native_macos_fullscreen_mode(&self) -> bool { configuration().native_macos_fullscreen_mode } diff --git a/window/src/configuration.rs b/window/src/configuration.rs index 42cf47eb8..3078ebc78 100644 --- a/window/src/configuration.rs +++ b/window/src/configuration.rs @@ -27,6 +27,10 @@ pub trait WindowConfiguration { true } + fn prefer_swrast(&self) -> bool { + false + } + fn native_macos_fullscreen_mode(&self) -> bool { false } diff --git a/window/src/egl.rs b/window/src/egl.rs index 53c200f91..68e83293e 100644 --- a/window/src/egl.rs +++ b/window/src/egl.rs @@ -1,4 +1,3 @@ -use crate::{is_swrast_preferred, prefer_swrast}; use anyhow::{anyhow, bail, ensure, Error}; use std::ffi::c_void; use std::rc::Rc; @@ -405,9 +404,10 @@ impl GlState { } let mut errors = vec![]; + let mut prefer_swrast = crate::configuration::config().prefer_swrast(); for _ in 0..2 { - if is_swrast_preferred() { + if prefer_swrast { // Assuming that we're using Mesa, set an environment // variable that should select CPU based rendering. std::env::set_var("LIBGL_ALWAYS_SOFTWARE", "true"); @@ -445,7 +445,10 @@ impl GlState { if cfg!(windows) { break; } - prefer_swrast(); + if prefer_swrast { + break; + } + prefer_swrast = true; } bail!("with_egl_lib failed: {}", errors.join(", ")) } diff --git a/window/src/lib.rs b/window/src/lib.rs index 8a9b29cfe..64b62c850 100644 --- a/window/src/lib.rs +++ b/window/src/lib.rs @@ -1,6 +1,5 @@ use promise::Future; use std::any::Any; -use std::sync::atomic::{AtomicBool, Ordering}; pub mod bitmaps; pub mod color; pub mod configuration; @@ -252,13 +251,3 @@ pub trait WindowOpsMut { fn config_did_change(&mut self) {} } - -static PREFER_SWRAST: AtomicBool = AtomicBool::new(false); - -pub fn prefer_swrast() { - PREFER_SWRAST.store(true, Ordering::Release); -} - -pub fn is_swrast_preferred() -> bool { - PREFER_SWRAST.load(Ordering::Acquire) -}