[Xquartz-changes] xserver: Branch 'master'

Jeremy Huddleston jeremyhu at freedesktop.org
Tue Oct 13 13:44:27 PDT 2015


Rebased ref, commits from common ancestor:
commit a34adc671d35b4f84bf2841d4d39dcf951716486
Author: Tom Seddon <xquartz-dev at tomseddon.plus.com>
Date:   Mon Oct 12 16:45:41 2015 -0700

    XQuartz: Fix how we calculate the height of the OSX menu bar
    
    Squashes two commits:
    
    I've been having all sorts of problems with XQuartz and quartz-wm when the
    `Displays have separate Spaces' option is set. This sejems to be due to the
    aquaBarMenuHeight calculation being a bit unusual - on my system it gets
    things hopelessly wrong, and decides the menu bar is -500 pixels high.
    
    With my change it gets the right value, and windows are appropriately
    constrained to the screens' visible frames. Full screen mode still doesn't
    work, though.
    
    Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Signed-off-by: Tom Seddon <xquartz-dev at tomseddon.plus.com>
    
    +[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 at apple.com>
    Signed-off-by: Ken Thomases <ken at codeweavers.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8a928ba..2262a70 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1238,8 +1238,14 @@ 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 (!aquaMenuBarHeight) {
+        aquaMenuBarHeight = [NSMenuView menuBarHeight];
+    }
+    if (!aquaMenuBarHeight) {
+        NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0];
+        aquaMenuBarHeight = NSHeight([primaryScreen frame]) - NSMaxY([primaryScreen visibleFrame]);
+    }
 
 #ifdef HAVE_LIBDISPATCH
     eventTranslationQueue = dispatch_queue_create(


More information about the Xquartz-changes mailing list