Repository: tauri-apps/tauri
File: core/tauri-runtime-wry/src/lib.rs (Rust)

Code before:
    window_wrapper.inner = None;
  }
}

pub fn center_window(window: &Window, window_size: TaoPhysicalSize<u32>) -> Result<()> {
  if let Some(monitor) = window.current_monitor() {
    let screen_size = monitor.size();
    let monitor_pos = monitor.position();
    let x = (screen_size.width as i32 - window_size.width as i32) / 2;
    let y = (screen_size.height as i32 - window_size.height as i32) / 2;
    window.set_outer_position(TaoPhysicalPosition::new(
      monitor_pos.x + x,
      monitor_pos.y + y,
    ));
    Ok(())
  } else {
    Err(Error::FailedToGetMonitor)
  }
}

fn parse_proxy(url: &str) -> Result<ProxyConfig> {
  let proxy = Url::parse(url).unwrap();

  if proxy.scheme() == "http" && proxy.path() == "" {
    let host = proxy.host().unwrap();
    let port = proxy.port().unwrap();
    let config = ProxyConfig::Http(ProxyEndpoint {
      host: host.to_string(),
      port: port.to_string(),
    });

    Ok(config)
  } else if proxy.scheme() == "socks5" && proxy.path() == "" {
    let host = proxy.host().unwrap();
    let port = proxy.port().unwrap();
    let config = ProxyConfig::Socks5(ProxyEndpoint {
      host: host.to_string(),
      port: port.to_string(),
    });

    Ok(config)
  } else {
    Err(Error::InvalidProxyUrl)
  }
}

fn create_webview<T: UserEvent, F: Fn(RawWindow) + Send + 'static>(
  window_id: WebviewId,
  event_loop: &EventLoopWindowTarget<Message<T>>,
  web_context_store: &WebContextStore,
  context: Context<T>,

Review comment (suggestion):
```suggestion
    let host = proxy.host().unwrap_or_default();
    let port = proxy.port().unwrap_or_default();
```

Code after:
            if let Some(b) = &webview.bounds {
              let window_size = window.inner_size();
              let mut bounds = b.lock().unwrap();
              bounds.width_rate = size.width as f32 / window_size.width as f32;
              bounds.height_rate = size.height as f32 / window_size.height as f32;
            }

            webview.set_bounds(bounds);
          }
          WebviewMessage::SetPosition(position) => {
            let mut bounds = webview.bounds();
            let position = position.to_logical(window.scale_factor());
            bounds.x = position.x;
            bounds.y = position.y;

            if let Some(b) = &webview.bounds {
              let window_size = window.inner_size();
              let mut bounds = b.lock().unwrap();
              bounds.width_rate = position.x as f32 / window_size.width as f32;
              bounds.height_rate = position.y as f32 / window_size.height as f32;
            }

            webview.set_bounds(bounds);
          }
          WebviewMessage::SetFocus => {
            webview.focus();
          }
          WebviewMessage::WebviewEvent(_event) => { /* already handled */ }
          WebviewMessage::WithWebview(f) => {
            #[cfg(any(
              target_os = "linux",
              target_os = "dragonfly",
              target_os = "freebsd",
              target_os = "netbsd",
              target_os = "openbsd"
            ))]
            {
              f(webview.webview());
            }
            #[cfg(target_os = "macos")]
            {
              use wry::WebViewExtMacOS;
              f(Webview {
                webview: webview.webview(),
                manager: webview.manager(),
                ns_window: webview.ns_window(),
              });
            }
            #[cfg(target_os = "ios")]
            {
              use tao::platform::ios::WindowExtIOS;