Skip to content

Commit

Permalink
ios
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars committed Jan 6, 2025
1 parent 8f48145 commit b711f02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
22 changes: 10 additions & 12 deletions src/wkwebview/class/wry_web_view_parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,17 @@ impl WryWebViewParent {
unsafe { msg_send_id![super(delegate), init] }
}

#[cfg(target_os = "macos")]
pub fn set_traffic_light_inset(&self, ns_window: &NSWindow, position: dpi::Position) {
#[cfg(target_os = "macos")]
{
let scale_factor = NSWindow::backingScaleFactor(ns_window);
let position = position.to_logical(scale_factor);
self
.ivars()
.traffic_light_inset
.replace(Some((position.x, position.y)));

unsafe {
inset_traffic_lights(ns_window, position.x, position.y);
}
let scale_factor = NSWindow::backingScaleFactor(ns_window);
let position = position.to_logical(scale_factor);
self
.ivars()
.traffic_light_inset
.replace(Some((position.x, position.y)));

unsafe {
inset_traffic_lights(ns_window, position.x, position.y);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/wkwebview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub(crate) struct InnerWebView {
// We need this the keep the reference count
ui_delegate: Retained<WryWebViewUIDelegate>,
protocol_ptrs: Vec<*mut Box<dyn Fn(crate::WebViewId, Request<Vec<u8>>, RequestAsyncResponder)>>,
#[cfg(target_os = "macos")]
// We need this to update the traffic light inset
parent_view: Option<Retained<WryWebViewParent>>,
}
Expand Down Expand Up @@ -941,12 +942,10 @@ r#"Object.defineProperty(window, 'ipc', {
Ok(())
}

#[cfg(target_os = "macos")]
pub(crate) fn set_traffic_light_inset(&self, position: dpi::Position) -> crate::Result<()> {
#[cfg(target_os = "macos")]
if !self.is_child {
if let Some(parent_view) = &self.parent_view {
parent_view.set_traffic_light_inset(&self.webview.window().unwrap(), position);
}
if let Some(parent_view) = &self.parent_view {
parent_view.set_traffic_light_inset(&self.webview.window().unwrap(), position);
}

Ok(())
Expand Down

0 comments on commit b711f02

Please sign in to comment.