浏览代码

cocoadisplay: Fix oversized window getting an awkward offset

We currently do the centering based on the total screen size, not the screen size that macOS actually lets us use.

See #1312
rdb 3 年之前
父节点
当前提交
9cb60ccd93
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      panda/src/cocoadisplay/cocoaGraphicsWindow.mm

+ 10 - 1
panda/src/cocoadisplay/cocoaGraphicsWindow.mm

@@ -1015,10 +1015,19 @@ set_properties_now(WindowProperties &properties) {
     NSRect frame;
     NSRect container;
     if (_window != nil) {
-      frame = [_window contentRectForFrameRect:[_window frame]];
+      NSRect window_frame = [_window frame];
+      frame = [_window contentRectForFrameRect:window_frame];
       NSScreen *screen = [_window screen];
       nassertv(screen != nil);
       container = [screen frame];
+
+      // Prevent the centering from overlapping the Dock
+      if (y < 0) {
+        NSRect visible_frame = [screen visibleFrame];
+        if (window_frame.size.height == visible_frame.size.height) {
+          y = 0;
+        }
+      }
     } else {
       frame = [_view frame];
       container = [[_view superview] frame];