Fixed strange y results from faulty conversion to screen coordinates
co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
db2aaa4367
commit
87cf8ac60e
2 changed files with 7 additions and 4 deletions
|
@ -14,12 +14,12 @@ use pathfinder_geometry::{
|
||||||
|
|
||||||
pub trait Vector2FExt {
|
pub trait Vector2FExt {
|
||||||
/// Converts self to an NSPoint with y axis pointing up.
|
/// Converts self to an NSPoint with y axis pointing up.
|
||||||
fn to_screen_ns_point(&self, native_window: id) -> NSPoint;
|
fn to_screen_ns_point(&self, native_window: id, window_height: f64) -> NSPoint;
|
||||||
}
|
}
|
||||||
impl Vector2FExt for Vector2F {
|
impl Vector2FExt for Vector2F {
|
||||||
fn to_screen_ns_point(&self, native_window: id) -> NSPoint {
|
fn to_screen_ns_point(&self, native_window: id, window_height: f64) -> NSPoint {
|
||||||
unsafe {
|
unsafe {
|
||||||
let point = NSPoint::new(self.x() as f64, self.y() as f64);
|
let point = NSPoint::new(self.x() as f64, window_height - self.y() as f64);
|
||||||
msg_send![native_window, convertPointToScreen: point]
|
msg_send![native_window, convertPointToScreen: point]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -832,7 +832,10 @@ impl platform::Window for Window {
|
||||||
let app = NSApplication::sharedApplication(nil);
|
let app = NSApplication::sharedApplication(nil);
|
||||||
|
|
||||||
// Convert back to screen coordinates
|
// Convert back to screen coordinates
|
||||||
let screen_point = position.to_screen_ns_point(self_borrow.native_window);
|
let screen_point = position.to_screen_ns_point(
|
||||||
|
self_borrow.native_window,
|
||||||
|
self_borrow.content_size().y() as f64,
|
||||||
|
);
|
||||||
|
|
||||||
let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:screen_point belowWindowWithWindowNumber:0];
|
let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:screen_point belowWindowWithWindowNumber:0];
|
||||||
let top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];
|
let top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue