File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -26,16 +26,26 @@ struct NSRectExt {
2626
2727// NSPoint extension-like helper for coordinate system conversion
2828struct NSPointExt {
29+ // Convert bottom-left point to top-left point
2930 static CGPoint topLeft (NSPoint point) {
3031 NSRect primaryScreenFrame = [[NSScreen screens ][0 ] frame ];
3132 return CGPointMake (point.x , primaryScreenFrame.size .height - point.y );
3233 }
3334
34- // Convert from top-left coordinate system to bottom-left (macOS default)
35+ // Convert top-left point to bottom-left point
36+ // Note: For window positions, use bottomLeftForWindow instead, as it requires window height
3537 static NSPoint bottomLeft (CGPoint topLeftPoint) {
3638 NSRect primaryScreenFrame = [[NSScreen screens ][0 ] frame ];
3739 return NSMakePoint (topLeftPoint.x , primaryScreenFrame.size .height - topLeftPoint.y );
3840 }
41+
42+ // Convert top-left window position to bottom-left window position
43+ // This is the correct method for converting window positions, as it accounts for window height
44+ static NSPoint bottomLeftForWindow (CGPoint topLeftPoint, CGFloat windowHeight) {
45+ NSRect primaryScreenFrame = [[NSScreen screens ][0 ] frame ];
46+ double bottomY = primaryScreenFrame.size .height - topLeftPoint.y - windowHeight;
47+ return NSMakePoint (topLeftPoint.x , bottomY);
48+ }
3949};
4050
4151} // namespace nativeapi
Original file line number Diff line number Diff line change 280280
281281void Window::SetPosition (Point point) {
282282 // Convert from topLeft coordinate system to bottom-left (macOS default)
283- NSPoint topLeftPoint = {point.x , point.y };
284- NSPoint bottomLeft = NSPointExt::bottomLeft (topLeftPoint);
283+ // We need the window height to correctly convert the top-left position
284+ NSRect frame = [pimpl_->ns_window_ frame ];
285+ CGPoint topLeftPoint = {point.x , point.y };
286+ NSPoint bottomLeft = NSPointExt::bottomLeftForWindow (topLeftPoint, frame.size .height );
285287 [pimpl_->ns_window_ setFrameOrigin: bottomLeft];
286288}
287289
You can’t perform that action at this time.
0 commit comments