diff --git a/src/config.rs b/src/config.rs index 696d38d..cfdcb05 100644 --- a/src/config.rs +++ b/src/config.rs @@ -41,6 +41,8 @@ pub struct CliArgs { pub resource_dir: Option, /// Override the user agent pub user_agent: Option, + /// Initial window's zoom level + pub zoom_level: Option, } /// Configuration of Verso instance. @@ -130,6 +132,8 @@ fn parse_cli_args() -> Result { "Launch the initial window without maximized", ); + opts.optopt("", "zoom", "Initial window's zoom level", "1.5"); + let matches: getopts::Matches = opts.parse(&args[1..])?; let url = matches .opt_str("url") @@ -219,6 +223,11 @@ fn parse_cli_args() -> Result { window_attributes = window_attributes.with_maximized(true); } + let zoom_level = matches.opt_get::("zoom").unwrap_or_else(|e| { + log::error!("Failed to parse zoom command line argument: {e}"); + None + }); + Ok(CliArgs { url, resource_dir, @@ -228,6 +237,7 @@ fn parse_cli_args() -> Result { devtools_port, profiler_settings, user_agent, + zoom_level, }) } diff --git a/src/verso.rs b/src/verso.rs index 1b4b02c..75e5cb9 100644 --- a/src/verso.rs +++ b/src/verso.rs @@ -114,6 +114,7 @@ impl Verso { .clone() .unwrap_or_else(|| default_user_agent_string().to_string()) .into(); + let zoom_level = config.args.zoom_level; config.init(); // Reserving a namespace to create TopLevelBrowsingContextId. @@ -360,7 +361,7 @@ impl Verso { // The compositor coordinates with the client window to create the final // rendered page and display it somewhere. - let compositor = IOCompositor::new( + let mut compositor = IOCompositor::new( window.id(), window.size(), Scale::new(window.scale_factor() as f32), @@ -380,6 +381,10 @@ impl Verso { opts.debug.convert_mouse_to_touch, ); + if let Some(zoom_level) = zoom_level { + compositor.on_zoom_window_event(zoom_level, &window); + } + if with_panel { window.create_panel(&constellation_sender, initial_url); } else if let Some(initial_url) = initial_url {