Skip to content

Commit

Permalink
fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars committed Jan 6, 2025
1 parent e071395 commit 8f48145
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ objc2-ui-kit = { version = "0.2.2", features = [
[target."cfg(target_os = \"macos\")".dependencies]
objc2-app-kit = { version = "0.2.0", features = [
"NSApplication",
"NSButton",
"NSControl",
"NSEvent",
"NSWindow",
"NSView",
Expand Down
29 changes: 17 additions & 12 deletions src/wkwebview/class/wry_web_view_parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use objc2::{
declare_class, msg_send_id, mutability::MainThreadOnly, rc::Retained, ClassType, DeclaredClass,
};
#[cfg(target_os = "macos")]
use objc2_app_kit::{NSApplication, NSEvent, NSView};
use objc2_app_kit::{NSWindow, NSWindowButton};
use objc2_foundation::{MainThreadMarker, NSRect};
use objc2_app_kit::{NSApplication, NSEvent, NSView, NSWindow, NSWindowButton};
use objc2_foundation::MainThreadMarker;
#[cfg(target_os = "macos")]
use objc2_foundation::NSRect;
#[cfg(target_os = "ios")]
use objc2_ui_kit::UIView as NSView;

Expand Down Expand Up @@ -69,19 +70,23 @@ impl WryWebViewParent {
}

pub fn set_traffic_light_inset(&self, ns_window: &NSWindow, position: dpi::Position) {
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);
#[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);
}
}
}
}

#[cfg(target_os = "macos")]
pub unsafe fn inset_traffic_lights(window: &NSWindow, x: f64, y: f64) {
let close = window
.standardWindowButton(NSWindowButton::NSWindowCloseButton)
Expand Down

0 comments on commit 8f48145

Please sign in to comment.