Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions platforms/macos/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ impl Adapter {
let window = view.window().unwrap();
let point = window.convert_point_from_screen(point);
let point = view.convert_point_from_view(point, None);
let view_bounds = view.bounds();
let point = Point::new(point.x, view_bounds.size.height - point.y);
let point = Point::new(
point.x,
if view.is_flipped() {
point.y
} else {
let view_bounds = view.bounds();
view_bounds.size.height - point.y
},
);

let state = context.tree.read();
let root = state.root();
Expand Down
3 changes: 3 additions & 0 deletions platforms/macos/src/appkit/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ extern_methods!(
point: NSPoint,
view: Option<&NSView>,
) -> NSPoint;

#[sel(isFlipped)]
pub(crate) fn is_flipped(&self) -> bool;
}
);
8 changes: 6 additions & 2 deletions platforms/macos/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,15 @@ declare_class!(
};

node.bounding_box().map_or(NSRect::ZERO, |rect| {
let view_bounds = view.bounds();
let rect = NSRect {
origin: NSPoint {
x: rect.x0,
y: view_bounds.size.height - rect.y1,
y: if view.is_flipped() {
rect.y0
} else {
let view_bounds = view.bounds();
view_bounds.size.height - rect.y1
},
},
size: NSSize {
width: rect.width(),
Expand Down