summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Thomases <ken@codeweavers.com>2015-10-12 16:45:41 -0700
committerJeremy Huddleston Sequoia <jeremyhu@apple.com>2015-10-13 14:19:05 -0700
commit4513f924a7065edbd267cf96837af94ce5a58a6f (patch)
tree8fa0f5e313ae496173af5d79a3c11e9eaf81c50b
parent6e6827aac33eddeacfb37ef3d7b0397b1446bf66 (diff)
XQuartz: Fix how we calculate the height of the OSX menu bar
+[NSScreen mainScreen] does not mean the primary display. It used to mean the one with the key window. When "Displays have separate spaces" is enabled, it means the active screen, the one whose menu bar is mostly opaque. As such, it may not be the screen whose lower-left corner is located at (0, 0). That's why its max-Y is not necessarily comparable to its height. That only works for the primary display. This code could use [[NSScreen screens] firstObject]. This is always the primary display, the one whose lower-left corner is at (0, 0). Once that's done, the above change should be reverted. The height of the visible frame would be the full height of the screen minus the menu bar _and the Dock_ if the Dock is along the bottom of the screen. Actually, there's a theoretically-simpler approach: use -[NSMenu menuBarHeight]. That replaces a long-deprecated method +[NSMenuView menuBarHeight]. However, there was a bug in Tiger that led to the former not working while the latter still worked. I haven't actually checked recently. CrossOver's still-kicking X server code uses this code, which tries all of the above: NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; aquaMenuBarHeight = [[NSApp mainMenu] menuBarHeight]; if (!aquaMenuBarHeight) aquaMenuBarHeight = [NSMenuView menuBarHeight]; if (!aquaMenuBarHeight) aquaMenuBarHeight = NSHeight([primaryScreen frame]) - NSMaxY([primaryScreen visibleFrame]); Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Signed-off-by: Ken Thomases <ken@codeweavers.com>
-rw-r--r--hw/xquartz/X11Application.m12
1 files changed, 10 insertions, 2 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8a928baac..d2c5d3083 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1238,8 +1238,16 @@ X11ApplicationMain(int argc, char **argv, char **envp)
QuartzModeBundleInit();
/* Calculate the height of the menubar so we can avoid it. */
- aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
- NSMaxY([[NSScreen mainScreen] visibleFrame]);
+ aquaMenuBarHeight = [[NSApp mainMenu] menuBarHeight];
+#if ! __LP64__
+ if (!aquaMenuBarHeight) {
+ aquaMenuBarHeight = [NSMenuView menuBarHeight];
+ }
+#endif
+ if (!aquaMenuBarHeight) {
+ NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0];
+ aquaMenuBarHeight = NSHeight([primaryScreen frame]) - NSMaxY([primaryScreen visibleFrame]);
+ }
#ifdef HAVE_LIBDISPATCH
eventTranslationQueue = dispatch_queue_create(