@ -24,6 +24,8 @@ pub struct CmdLineSettings {
pub x11_wm_class : String ,
pub x11_wm_class : String ,
// Disable open multiple files as tabs
// Disable open multiple files as tabs
pub no_tabs : bool ,
pub no_tabs : bool ,
// Replicate macOS behaviour where first click is not registered
pub click_through : bool ,
}
}
impl Default for CmdLineSettings {
impl Default for CmdLineSettings {
@ -43,6 +45,7 @@ impl Default for CmdLineSettings {
multi_grid : false ,
multi_grid : false ,
no_idle : false ,
no_idle : false ,
srgb : true ,
srgb : true ,
click_through : false ,
// Command-line arguments with environment variable fallback
// Command-line arguments with environment variable fallback
neovim_bin : None ,
neovim_bin : None ,
wayland_app_id : String ::new ( ) ,
wayland_app_id : String ::new ( ) ,
@ -105,6 +108,11 @@ pub fn handle_command_line_arguments(args: Vec<String>) -> Result<(), String> {
. long ( "wsl" )
. long ( "wsl" )
. help ( "Run in WSL" )
. help ( "Run in WSL" )
)
)
. arg (
Arg ::new ( "click_through" )
. long ( "click-through" )
. help ( "On first mouse click, move the cursor to location of mouse click. DISCLAIMER: Providing this flag on non-macOS systems will not change anything" )
)
// Command-line flags with environment variable fallback
// Command-line flags with environment variable fallback
. arg (
. arg (
Arg ::new ( "frame" )
Arg ::new ( "frame" )
@ -186,6 +194,10 @@ pub fn handle_command_line_arguments(args: Vec<String>) -> Result<(), String> {
no_fork : matches . is_present ( "nofork" ) ,
no_fork : matches . is_present ( "nofork" ) ,
remote_tcp : matches . value_of ( "remote_tcp" ) . map ( | i | i . to_owned ( ) ) ,
remote_tcp : matches . value_of ( "remote_tcp" ) . map ( | i | i . to_owned ( ) ) ,
wsl : matches . is_present ( "wsl" ) ,
wsl : matches . is_present ( "wsl" ) ,
#[ cfg(target_os = " macos " ) ]
click_through : matches . is_present ( "click_through" ) ,
#[ cfg(not(target_os = " macos " )) ]
click_through : true ,
// Command-line flags with environment variable fallback
// Command-line flags with environment variable fallback
frame : match matches . value_of ( "frame" ) {
frame : match matches . value_of ( "frame" ) {
Some ( val ) = > Frame ::from_string ( val . to_string ( ) ) ,
Some ( val ) = > Frame ::from_string ( val . to_string ( ) ) ,
@ -197,7 +209,7 @@ pub fn handle_command_line_arguments(args: Vec<String>) -> Result<(), String> {
maximized : matches . is_present ( "maximized" ) | | std ::env ::var ( "NEOVIDE_MAXIMIZED" ) . is_ok ( ) ,
maximized : matches . is_present ( "maximized" ) | | std ::env ::var ( "NEOVIDE_MAXIMIZED" ) . is_ok ( ) ,
multi_grid : matches . is_present ( "multi_grid" ) | | std ::env ::var ( "NEOVIDE_MULTIGRID" ) . is_ok ( ) ,
multi_grid : matches . is_present ( "multi_grid" ) | | std ::env ::var ( "NEOVIDE_MULTIGRID" ) . is_ok ( ) ,
no_idle : matches . is_present ( "noidle" ) | | std ::env ::var ( "NEOVIDE_NO_IDLE" ) . is_ok ( ) ,
no_idle : matches . is_present ( "noidle" ) | | std ::env ::var ( "NEOVIDE_NO_IDLE" ) . is_ok ( ) ,
// Srgb is enabled by default, so set it to false if nosrgb or N O EVIDE_NO_SRGB is set
// Srgb is enabled by default, so set it to false if nosrgb or N EO VIDE_NO_SRGB is set
srgb : ! ( matches . is_present ( "nosrgb" ) | | std ::env ::var ( "NEOVIDE_NO_SRGB" ) . is_ok ( ) ) ,
srgb : ! ( matches . is_present ( "nosrgb" ) | | std ::env ::var ( "NEOVIDE_NO_SRGB" ) . is_ok ( ) ) ,
// Command-line arguments with environment variable fallback
// Command-line arguments with environment variable fallback
neovim_bin : matches
neovim_bin : matches
@ -345,6 +357,18 @@ mod tests {
assert! ( SETTINGS . get ::< CmdLineSettings > ( ) . log_to_file ) ;
assert! ( SETTINGS . get ::< CmdLineSettings > ( ) . log_to_file ) ;
}
}
#[ test ]
fn test_click_through ( ) {
let args : Vec < String > = vec! [ "neovide" , "--click-through" ]
. iter ( )
. map ( | s | s . to_string ( ) )
. collect ( ) ;
let _accessing_settings = ACCESSING_SETTINGS . lock ( ) . unwrap ( ) ;
handle_command_line_arguments ( args ) . expect ( "Could not parse arguments" ) ;
assert! ( SETTINGS . get ::< CmdLineSettings > ( ) . click_through )
}
#[ test ]
#[ test ]
fn test_frameless_flag ( ) {
fn test_frameless_flag ( ) {
let args : Vec < String > = vec! [ "neovide" , "--frame=full" ]
let args : Vec < String > = vec! [ "neovide" , "--frame=full" ]