diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index 6b8a15951..0514f99e8 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -21,12 +21,12 @@ fn main() -> wry::Result<()> { let mut webviews = HashMap::new(); let proxy = event_loop.create_proxy(); - let new_window = create_new_window( + let (window, webview) = create_new_window( format!("Window {}", webviews.len() + 1), &event_loop, proxy.clone(), ); - webviews.insert(new_window.0.id(), (new_window.0, new_window.1)); + webviews.insert(window.id(), (window, webview)); event_loop.run(move |event, event_loop, control_flow| { *control_flow = ControlFlow::Wait; @@ -43,12 +43,12 @@ fn main() -> wry::Result<()> { } } Event::UserEvent(UserEvent::NewWindow) => { - let new_window = create_new_window( + let (window, webview) = create_new_window( format!("Window {}", webviews.len() + 1), event_loop, proxy.clone(), ); - webviews.insert(new_window.0.id(), (new_window.0, new_window.1)); + webviews.insert(window.id(), (window, webview)); } Event::UserEvent(UserEvent::CloseWindow(id)) => { webviews.remove(&id); diff --git a/src/android/main_pipe.rs b/src/android/main_pipe.rs index 3b8e93d55..21fe8668c 100644 --- a/src/android/main_pipe.rs +++ b/src/android/main_pipe.rs @@ -74,11 +74,11 @@ impl<'a> MainPipe<'a> { string_class, self.env.new_string("")?, )?; - for (i, script) in initialization_scripts.into_iter().enumerate() { + for (i, (script, _)) in initialization_scripts.into_iter().enumerate() { self.env.set_object_array_element( &initialization_scripts_array, i as i32, - self.env.new_string(script.0)?, + self.env.new_string(script)?, )?; } diff --git a/src/android/mod.rs b/src/android/mod.rs index e284f389b..92986953a 100644 --- a/src/android/mod.rs +++ b/src/android/mod.rs @@ -232,13 +232,13 @@ impl InnerWebView { UnsafeRequestHandler::new(Box::new( move |webview_id: &str, mut request, is_document_start_script_enabled| { let uri = request.uri().to_string(); - if let Some(custom_protocol) = custom_protocols.iter().find(|(name, _)| { + if let Some((custom_protocol_uri, custom_protocol_closure)) = custom_protocols.iter().find(|(name, _)| { uri.starts_with(&format!("{scheme}://{}.", name)) }) { let uri_res = uri .replace( - &format!("{scheme}://{}.", custom_protocol.0), - &format!("{}://", custom_protocol.0), + &format!("{scheme}://{}.", custom_protocol_uri), + &format!("{}://", custom_protocol_uri), ) .parse(); @@ -273,15 +273,15 @@ impl InnerWebView { let mut hashes = Vec::new(); with_html_head(&mut document, |head| { // iterate in reverse order since we are prepending each script to the head tag - for script in initialization_scripts.iter().rev() { + for (script, _) in initialization_scripts.iter().rev() { let script_el = NodeRef::new_element( QualName::new(None, ns!(html), "script".into()), None, ); - script_el.append(NodeRef::new_text(script.0.as_str())); + script_el.append(NodeRef::new_text(script.as_str())); head.prepend(script_el); if csp.is_some() { - hashes.push(hash_script(script.0.as_str())); + hashes.push(hash_script(script.as_str())); } } }); @@ -304,7 +304,7 @@ impl InnerWebView { tx.send(response).unwrap(); }); - (custom_protocol.1)(webview_id, request, RequestAsyncResponder { responder }); + (custom_protocol_closure)(webview_id, request, RequestAsyncResponder { responder }); return Some(rx.recv_timeout(MAIN_PIPE_TIMEOUT).unwrap()); } None diff --git a/src/webkitgtk/mod.rs b/src/webkitgtk/mod.rs index 2c04bf7f4..1c6ccd393 100644 --- a/src/webkitgtk/mod.rs +++ b/src/webkitgtk/mod.rs @@ -254,12 +254,9 @@ impl InnerWebView { webview.set_background_color(>k::gdk::RGBA::new(0., 0., 0., 0.)); } else { // background color - if let Some(background_color) = attributes.background_color { + if let Some((red, green, blue, alpha)) = attributes.background_color { webview.set_background_color(>k::gdk::RGBA::new( - background_color.0 as _, - background_color.1 as _, - background_color.2 as _, - background_color.3 as _, + red as _, green as _, blue as _, alpha as _, )); } } @@ -660,12 +657,9 @@ impl InnerWebView { Ok(()) } - pub fn set_background_color(&self, background_color: RGBA) -> Result<()> { + pub fn set_background_color(&self, (red, green, blue, alpha): RGBA) -> Result<()> { self.webview.set_background_color(>k::gdk::RGBA::new( - background_color.0 as _, - background_color.1 as _, - background_color.2 as _, - background_color.3 as _, + red as _, green as _, blue as _, alpha as _, )); Ok(()) } diff --git a/src/webview2/mod.rs b/src/webview2/mod.rs index 05c79b2c7..bb2bfd540 100644 --- a/src/webview2/mod.rs +++ b/src/webview2/mod.rs @@ -1667,19 +1667,14 @@ unsafe fn set_background_color( controller: &ICoreWebView2Controller, background_color: RGBA, ) -> Result<()> { - let mut color = background_color; - if is_windows_7() || color.3 != 0 { - color.3 = 255; + let (R, G, B, mut A) = background_color; + if is_windows_7() || A != 0 { + A = 255; } let controller2: ICoreWebView2Controller2 = controller.cast()?; controller2 - .SetDefaultBackgroundColor(COREWEBVIEW2_COLOR { - R: color.0, - G: color.1, - B: color.2, - A: color.3, - }) + .SetDefaultBackgroundColor(COREWEBVIEW2_COLOR { R, G, B, A }) .map_err(Into::into) } diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 147db93ad..afa4f0aeb 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -192,11 +192,11 @@ impl InnerWebView { let config = WKWebViewConfiguration::new(); // Incognito mode - let os_version = util::operating_system_version(); + let (os_major_version, _, _) = util::operating_system_version(); #[cfg(target_os = "macos")] - let custom_data_store_available = os_version.0 >= 14; + let custom_data_store_available = os_major_version >= 14; #[cfg(target_os = "ios")] - let custom_data_store_available = os_version.0 >= 17; + let custom_data_store_available = os_major_version >= 17; let data_store = match ( attributes.incognito, @@ -521,7 +521,7 @@ r#"Object.defineProperty(window, 'ipc', { // make sure the window is always on top when we create a new webview let app = NSApplication::sharedApplication(mtm); - if os_version.0 >= 14 { + if os_major_version >= 14 { NSApplication::activate(&app); } else { #[allow(deprecated)]