From c23c176c00a6571906d0a0b2d9ad27cadafc4a81 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Wed, 8 Sep 2021 13:26:35 -0700 Subject: [PATCH] add srgb setting, commandline arg, and environment variable to fix amd windows machines --- .gitignore | 1 + src/cmd_line.rs | 40 +++++++++++++++++++++++--------- src/main.rs | 2 +- src/window/settings.rs | 5 +--- src/window/window_wrapper/mod.rs | 7 +++--- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 0920fd8..e24e352 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target +/.vs **/*.rs.bk *.log .DS_Store diff --git a/src/cmd_line.rs b/src/cmd_line.rs index 38a99f2..cc94a23 100644 --- a/src/cmd_line.rs +++ b/src/cmd_line.rs @@ -11,7 +11,9 @@ pub struct CmdLineSettings { pub neovim_bin: Option, pub files_to_open: Vec, - pub nofork: bool, + pub no_fork: bool, + pub no_idle: bool, + pub srgb: bool, pub geometry: Dimensions, pub wsl: bool, pub remote_tcp: Option, @@ -25,12 +27,15 @@ pub struct CmdLineSettings { impl Default for CmdLineSettings { fn default() -> Self { Self { - neovim_bin: None, verbosity: 0, log_to_file: false, + neovim_bin: None, neovim_args: vec![], files_to_open: vec![], - nofork: false, + + no_fork: false, + no_idle: false, + srgb: true, geometry: DEFAULT_WINDOW_GEOMETRY, wsl: false, remote_tcp: None, @@ -64,6 +69,16 @@ pub fn handle_command_line_arguments() -> Result<(), String> { .long("nofork") .help("Do not detach process from terminal"), ) + .arg( + Arg::with_name("noidle") + .long("noidle") + .help("Render every frame. Takes more power and cpu time but possibly fixes animation issues"), + ) + .arg( + Arg::with_name("srgb") + .long("srgb") + .help("Use standard color space to initialize the window. Swapping this variable sometimes fixes issues on startup"), + ) .arg( Arg::with_name("maximized") .long("maximized") @@ -129,24 +144,27 @@ pub fn handle_command_line_arguments() -> Result<(), String> { * NEOVIDE_MULTIGRID || --multigrid */ SETTINGS.set::(&CmdLineSettings { - neovim_bin: std::env::var("NEOVIM_BIN").ok(), + verbosity: matches.occurrences_of("verbosity"), + log_to_file: matches.is_present("log_to_file"), neovim_args: matches .values_of("neovim_args") .map(|opt| opt.map(|v| v.to_owned()).collect()) .unwrap_or_default(), - verbosity: matches.occurrences_of("verbosity"), - log_to_file: matches.is_present("log_to_file"), + neovim_bin: std::env::var("NEOVIM_BIN").ok(), files_to_open: matches .values_of("files") .map(|opt| opt.map(|v| v.to_owned()).collect()) .unwrap_or_default(), - maximized: matches.is_present("maximized") || std::env::var("NEOVIDE_MAXIMIZED").is_ok(), - multi_grid: std::env::var("NEOVIDE_MULTIGRID").is_ok() || matches.is_present("multi_grid"), - remote_tcp: matches.value_of("remote_tcp").map(|i| i.to_owned()), - nofork: matches.is_present("nofork") || matches.is_present("verbosity"), + + no_fork: matches.is_present("nofork") || matches.is_present("verbosity"), + no_idle: matches.is_present("noidle") || std::env::var("NEOVIDE_NOIDLE").is_ok(), + srgb: matches.is_present("srgb") || !std::env::var("NEOVIDE_NO_SRGB").is_ok(), + geometry: parse_window_geometry(matches.value_of("geometry").map(|i| i.to_owned()))?, wsl: matches.is_present("wsl"), + remote_tcp: matches.value_of("remote_tcp").map(|i| i.to_owned()), + multi_grid: std::env::var("NEOVIDE_MULTIGRID").is_ok() || matches.is_present("multi_grid"), + maximized: matches.is_present("maximized") || std::env::var("NEOVIDE_MAXIMIZED").is_ok(), frameless: matches.is_present("frameless") || std::env::var("NEOVIDE_FRAMELESS").is_ok(), - geometry: parse_window_geometry(matches.value_of("geometry").map(|i| i.to_owned()))?, wayland_app_id: match std::env::var("NEOVIDE_APP_ID") { Ok(val) => val, Err(_) => matches diff --git a/src/main.rs b/src/main.rs index 9870f50..dce2e0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,7 +205,7 @@ fn maybe_disown() { let settings = SETTINGS.get::(); - if cfg!(debug_assertions) || settings.nofork { + if cfg!(debug_assertions) || settings.no_fork { return; } diff --git a/src/window/settings.rs b/src/window/settings.rs index 52c5452..87748fd 100644 --- a/src/window/settings.rs +++ b/src/window/settings.rs @@ -17,10 +17,7 @@ impl Default for WindowSettings { fullscreen: false, iso_layout: false, refresh_rate: 60, - no_idle: SETTINGS - .get::() - .neovim_args - .contains(&String::from("--noIdle")), + no_idle: SETTINGS.get::().no_idle, remember_window_size: false, } } diff --git a/src/window/window_wrapper/mod.rs b/src/window/window_wrapper/mod.rs index cf0ba99..c7ea3db 100644 --- a/src/window/window_wrapper/mod.rs +++ b/src/window/window_wrapper/mod.rs @@ -243,11 +243,12 @@ pub fn create_window( let event_loop = EventLoop::new(); + let cmd_line_settings = SETTINGS.get::(); let winit_window_builder = window::WindowBuilder::new() .with_title("Neovide") .with_window_icon(Some(icon)) - .with_maximized(SETTINGS.get::().maximized) - .with_decorations(!SETTINGS.get::().frameless); + .with_maximized(cmd_line_settings.maximized) + .with_decorations(!cmd_line_settings.frameless); #[cfg(target_os = "linux")] let winit_window_builder = winit_window_builder @@ -262,7 +263,7 @@ pub fn create_window( .with_stencil_buffer(8) .with_gl_profile(GlProfile::Core) .with_vsync(false) - .with_srgb(false) + .with_srgb(cmd_line_settings.srgb) .build_windowed(winit_window_builder, &event_loop) .unwrap(); let windowed_context = unsafe { windowed_context.make_current().unwrap() };