From 9cb60ccd93c508e7d76f90de61413957548fc9d3 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 16 Dec 2022 16:07:58 +0100 Subject: [PATCH] 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 --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 4a001912ff..2063327f85 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/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];