It looks like wry/tao/winit automatically scales the content?

This commit is contained in:
Tim-Paik 2022-05-08 14:10:52 +08:00
parent 5727f6b96f
commit 7d0dfe5d6f
Signed by: Tim-Paik
GPG Key ID: DC36A050DB42566D
2 changed files with 4 additions and 10 deletions

View File

@ -57,14 +57,12 @@ pub fn dev(config_path: String) -> wry::Result<()> {
)?)), )?)),
None => window_builder, None => window_builder,
}; };
let monitor = event_loop.primary_monitor().unwrap_or_else(|| { let monitor_size = event_loop.primary_monitor().unwrap_or_else(|| {
event_loop event_loop
.available_monitors() .available_monitors()
.next() .next()
.expect("no monitor found") .expect("no monitor found")
}); }).size();
let monitor_size = monitor.size();
let monitor_scale_factor = monitor.scale_factor();
let window_builder = match config.window_attr()?.inner_size { let window_builder = match config.window_attr()?.inner_size {
Some(size) => window_builder.with_inner_size(get_size(size, monitor_size)), Some(size) => window_builder.with_inner_size(get_size(size, monitor_size)),
None => window_builder, None => window_builder,
@ -178,7 +176,6 @@ pub fn dev(config_path: String) -> wry::Result<()> {
}) })
.with_devtools(true) .with_devtools(true)
.build()?; .build()?;
webview.zoom(monitor_scale_factor);
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;

View File

@ -58,14 +58,12 @@ fn main() -> wry::Result<()> {
)?)), )?)),
None => window_builder, None => window_builder,
}; };
let monitor = event_loop.primary_monitor().unwrap_or_else(|| { let monitor_size = event_loop.primary_monitor().unwrap_or_else(|| {
event_loop event_loop
.available_monitors() .available_monitors()
.next() .next()
.expect("no monitor found") .expect("no monitor found")
}); }).size();
let monitor_size = monitor.size();
let monitor_scale_factor = monitor.scale_factor();
let window_builder = match res.window_attr.inner_size { let window_builder = match res.window_attr.inner_size {
Some(size) => window_builder.with_inner_size(get_size(size, monitor_size)), Some(size) => window_builder.with_inner_size(get_size(size, monitor_size)),
None => window_builder, None => window_builder,
@ -169,7 +167,6 @@ fn main() -> wry::Result<()> {
}) })
.with_devtools(false) .with_devtools(false)
.build()?; .build()?;
webview.zoom(monitor_scale_factor);
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;