xserver: Branch 'master' - 12 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 2 00:45:30 UTC 2021


 configure.ac                          |    4 
 hw/xquartz/GL/indirect.c              |    2 
 hw/xquartz/Makefile.am                |    6 
 hw/xquartz/X11Application.m           |   63 ----
 hw/xquartz/X11Controller.h            |   15 -
 hw/xquartz/X11Controller.m            |   15 -
 hw/xquartz/applewmExt.h               |    6 
 hw/xquartz/console_redirect.c         |  482 ----------------------------------
 hw/xquartz/console_redirect.h         |   46 ---
 hw/xquartz/mach-startup/bundle-main.c |   69 ----
 hw/xquartz/mach-startup/stub.c        |   15 -
 hw/xquartz/man/Xquartz.man            |    2 
 hw/xquartz/pbproxy/pbproxy.h          |   11 
 hw/xquartz/pbproxy/x-selection.m      |   28 -
 hw/xquartz/quartz.c                   |    6 
 hw/xquartz/quartzKeyboard.c           |  149 ----------
 hw/xquartz/quartzRandR.c              |  152 ----------
 hw/xquartz/xpr/dri.c                  |   12 
 hw/xquartz/xpr/xprAppleWM.c           |   10 
 hw/xquartz/xpr/xprEvent.c             |   23 -
 hw/xquartz/xpr/xprFrame.c             |   39 --
 hw/xquartz/xpr/xprScreen.c            |   31 --
 include/dix-config.h.in               |    3 
 os/log.c                              |    7 
 24 files changed, 24 insertions(+), 1172 deletions(-)

New commits:
commit 7d0bb7ed061458698ff27856976939b261e73b23
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:46:02 2021 -0800

    xquartz: Remove support for older versions of libXplugin
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 77c919106..10afdf91a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -345,14 +345,11 @@ message_kit_thread(SEL selector, NSObject *arg)
                     swallow_keycode = [e keyCode];
                     do_swallow = YES;
                     for_x = NO;
-#if XPLUGIN_VERSION >= 1
-                }
-                else if (XQuartzEnableKeyEquivalents &&
+                } else if (XQuartzEnableKeyEquivalents &&
                          xp_is_symbolic_hotkey_event([e eventRef])) {
                     swallow_keycode = [e keyCode];
                     do_swallow = YES;
                     for_x = NO;
-#endif
                 }
                 else if (XQuartzEnableKeyEquivalents &&
                          [[self mainMenu] performKeyEquivalent:e]) {
@@ -1558,8 +1555,6 @@ handle_mouse:
         }
 
         if (!XQuartzServerVisible && noTestExtensions) {
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
-            /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
             xp_window_id wid = 0;
             xp_error err;
 
@@ -1572,7 +1567,6 @@ handle_mouse:
             err = xp_find_window(location.x, location.y, 0, &wid);
 
             if (err != XP_Success || (err == XP_Success && wid == 0))
-#endif
             {
                 bgMouseLocation = location;
                 bgMouseLocationUpdated = TRUE;
@@ -1650,17 +1644,6 @@ handle_mouse:
         }
 #endif
         
-#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
-        /* If we're in the background, we need to send a MotionNotify event
-         * first, since we aren't getting them on background mouse motion
-         */
-        if (!XQuartzServerVisible && noTestExtensions) {
-            bgMouseLocationUpdated = FALSE;
-            DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
-                                    location.x, location.y,
-                                    0.0, 0.0);
-        }
-#endif
         if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7 &&
             XQuartzScrollInDeviceDirection &&
             [e isDirectionInvertedFromDevice]) {
diff --git a/hw/xquartz/applewmExt.h b/hw/xquartz/applewmExt.h
index 14c77214a..9a8b8d639 100644
--- a/hw/xquartz/applewmExt.h
+++ b/hw/xquartz/applewmExt.h
@@ -35,12 +35,6 @@
 #include "window.h"
 #include <Xplugin.h>
 
-#if XPLUGIN_VERSION < 4
-typedef int xp_frame_attr;
-typedef int xp_frame_class;
-typedef int xp_frame_rect;
-#endif
-
 typedef int (*DisableUpdateProc)(void);
 typedef int (*EnableUpdateProc)(void);
 typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index 8c4f5efb8..126661766 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -82,7 +82,6 @@ xprSetWindowLevel(WindowPtr pWin, int level)
     return Success;
 }
 
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
 static int
 xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent)
 {
@@ -114,7 +113,6 @@ xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent)
 
     return Success;
 }
-#endif
 
 static int
 xprFrameDraw(WindowPtr pWin,
@@ -146,16 +144,8 @@ static AppleWMProcsRec xprAppleWMProcs = {
     xp_frame_get_rect,
     xp_frame_hit_test,
     xprFrameDraw,
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
     xp_set_dock_proxy,
     xprAttachTransient
-#elif defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 2
-    xp_set_dock_proxy,
-    NULL
-#else
-    NULL,
-    NULL
-#endif
 };
 
 void
diff --git a/hw/xquartz/xpr/xprEvent.c b/hw/xquartz/xpr/xprEvent.c
index e193a2747..eb321a52f 100644
--- a/hw/xquartz/xpr/xprEvent.c
+++ b/hw/xquartz/xpr/xprEvent.c
@@ -74,24 +74,9 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev)
 
     case kXquartzBringAllToFront:
         DEBUG_LOG("kXquartzBringAllToFront\n");
-        /* There's no need to do xp_window_bring_all_to_front on Leopard,
-         * and we don't care about the result, so just do it async.
-         */
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6
-#  if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6
-        if (&xp_window_bring_all_to_front) {
-#  endif
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                xp_window_bring_all_to_front();
-            });
-#  if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6
-        } else {
-            RootlessOrderAllWindows(e->data[0]);
-        }
-#  endif
-#else
-        RootlessOrderAllWindows(e->data[0]);
-#endif
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            xp_window_bring_all_to_front();
+        });
 
         return TRUE;
 
commit 5e7c0762e6fdaefc9b8257c0f875432b1877c49e
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:43:01 2021 -0800

    xquartz: Remove unused include of AvailabilityMacros.h from various sources
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 6738946ff..a8ccfc8ee 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -35,8 +35,6 @@
 #include <dix-config.h>
 #endif
 
-#include <AvailabilityMacros.h>
-
 #include <dlfcn.h>
 
 #include <OpenGL/OpenGL.h>
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 9eb46ab05..77c919106 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -48,7 +48,6 @@
 
 #include <mach/mach.h>
 #include <unistd.h>
-#include <AvailabilityMacros.h>
 
 #include <pthread.h>
 
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index bc976bf5f..c0604b773 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -29,7 +29,6 @@
  */
 
 #include "sanitizedCarbon.h"
-#include <AvailabilityMacros.h>
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index cacac7a8f..363bf5ac1 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -29,7 +29,6 @@
  */
 
 #include <CoreFoundation/CoreFoundation.h>
-#include <AvailabilityMacros.h>
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index fad7ea76d..f5fef90fb 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -50,8 +50,6 @@
 
 #include <signal.h>
 
-#include <AvailabilityMacros.h>
-
 #include "launchd_fd.h"
 
 static char x11_path[PATH_MAX + 1];
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index 1b94097b7..482f95ea6 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -35,8 +35,6 @@
 
 #include <asl.h>
 
-#include <AvailabilityMacros.h>
-
 #define  Cursor X_Cursor
 #undef _SHAPE_H_
 #include <X11/Xlib.h>
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index bf28dedb4..9845b82ec 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -46,7 +46,6 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/stat.h>
-#include <AvailabilityMacros.h>
 
 #include "quartz.h"
 #include "darwin.h"
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index 2e0c7b53d..795d1915c 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -42,8 +42,6 @@
 
 #include "X11Application.h"
 
-#include <AvailabilityMacros.h>
-
 #include <X11/extensions/randr.h>
 #include <randrstr.h>
 #include <IOKit/graphics/IOGraphicsTypes.h>
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 67ea6a006..091418e19 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -69,8 +69,6 @@
 #include "x-hook.h"
 #include "driWrap.h"
 
-#include <AvailabilityMacros.h>
-
 static DevPrivateKeyRec DRIScreenPrivKeyRec;
 #define DRIScreenPrivKey       (&DRIScreenPrivKeyRec)
 static DevPrivateKeyRec DRIWindowPrivKeyRec;
commit 59f22341a8b4cd468d6f37fb17dd7fde347e430b
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:40:48 2021 -0800

    xquartz: Remove support for building for i386
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index eb089b72d..9eb46ab05 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1209,11 +1209,6 @@ X11ApplicationMain(int argc, char **argv, char **envp)
 
     /* Calculate the height of the menubar so we can avoid it. */
     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]);
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index b89a5760e..21b5b3172 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -673,13 +673,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
         return;
     }
 
-#ifdef __LP64__
     DebugF("pbtypes retainCount after containsObject: %lu\n",
            [pbtypes retainCount]);
-#else
-    DebugF("pbtypes retainCount after containsObject: %u\n",
-           [pbtypes retainCount]);
-#endif
 
     data = [pb stringForType:NSStringPboardType];
 
@@ -698,11 +693,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
 
         if (length < 50) {
             DebugF("UTF-8: %s\n", bytes);
-#ifdef __LP64__
             DebugF("UTF-8 length: %lu\n", length);
-#else
-            DebugF("UTF-8 length: %u\n", length);
-#endif
         }
     }
     else {
@@ -1196,13 +1187,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
         return;
     }
 
-#ifdef __LP64__
     DebugF("data retainCount before NSBitmapImageRep initWithData: %lu\n",
            [data retainCount]);
-#else
-    DebugF("data retainCount before NSBitmapImageRep initWithData: %u\n",
-           [data retainCount]);
-#endif
 
     bmimage = [[NSBitmapImageRep alloc] initWithData:data];
 
@@ -1212,13 +1198,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
         return;
     }
 
-#ifdef __LP64__
     DebugF("data retainCount after NSBitmapImageRep initWithData: %lu\n",
            [data retainCount]);
-#else
-    DebugF("data retainCount after NSBitmapImageRep initWithData: %u\n",
-           [data retainCount]);
-#endif
 
     @try
     {
@@ -1233,13 +1214,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
         return;
     }
 
-#ifdef __LP64__
     DebugF("bmimage retainCount after TIFFRepresentation %lu\n",
            [bmimage retainCount]);
-#else
-    DebugF("bmimage retainCount after TIFFRepresentation %u\n",
-           [bmimage retainCount]);
-#endif
 
     pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
 
@@ -1256,11 +1232,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete,
 
     [data autorelease];
 
-#ifdef __LP64__
     DebugF("bmimage retainCount before release %lu\n", [bmimage retainCount]);
-#else
-    DebugF("bmimage retainCount before release %u\n", [bmimage retainCount]);
-#endif
 
     [bmimage autorelease];
 }
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index cd1f96550..bf28dedb4 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -733,54 +733,6 @@ DarwinModifierStringToNXMask(const char *str, int separatelr)
     return 0;
 }
 
-#if !defined(__LP64__)
-static inline UniChar
-macroman2ucs(unsigned char c)
-{
-    /* Precalculated table mapping MacRoman-128 to Unicode. Generated
-       by creating single element CFStringRefs then extracting the
-       first character. */
-
-    static const unsigned short table[128] = {
-        0xc4,   0xc5,     0xc7,       0xc9,       0xd1,       0xd6,       0xdc,
-        0xe1,
-        0xe0,   0xe2,     0xe4,     0xe3,     0xe5,   0xe7,     0xe9,
-        0xe8,
-        0xea,   0xeb,     0xed,     0xec,     0xee,   0xef,     0xf1,
-        0xf3,
-        0xf2,   0xf4,     0xf6,     0xf5,     0xfa,   0xf9,     0xfb,
-        0xfc,
-        0x2020, 0xb0,     0xa2,     0xa3,     0xa7,   0x2022,   0xb6,
-        0xdf,
-        0xae,   0xa9,     0x2122,   0xb4,     0xa8,   0x2260,   0xc6,
-        0xd8,
-        0x221e, 0xb1,     0x2264,   0x2265,   0xa5,   0xb5,     0x2202,
-        0x2211,
-        0x220f, 0x3c0,    0x222b,   0xaa,     0xba,   0x3a9,    0xe6,
-        0xf8,
-        0xbf,   0xa1,     0xac,     0x221a,   0x192,  0x2248,   0x2206,
-        0xab,
-        0xbb,   0x2026,   0xa0,     0xc0,     0xc3,   0xd5,     0x152,
-        0x153,
-        0x2013, 0x2014,   0x201c,   0x201d,   0x2018, 0x2019,   0xf7,
-        0x25ca,
-        0xff,   0x178,    0x2044,   0x20ac,   0x2039, 0x203a,   0xfb01,
-        0xfb02,
-        0x2021, 0xb7,     0x201a,   0x201e,   0x2030, 0xc2,     0xca,
-        0xc1,
-        0xcb,   0xc8,     0xcd,     0xce,     0xcf,   0xcc,     0xd3,
-        0xd4,
-        0xf8ff, 0xd2,     0xda,     0xdb,     0xd9,   0x131,    0x2c6,
-        0x2dc,
-        0xaf,   0x2d8,    0x2d9,    0x2da,    0xb8,   0x2dd,    0x2db,
-        0x2c7,
-    };
-
-    if (c < 128) return c;
-    else return table[c - 128];
-}
-#endif
-
 static KeySym
 make_dead_key(KeySym in)
 {
@@ -795,10 +747,6 @@ make_dead_key(KeySym in)
 static Bool
 QuartzReadSystemKeymap(darwinKeyboardInfo *info)
 {
-#if !defined(__LP64__)
-    KeyboardLayoutRef key_layout;
-    int is_uchr = 1;
-#endif
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = LMGetKbdType();
@@ -815,53 +763,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
             currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
         if (currentKeyLayoutDataRef)
             chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
-    }
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
-#endif
-
-#if !defined(__LP64__)
-    if (chr_data == NULL) {
-        ErrorF(
-            "X11.app: Error detected in determining keyboard layout.  If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
-        ErrorF(
-            "X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
-            (unsigned)keyboard_type, currentKeyLayoutRef,
-            currentKeyLayoutDataRef, chr_data);
-
-        KLGetCurrentKeyboardLayout(&key_layout);
-        KLGetKeyboardLayoutProperty(key_layout, kKLuchrData, &chr_data);
-
-        if (chr_data != NULL) {
-            ErrorF(
-                "X11.app: Fallback succeeded, but this is still a bug.  Please report the above information.\n");
-        }
-    }
-
-    if (chr_data == NULL) {
-        ErrorF(
-            "X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
-        ErrorF(
-            "If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
-        KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data);
-        is_uchr = 0;
-        num_keycodes = 128;
-
-        if (chr_data != NULL) {
-            ErrorF(
-                "X11.app: Fallback succeeded, but this is still a bug.  Please report the above information.\n");
-        }
-    }
-#endif
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-    if (currentKeyLayoutRef)
         CFRelease(currentKeyLayoutRef);
+    }
 
     if (chr_data == NULL) {
         ErrorF("Couldn't get uchr or kchr resource\n");
@@ -885,9 +788,6 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
         k = info->keyMap + i * GLYPHS_PER_KEY;
 
         for (j = 0; j < 4; j++) {
-#if !defined(__LP64__)
-            if (is_uchr) {
-#endif
             UniChar s[8];
             UniCharCount len;
             UInt32 dead_key_state = 0, extra_dead = 0;
@@ -914,42 +814,6 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
                 k[j] = ucs2keysym(s[0]);
                 if (dead_key_state != 0) k[j] = make_dead_key(k[j]);
             }
-#if !defined(__LP64__)
-        }
-        else {       // kchr
-            UInt32 c, state = 0, state2 = 0;
-            UInt16 code;
-
-            code = i | mods[j];
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
-#endif
-
-            c = KeyTranslate(chr_data, code, &state);
-
-            /* Dead keys are only processed on key-down, so ask
-               to translate those events. When we find a dead key,
-               translating the matching key up event will give
-               us the actual dead character. */
-
-            if (state != 0)
-                c = KeyTranslate(chr_data, code | 128, &state2);
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-            /* Characters seem to be in MacRoman encoding. */
-
-            if (c != 0 && c != 0x0010) {
-                k[j] = ucs2keysym(macroman2ucs(c & 255));
-
-                if (state != 0) k[j] = make_dead_key(k[j]);
-            }
-        }
-#endif
         }
 
         if (k[3] == k[2]) k[3] = NoSymbol;
commit aea15a76593f98205e44f20632178dc384c02d57
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:35:17 2021 -0800

    xquartz: Remove support for Mountain Lion and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index b7d5ebef7..cacac7a8f 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -57,6 +57,8 @@
 #include "mach_startup.h"
 #include "mach_startupServer.h"
 
+#include <asl.h>
+
 /* From darwinEvents.c ... but don't want to pull in all the server cruft */
 void
 DarwinListenOnOpenFD(int fd);
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index f54870dd9..ec2cdaa0c 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -56,11 +56,6 @@
 
 #include "nonsdk_extinit.h"
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
-// From NSApplication.h
-extern const double NSAppKitVersionNumber;
-#endif
-
 /* 10.4's deferred update makes X slower.. have to live with the tearing
  * for now.. */
 #define XP_NO_DEFERRED_UPDATES 8
@@ -172,18 +167,13 @@ displayScreenBounds(CGDirectDisplayID id)
               (int)frame.origin.x, (int)frame.origin.y);
 
     Boolean spacePerDisplay = false;
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
-    if (NSAppKitVersionNumber >= 1265)
-#endif
-    {
-        Boolean ok;
-        (void)CFPreferencesAppSynchronize(CFSTR("com.apple.spaces"));
-        spacePerDisplay = ! CFPreferencesGetAppBooleanValue(CFSTR("spans-displays"),
-                                                            CFSTR("com.apple.spaces"),
-                                                            &ok);
-        if (!ok)
-            spacePerDisplay = true;
-    }
+    Boolean ok;
+    (void)CFPreferencesAppSynchronize(CFSTR("com.apple.spaces"));
+    spacePerDisplay = ! CFPreferencesGetAppBooleanValue(CFSTR("spans-displays"),
+                                                        CFSTR("com.apple.spaces"),
+                                                        &ok);
+    if (!ok)
+        spacePerDisplay = true;
 
     /* Remove menubar to help standard X11 window managers.
      * On Mavericks and later, the menu bar is on all displays when spans-displays is false or unset.
commit c0b2d3e099a60f55b18ca9c30373000f12d40fe2
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:33:22 2021 -0800

    xquartz: Remove support for Lion and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index ebd3e1bc7..85355a8ac 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -33,8 +33,7 @@ libXquartz_la_SOURCES = \
 	quartzCocoa.m \
 	quartzKeyboard.c \
 	quartzStartup.c \
-	quartzRandR.c \
-	console_redirect.c
+	quartzRandR.c
 
 libXquartz_la_LIBADD = $(top_builddir)/pseudoramiX/libPseudoramiX.la
 
@@ -51,5 +50,4 @@ EXTRA_DIST = \
 	quartzKeyboard.h \
 	quartzRandR.h \
 	sanitizedCarbon.h \
-	sanitizedCocoa.h \
-	console_redirect.h
+	sanitizedCocoa.h
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 81ad3c639..bc976bf5f 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -347,10 +347,8 @@ extern char *bundle_id_prefix;
     const char *newargv[4];
     char buf[128];
     char *s;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
     int stdout_pipe[2];
     int stderr_pipe[2];
-#endif
 
     newargv[0] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
     newargv[1] = "-c";
@@ -363,7 +361,6 @@ extern char *bundle_id_prefix;
         setenv("DISPLAY", buf, TRUE);
     }
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
     if (&asl_log_descriptor) {
         char *asl_sender;
         aslmsg amsg = asl_new(ASL_TYPE_MSG);
@@ -395,7 +392,6 @@ extern char *bundle_id_prefix;
 
         asl_free(amsg);
     }
-#endif
 
     /* Do the fork-twice trick to avoid having to reap zombies */
     child1 = fork();
@@ -413,13 +409,11 @@ extern char *bundle_id_prefix;
             _exit(1);
 
         case 0:                                     /* child2 */
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
             if (&asl_log_descriptor) {
                 /* Replace our stdout/stderr */
                 dup2(stdout_pipe[1], STDOUT_FILENO);
                 dup2(stderr_pipe[1], STDERR_FILENO);
             }
-#endif
 
             /* close all open files except for standard streams */
             max_files = sysconf(_SC_OPEN_MAX);
@@ -442,13 +436,11 @@ extern char *bundle_id_prefix;
         waitpid(child1, &status, 0);
     }
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
     if (&asl_log_descriptor) {
         /* Close the write ends of the pipe */
         close(stdout_pipe[1]);
         close(stderr_pipe[1]);
     }
-#endif
 }
 
 - (void) app_selected:sender
diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
deleted file mode 100644
index 245086ad0..000000000
--- a/hw/xquartz/console_redirect.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above
- * copyright holders shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without
- * prior written authorization.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-#define DEBUG_CONSOLE_REDIRECT 1
-#endif
-
-#include <assert.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/event.h>
-#include <asl.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#include "console_redirect.h"
-
-#define BUF_SIZE 512
-
-#include <dispatch/dispatch.h>
-
-static dispatch_queue_t redirect_serial_q;
-static dispatch_group_t read_source_group;
-
-typedef struct {
-    int level;
-    aslclient asl;
-    aslmsg msg;
-
-    /* Buffered reading */
-    char *buf;
-    char *w;
-
-    dispatch_source_t read_source;
-} asl_redirect;
-
-static asl_redirect *redirect_fds = NULL;
-static int n_redirect_fds = 0;
-
-/* Read from the FD until there is no more to read and redirect to ASL.
- * Preconditions:
- *      1: pthread_mutex_lock lock is held (pthreads) or called
- *         from the appropriate serial queue for operating on
- *         redirect_fds
- *      2: fd corresponds to a valid entry in redirect_fds
- *
- * Return values:
- *      If the pipe is closed, EOF is returned regardless of how many bytes
- *      were processed.  If the pipe is still open, the number of read bytes
- *      is returned.
- */
-static inline int
-_read_redirect(int fd, int flush)
-{
-    int total_read = 0;
-    int nbytes;
-    asl_redirect *aslr = &redirect_fds[fd];
-
-    while ((nbytes =
-                read(fd, aslr->w,
-                     BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
-        char *s, *p;
-
-        /* Increment our returned number read */
-        total_read += nbytes;
-
-        /* Increment our write location */
-        aslr->w += nbytes;
-        aslr->w[0] = '\0';
-
-        /* One line at a time */
-        for (p = aslr->buf; p < aslr->w; p = s + 1) {
-            // Find null or \n
-            for (s = p; *s && *s != '\n'; s++) ;
-            if (*s == '\n') {
-                *s = '\0';
-            }
-
-            if (s < aslr->w || aslr->buf == p) {
-                /* Either the first of multiple messages or one message which is larger than our buffer */
-                asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
-            }
-            else {
-                /* We reached the end of the buffer, move this chunk to the start. */
-                memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
-                aslr->w = aslr->buf + (s - p);
-                break;
-            }
-        }
-
-        if (p == aslr->w) {
-            /* Start writing at the beginning in the case where we flushed */
-            aslr->w = aslr->buf;
-        }
-    }
-
-    /* Flush if requested or we're at EOF */
-    if (flush || nbytes == 0) {
-        if (aslr->w > aslr->buf) {
-            *aslr->w = '\0';
-            asl_log(aslr->asl, aslr->msg, aslr->level, "%s", aslr->buf);
-        }
-    }
-
-    if (nbytes == 0)
-        return EOF;
-    return total_read;
-}
-
-static void
-read_from_source(void *_source)
-{
-    dispatch_source_t source = (dispatch_source_t)_source;
-    int fd = dispatch_source_get_handle(source);
-    if (_read_redirect(fd, 0) == EOF) {
-        dispatch_source_cancel(source);
-    }
-}
-
-static void
-cancel_source(void *_source)
-{
-    dispatch_source_t source = (dispatch_source_t)_source;
-    int fd = dispatch_source_get_handle(source);
-    asl_redirect *aslr = &redirect_fds[fd];
-
-    /* Flush the buffer */
-    _read_redirect(fd, 1);
-
-    close(fd);
-    free(aslr->buf);
-    memset(aslr, 0, sizeof(*aslr));
-    dispatch_release(source);
-    dispatch_group_leave(read_source_group);
-}
-
-
-static void
-redirect_atexit(void)
-{
-    /* stdout is linebuffered, so flush the buffer */
-    if (redirect_fds[STDOUT_FILENO].buf)
-        fflush(stdout);
-
-    {
-        int i;
-
-        /* Cancel all of our dispatch sources, so they flush to ASL */
-        for (i = 0; i < n_redirect_fds; i++)
-            if (redirect_fds[i].read_source)
-                dispatch_source_cancel(redirect_fds[i].read_source);
-
-        /* Wait at least three seconds for our sources to flush to ASL */
-        dispatch_group_wait(read_source_group,
-                            dispatch_time(DISPATCH_TIME_NOW, 3LL *
-                                          NSEC_PER_SEC));
-    }
-}
-
-static void
-xq_asl_init(void *ctx __unused)
-{
-    assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
-    n_redirect_fds = 16;
-
-    redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
-    assert(redirect_serial_q != NULL);
-
-    read_source_group = dispatch_group_create();
-    assert(read_source_group != NULL);
-
-    atexit(redirect_atexit);
-}
-
-int
-xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
-{
-    int err __block = 0;
-    static dispatch_once_t once_control;
-    dispatch_once_f(&once_control, NULL, xq_asl_init);
-
-    if (fd < 0)
-        return EBADF;
-
-#define BLOCK_DONE return
-    dispatch_sync(redirect_serial_q, ^
-                  {
-                      /* Reallocate if we need more space */
-                      if (fd >= n_redirect_fds) {
-                          size_t new_n = 1 << (fls(fd) + 1);
-                          asl_redirect *new_array =
-                              realloc(redirect_fds, new_n *
-                                      sizeof(*redirect_fds));
-                          if (!new_array) {
-                              err = errno;
-                              BLOCK_DONE;
-                          }
-                          redirect_fds = new_array;
-                          memset(redirect_fds + n_redirect_fds, 0, (new_n -
-                                 n_redirect_fds) * sizeof(*redirect_fds));
-                          n_redirect_fds = new_n;
-                      }
-
-                      /* If we're already listening on it, return error. */
-                      if (redirect_fds[fd].buf != NULL) {
-                          err = EBADF;
-                          BLOCK_DONE;
-                      }
-
-                      /* Initialize our buffer */
-                      redirect_fds[fd].buf = (char *)malloc(BUF_SIZE);
-                      if (redirect_fds[fd].buf == NULL) {
-                          err = errno;
-                          BLOCK_DONE;
-                      }
-                      redirect_fds[fd].w = redirect_fds[fd].buf;
-
-                      /* Store our ASL settings */
-                      redirect_fds[fd].level = level;
-                      redirect_fds[fd].asl = asl;
-                      redirect_fds[fd].msg = msg;
-
-                      /* Don't block on reads from this fd */
-                      fcntl(fd, F_SETFL,
-                            O_NONBLOCK);
-
-                      /* Start listening */
-                      {
-                          dispatch_source_t read_source =
-                              dispatch_source_create(
-                                  DISPATCH_SOURCE_TYPE_READ, fd, 0,
-                                  redirect_serial_q);
-                          redirect_fds[fd].read_source = read_source;
-                          dispatch_set_context(read_source, read_source);
-                          dispatch_source_set_event_handler_f(read_source,
-                                                              read_from_source);
-                          dispatch_source_set_cancel_handler_f(read_source,
-                                                               cancel_source);
-                          dispatch_group_enter(read_source_group);
-                          dispatch_resume(read_source);
-                      }
-                  }
-                  );
-#undef BLOCK_DONE
-
-    return err;
-}
-
-int
-xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd)
-{
-    int pipepair[2];
-
-    /* Create pipe */
-    if (pipe(pipepair) == -1)
-        return errno;
-
-    /* Close the read fd but not the write fd on exec */
-    if (fcntl(pipepair[0], F_SETFD, FD_CLOEXEC) == -1)
-        return errno;
-
-    /* Replace the existing fd */
-    if (dup2(pipepair[1], fd) == -1) {
-        close(pipepair[0]);
-        close(pipepair[1]);
-        return errno;
-    }
-
-    /* If we capture STDOUT_FILENO, make sure we linebuffer stdout */
-    if (fd == STDOUT_FILENO)
-        setlinebuf(stdout);
-
-    /* Close the duplicate fds since they've been reassigned */
-    close(pipepair[1]);
-
-    /* Hand off the read end of our pipe to xq_asl_log_fd */
-    return xq_asl_log_fd(asl, msg, level, pipepair[0]);
-}
-
-#ifdef DEBUG_CONSOLE_REDIRECT
-int
-main(int argc __unused, char * *argv __unused)
-{
-    xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO);
-    xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO);
-
-    fprintf(stderr, "TEST ERR1\n");
-    fprintf(stdout, "TEST OUT1\n");
-    fprintf(stderr, "TEST ERR2\n");
-    fprintf(stdout, "TEST OUT2\n");
-    system("/bin/echo SYST OUT");
-    system("/bin/echo SYST ERR >&2");
-    fprintf(stdout, "TEST OUT3\n");
-    fprintf(stdout, "TEST OUT4\n");
-    fprintf(stderr, "TEST ERR3\n");
-    fprintf(stderr, "TEST ERR4\n");
-
-    exit(0);
-}
-#endif
diff --git a/hw/xquartz/console_redirect.h b/hw/xquartz/console_redirect.h
deleted file mode 100644
index 7b80de405..000000000
--- a/hw/xquartz/console_redirect.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (c) 2011-2012 Apple Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above
- * copyright holders shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without
- * prior written authorization.
- */
-
-#ifndef _XQUARTZ_CONSOLE_REDIRECT_H_
-#define _XQUARTZ_CONSOLE_REDIRECT_H_
-
-#include <asl.h>
-
-/* The given fd is replaced with a pipe.  Anything written to it will will be
- * logged to ASL.
- */
-int
-xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd);
-
-/* The given fd is read from and passed along to ASL until all write ends of the
- * pipe are closed. Once the last writer has closed the pipe, we close our end.
- */
-int
-xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd);
-
-#endif
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 47a02bcb3..b7d5ebef7 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -57,8 +57,6 @@
 #include "mach_startup.h"
 #include "mach_startupServer.h"
 
-#include "console_redirect.h"
-
 /* From darwinEvents.c ... but don't want to pull in all the server cruft */
 void
 DarwinListenOnOpenFD(int fd);
@@ -520,24 +518,8 @@ setup_console_redirect(const char *bundle_id)
 
     asl_set_filter(aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_WARNING));
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-# if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
-    if (asl_log_descriptor)
-# endif
-    {
-        asl_log_descriptor(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
-        asl_log_descriptor(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
-    }
-# if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
-    else {
-        xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
-        xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
-    }
-# endif
-#else
-    xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
-    xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
-#endif
+    asl_log_descriptor(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
+    asl_log_descriptor(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
 }
 
 static void
commit cc9cf6f085be6e8264f925a11d67a12ad47a042b
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:29:52 2021 -0800

    xquartz: Remove support for SnowLeopard and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 72a8c95f7..eb089b72d 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1667,15 +1667,12 @@ handle_mouse:
                                     0.0, 0.0);
         }
 #endif
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
-        // TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
-        if (NSAppKitVersionNumber >= 1117 &&
+        if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7 &&
             XQuartzScrollInDeviceDirection &&
             [e isDirectionInvertedFromDevice]) {
             deltaX *= -1;
             deltaY *= -1;
         }
-#endif
         /* This hack is in place to better deal with "clicky" scroll wheels:
          * http://xquartz.macosforge.org/trac/ticket/562
          */
commit f699aac2ea2cf6a3e2d3bdcb2d8179e103de1d4e
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:09:50 2021 -0800

    xquartz: Remove check for libdispatch now that we don't support pre-SnowLeopard
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 2c9e5dbf6..1cf1cca35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -684,10 +684,6 @@ case $host_os in
 			fi
 		fi
 
-		AC_CHECK_FUNC(dispatch_async,
-		              AC_DEFINE([HAVE_LIBDISPATCH], 1, [Define to 1 if you have the libdispatch (GCD) available]),
-		              [])
-
 		if test "x$XQUARTZ" = xyes ; then
 			XQUARTZ=yes
 			XVFB=no
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 39544e953..72a8c95f7 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -64,11 +64,9 @@ xpbproxy_run(void);
 #define XSERVER_VERSION "?"
 #endif
 
-#ifdef HAVE_LIBDISPATCH
 #include <dispatch/dispatch.h>
 
 static dispatch_queue_t eventTranslationQueue;
-#endif
 
 #ifndef __has_feature
 #define __has_feature(x) 0
@@ -486,13 +484,9 @@ message_kit_thread(SEL selector, NSObject *arg)
     if (for_appkit) [super sendEvent:e];
 
     if (for_x) {
-#ifdef HAVE_LIBDISPATCH
         dispatch_async(eventTranslationQueue, ^{
                            [self sendX11NSEvent:e];
                        });
-#else
-        [self sendX11NSEvent:e];
-#endif
     }
 }
 
@@ -1225,11 +1219,9 @@ X11ApplicationMain(int argc, char **argv, char **envp)
         aquaMenuBarHeight = NSHeight([primaryScreen frame]) - NSMaxY([primaryScreen visibleFrame]);
     }
 
-#ifdef HAVE_LIBDISPATCH
     eventTranslationQueue = dispatch_queue_create(
         BUNDLE_ID_PREFIX ".X11.NSEventsToX11EventsQueue", NULL);
     assert(eventTranslationQueue != NULL);
-#endif
 
     /* Set the key layout seed before we start the server */
     last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index 30d05ecc0..245086ad0 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -31,7 +31,6 @@
 #include <dix-config.h>
 #else
 #define DEBUG_CONSOLE_REDIRECT 1
-#define HAVE_LIBDISPATCH       1
 #endif
 
 #include <assert.h>
@@ -49,22 +48,10 @@
 
 #define BUF_SIZE 512
 
-#ifdef HAVE_LIBDISPATCH
 #include <dispatch/dispatch.h>
 
 static dispatch_queue_t redirect_serial_q;
 static dispatch_group_t read_source_group;
-#else
-#include <pthread.h>
-
-static pthread_t redirect_pthread;
-static pthread_mutex_t redirect_fds_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static int kq;
-
-/* Notifications to our reader thread */
-#define ASL_REDIRECT_TERMINATE ((void *)(uintptr_t)1)
-#endif
 
 typedef struct {
     int level;
@@ -75,9 +62,7 @@ typedef struct {
     char *buf;
     char *w;
 
-#ifdef HAVE_LIBDISPATCH
     dispatch_source_t read_source;
-#endif
 } asl_redirect;
 
 static asl_redirect *redirect_fds = NULL;
@@ -153,7 +138,6 @@ _read_redirect(int fd, int flush)
     return total_read;
 }
 
-#ifdef HAVE_LIBDISPATCH
 static void
 read_from_source(void *_source)
 {
@@ -181,79 +165,6 @@ cancel_source(void *_source)
     dispatch_group_leave(read_source_group);
 }
 
-#else /* !HAVE_LIBDISPATCH */
-static void *
-redirect_thread(void *ctx __unused)
-{
-    struct kevent ev;
-    int n;
-
-    while (1) {
-        n = kevent(kq, NULL, 0, &ev, 1, NULL);
-
-        /* Bail on errors */
-        if (n < 0) {
-            asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent failure: %s",
-                    strerror(errno));
-            break;
-        }
-
-        /* This should not happen */
-        if (n == 0)
-            continue;
-
-        switch (ev.filter) {
-        case EVFILT_READ:
-            pthread_mutex_lock(&redirect_fds_lock);
-            {
-                int fd = ev.ident;
-                int close_fd = 0;
-                asl_redirect *aslr = &redirect_fds[fd];
-
-                if (fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
-                    asl_log(NULL, NULL, ASL_LEVEL_ERR,
-                            "Unexpected file descriptor: %d",
-                            fd);
-                    goto next;
-                }
-
-                if (ev.flags & EV_EOF) {
-                    close_fd = 1;
-                    if (EOF != _read_redirect(fd, 1)) {
-                        asl_log(
-                            NULL, NULL, ASL_LEVEL_ERR,
-                            "kevent reported EOF on %d, but read doesn't concur.",
-                            fd);
-                    }
-                }
-                else {
-                    close_fd = (EOF == _read_redirect(fd, 0));
-                }
-
-                if (close_fd) {
-                    EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
-                    kevent(kq, &ev, 1, NULL, 0, NULL);
-                    close(fd);
-                    free(aslr->buf);
-                    memset(aslr, 0, sizeof(*aslr));
-                }
-            }
-next:
-            pthread_mutex_unlock(&redirect_fds_lock);
-
-        case EVFILT_TIMER:
-            if (ev.udata == ASL_REDIRECT_TERMINATE)
-                return NULL;
-
-        default:
-            ;
-            ;
-        }
-    }
-
-    return NULL;
-}
-#endif
 
 static void
 redirect_atexit(void)
@@ -262,7 +173,6 @@ redirect_atexit(void)
     if (redirect_fds[STDOUT_FILENO].buf)
         fflush(stdout);
 
-#ifdef HAVE_LIBDISPATCH
     {
         int i;
 
@@ -276,42 +186,19 @@ redirect_atexit(void)
                             dispatch_time(DISPATCH_TIME_NOW, 3LL *
                                           NSEC_PER_SEC));
     }
-#else
-    {
-        struct kevent ev;
-
-        /* Tell our reader thread it is time to pack up and go home */
-        EV_SET(&ev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 0,
-               ASL_REDIRECT_TERMINATE);
-        kevent(kq, &ev, 1, NULL, 0, NULL);
-
-        pthread_join(redirect_pthread, NULL);
-    }
-#endif
 }
 
-#ifdef HAVE_LIBDISPATCH
 static void
 xq_asl_init(void *ctx __unused)
-#else
-static void
-xq_asl_init(void)
-#endif
 {
     assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
     n_redirect_fds = 16;
 
-#ifdef HAVE_LIBDISPATCH
     redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
     assert(redirect_serial_q != NULL);
 
     read_source_group = dispatch_group_create();
     assert(read_source_group != NULL);
-#else
-    assert((kq = kqueue()) != -1);
-    assert(pthread_create(&redirect_pthread, NULL, redirect_thread,
-                          NULL) == 0);
-#endif
 
     atexit(redirect_atexit);
 }
@@ -319,26 +206,15 @@ xq_asl_init(void)
 int
 xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
 {
-#ifdef HAVE_LIBDISPATCH
     int err __block = 0;
     static dispatch_once_t once_control;
     dispatch_once_f(&once_control, NULL, xq_asl_init);
-#else
-    int err = 0;
-    static pthread_once_t once_control = PTHREAD_ONCE_INIT;
-    assert(pthread_once(&once_control, xq_asl_init) == 0);
-#endif
 
     if (fd < 0)
         return EBADF;
 
-#ifdef HAVE_LIBDISPATCH
 #define BLOCK_DONE return
     dispatch_sync(redirect_serial_q, ^
-#else
-#define BLOCK_DONE goto done
-    assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
-#endif
                   {
                       /* Reallocate if we need more space */
                       if (fd >= n_redirect_fds) {
@@ -380,7 +256,6 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
                             O_NONBLOCK);
 
                       /* Start listening */
-#ifdef HAVE_LIBDISPATCH
                       {
                           dispatch_source_t read_source =
                               dispatch_source_create(
@@ -395,20 +270,8 @@ xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
                           dispatch_group_enter(read_source_group);
                           dispatch_resume(read_source);
                       }
-#else
-                      {
-                          struct kevent ev;
-                          EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
-                          kevent(kq, &ev, 1, NULL, 0, NULL);
-                      }
-#endif
                   }
-#ifdef HAVE_LIBDISPATCH
                   );
-#else
-done:
-                  assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
-#endif
 #undef BLOCK_DONE
 
     return err;
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 8a68785c2..47a02bcb3 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -44,11 +44,7 @@
 #include <stdbool.h>
 #include <signal.h>
 
-#ifdef HAVE_LIBDISPATCH
 #include <dispatch/dispatch.h>
-#else
-#include <pthread.h>
-#endif
 
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -115,23 +111,6 @@ static char *pref_app_to_run;
 static char *pref_login_shell;
 static char *pref_startx_script;
 
-#ifndef HAVE_LIBDISPATCH
-/*** Pthread Magics ***/
-static pthread_t
-create_thread(void *(*func)(void *), void *arg)
-{
-    pthread_attr_t attr;
-    pthread_t tid;
-
-    pthread_attr_init(&attr);
-    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create(&tid, &attr, func, arg);
-    pthread_attr_destroy(&attr);
-
-    return tid;
-}
-#endif
 
 /*** Mach-O IPC Stuffs ***/
 
@@ -239,16 +218,9 @@ typedef struct {
 /* This thread accepts an incoming connection and hands off the file
  * descriptor for the new connection to accept_fd_handoff()
  */
-#ifdef HAVE_LIBDISPATCH
 static void
 socket_handoff(socket_handoff_t *handoff_data)
 {
-#else
-static void *
-socket_handoff_thread(void *arg)
-{
-    socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
-#endif
 
     int launchd_fd = -1;
     int connected_fd;
@@ -283,9 +255,6 @@ socket_handoff_thread(void *arg)
         launchd_fd);
     DarwinListenOnOpenFD(launchd_fd);
 
-#ifndef HAVE_LIBDISPATCH
-    return NULL;
-#endif
 }
 
 static int
@@ -369,14 +338,10 @@ do_request_fd_handoff_socket(mach_port_t port, string_t filename)
 
     strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
 
-#ifdef HAVE_LIBDISPATCH
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
                                              0), ^ {
                        socket_handoff(handoff_data);
                    });
-#else
-    create_thread(socket_handoff_thread, handoff_data);
-#endif
 
 #ifdef DEBUG
     ErrorF(
diff --git a/hw/xquartz/xpr/xprEvent.c b/hw/xquartz/xpr/xprEvent.c
index 398177ca8..e193a2747 100644
--- a/hw/xquartz/xpr/xprEvent.c
+++ b/hw/xquartz/xpr/xprEvent.c
@@ -52,9 +52,7 @@
 #include <sys/uio.h>
 #include <unistd.h>
 
-#ifdef HAVE_LIBDISPATCH
 #include <dispatch/dispatch.h>
-#endif
 
 #include "rootlessWindow.h"
 #include "xprEvent.h"
@@ -79,7 +77,7 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev)
         /* There's no need to do xp_window_bring_all_to_front on Leopard,
          * and we don't care about the result, so just do it async.
          */
-#if defined(HAVE_LIBDISPATCH) && defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6
+#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6
 #  if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6
         if (&xp_window_bring_all_to_front) {
 #  endif
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index aad375b52..ba84548b5 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -43,11 +43,7 @@
 #include "windowstr.h"
 #include "quartz.h"
 
-#ifdef HAVE_LIBDISPATCH
 #include <dispatch/dispatch.h>
-#else
-#include <pthread.h>
-#endif
 
 #ifdef DEBUG_XP_LOCK_WINDOW
 #include <execinfo.h>
@@ -70,11 +66,7 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
 static x_hash_table * window_hash;
 
 /* Need to guard window_hash since xprIsX11Window can be called from any thread. */
-#ifdef HAVE_LIBDISPATCH
 static dispatch_queue_t window_hash_serial_q;
-#else
-static pthread_rwlock_t window_hash_rwlock;
-#endif
 
 /* Prototypes for static functions */
 static Bool
@@ -209,15 +201,9 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
         return FALSE;
     }
 
-#ifdef HAVE_LIBDISPATCH
     dispatch_async(window_hash_serial_q, ^ {
                        x_hash_table_insert(window_hash, pFrame->wid, pFrame);
                    });
-#else
-    pthread_rwlock_wrlock(&window_hash_rwlock);
-    x_hash_table_insert(window_hash, pFrame->wid, pFrame);
-    pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
 
     xprSetNativeProperty(pFrame);
 
@@ -232,15 +218,9 @@ xprDestroyFrame(RootlessFrameID wid)
 {
     xp_error err;
 
-#ifdef HAVE_LIBDISPATCH
     dispatch_async(window_hash_serial_q, ^ {
                        x_hash_table_remove(window_hash, wid);
                    });
-#else
-    pthread_rwlock_wrlock(&window_hash_rwlock);
-    x_hash_table_remove(window_hash, wid);
-    pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
 
     err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
     if (err != Success)
@@ -293,9 +273,7 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
 {
     xp_window_changes wc;
     unsigned int mask = XP_STACKING;
-#ifdef HAVE_LIBDISPATCH
     __block
-#endif
     RootlessWindowRec * winRec;
 
     /* Stack frame below nextWid it if it exists, or raise
@@ -310,15 +288,9 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
         wc.sibling = x_cvt_vptr_to_uint(nextWid);
     }
 
-#ifdef HAVE_LIBDISPATCH
     dispatch_sync(window_hash_serial_q, ^ {
                       winRec = x_hash_table_lookup(window_hash, wid, NULL);
                   });
-#else
-    pthread_rwlock_rdlock(&window_hash_rwlock);
-    winRec = x_hash_table_lookup(window_hash, wid, NULL);
-    pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
 
     if (winRec) {
         if (XQuartzIsRootless)
@@ -519,13 +491,9 @@ xprInit(ScreenPtr pScreen)
     rootless_CopyWindow_threshold = xp_scroll_area_threshold;
 
     assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL)));
-#ifdef HAVE_LIBDISPATCH
     assert((window_hash_serial_q =
                 dispatch_queue_create(BUNDLE_ID_PREFIX ".X11.xpr_window_hash",
                                       NULL)));
-#else
-    assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL));
-#endif
 
     return TRUE;
 }
@@ -537,19 +505,12 @@ xprInit(ScreenPtr pScreen)
 WindowPtr
 xprGetXWindow(xp_window_id wid)
 {
-#ifdef HAVE_LIBDISPATCH
     RootlessWindowRec *winRec __block;
     dispatch_sync(window_hash_serial_q, ^ {
                       winRec =
                           x_hash_table_lookup(window_hash,
                                               x_cvt_uint_to_vptr(wid), NULL);
                   });
-#else
-    RootlessWindowRec *winRec;
-    pthread_rwlock_rdlock(&window_hash_rwlock);
-    winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
-    pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
 
     return winRec != NULL ? winRec->win : NULL;
 }
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index ca8ac8763..382d70609 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -116,9 +116,6 @@
 /* Define to 1 if you have the `m' library (-lm). */
 #undef HAVE_LIBM
 
-/* Define to 1 if you have the libdispatch (GCD) available */
-#undef HAVE_LIBDISPATCH
-
 /* Define to 1 if you have the <linux/agpgart.h> header file. */
 #undef HAVE_LINUX_AGPGART_H
 
commit 5ad49102722274f53b9b011082d9e0f202fcd9a4
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:23:18 2021 -0800

    xquartz: Remove support for Leopard and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index 84c7ce6d8..29008c593 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -46,10 +46,7 @@
 #undef BOOL
 #endif
 
- at interface X11Controller : NSObject
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-    <NSTableViewDataSource>
-#endif
+ at interface X11Controller : NSObject <NSTableViewDataSource>
 {
     IBOutlet NSPanel *prefs_panel;
 
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index c75493c42..81ad3c639 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -868,13 +868,7 @@ extern char *bundle_id_prefix;
 
 - (IBAction) x11_help:sender
 {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-    AHLookupAnchor((CFStringRef)NSLocalizedString(@"Mac Help",
-                                                  no comment),
-                   CFSTR("mchlp2276"));
-#else
     AHLookupAnchor(CFSTR("com.apple.machelp"), CFSTR("mchlp2276"));
-#endif
 }
 
 - (OSX_BOOL) validateMenuItem:(NSMenuItem *)item
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 980aa4a36..8a3c5a2d3 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -72,12 +72,6 @@
 #include <rootlessCommon.h>
 #include <Xplugin.h>
 
-/* Work around a bug on Leopard's headers */
-#if defined (__LP64__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 && MAC_OS_X_VERSION_MAX_ALLOWED < 1060
-extern OSErr UpdateSystemActivity(UInt8 activity);
-#define OverallAct 0
-#endif
-
 DevPrivateKeyRec quartzScreenKeyRec;
 int aquaMenuBarHeight = 0;
 QuartzModeProcsPtr quartzProcs = NULL;
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index cb470fa8e..2e0c7b53d 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -66,154 +66,6 @@ static Bool ignore_next_fake_mode_update = FALSE;
 typedef int (*QuartzModeCallback)
     (ScreenPtr, QuartzModeInfoPtr, void *);
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-
-static long
-getDictLong(CFDictionaryRef dictRef, CFStringRef key)
-{
-    long value;
-
-    CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key);
-    if (!numRef)
-        return 0;
-
-    if (!CFNumberGetValue(numRef, kCFNumberLongType, &value))
-        return 0;
-    return value;
-}
-
-static double
-getDictDouble(CFDictionaryRef dictRef, CFStringRef key)
-{
-    double value;
-
-    CFNumberRef numRef = (CFNumberRef)CFDictionaryGetValue(dictRef, key);
-    if (!numRef)
-        return 0.0;
-
-    if (!CFNumberGetValue(numRef, kCFNumberDoubleType, &value))
-        return 0.0;
-    return value;
-}
-
-static void
-QuartzRandRGetModeInfo(CFDictionaryRef modeRef,
-                       QuartzModeInfoPtr pMode)
-{
-    pMode->width = (size_t)getDictLong(modeRef, kCGDisplayWidth);
-    pMode->height = (size_t)getDictLong(modeRef, kCGDisplayHeight);
-    pMode->refresh =
-        (int)(getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5);
-    if (pMode->refresh == 0)
-        pMode->refresh = DEFAULT_REFRESH;
-    pMode->ref = NULL;
-    pMode->pSize = NULL;
-}
-
-static Bool
-QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId,
-                               QuartzModeInfoPtr pMode)
-{
-    CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId);
-    if (!curModeRef)
-        return FALSE;
-
-    QuartzRandRGetModeInfo(curModeRef, pMode);
-    pMode->ref = (void *)curModeRef;
-    CFRetain(pMode->ref);
-    return TRUE;
-}
-
-static Bool
-QuartzRandRSetCGMode(CGDirectDisplayID screenId,
-                     QuartzModeInfoPtr pMode)
-{
-    CFDictionaryRef modeRef = (CFDictionaryRef)pMode->ref;
-    return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess);
-}
-
-static Bool
-QuartzRandREnumerateModes(ScreenPtr pScreen,
-                          QuartzModeCallback callback,
-                          void *data)
-{
-    Bool retval = FALSE;
-    QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
-    /* Just an 800x600 fallback if we have no attached heads */
-    if (pQuartzScreen->displayIDs) {
-        CFDictionaryRef curModeRef, modeRef;
-        long curBpp;
-        CFArrayRef modes;
-        QuartzModeInfo modeInfo;
-        int i;
-        CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
-
-        curModeRef = CGDisplayCurrentMode(screenId);
-        if (!curModeRef)
-            return FALSE;
-        curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
-
-        modes = CGDisplayAvailableModes(screenId);
-        if (!modes)
-            return FALSE;
-        for (i = 0; i < CFArrayGetCount(modes); i++) {
-            int cb;
-            modeRef = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i);
-
-            /* Skip modes that are not usable on the current display or have a
-               different pixel encoding than the current mode. */
-            if (((unsigned long)getDictLong(modeRef, kCGDisplayIOFlags) &
-                 kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
-                continue;
-            if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
-                continue;
-
-            QuartzRandRGetModeInfo(modeRef, &modeInfo);
-            modeInfo.ref = (void *)modeRef;
-            cb = callback(pScreen, &modeInfo, data);
-            if (cb == CALLBACK_CONTINUE)
-                retval = TRUE;
-            else if (cb == CALLBACK_SUCCESS)
-                return TRUE;
-            else if (cb == CALLBACK_ERROR)
-                return FALSE;
-        }
-    }
-
-    switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
-    case CALLBACK_SUCCESS:
-        return TRUE;
-
-    case CALLBACK_ERROR:
-        return FALSE;
-
-    case CALLBACK_CONTINUE:
-        retval = TRUE;
-
-    default:
-        break;
-    }
-
-    switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
-    case CALLBACK_SUCCESS:
-        return TRUE;
-
-    case CALLBACK_ERROR:
-        return FALSE;
-
-    case CALLBACK_CONTINUE:
-        retval = TRUE;
-
-    default:
-        break;
-    }
-
-    return retval;
-}
-
-#else /* we have the new CG APIs from Snow Leopard */
-
 static void
 QuartzRandRGetModeInfo(CGDisplayModeRef modeRef,
                        QuartzModeInfoPtr pMode)
@@ -350,8 +202,6 @@ QuartzRandREnumerateModes(ScreenPtr pScreen,
     return retval;
 }
 
-#endif  /* Snow Leopard CoreGraphics APIs */
-
 static Bool
 QuartzRandRModesEqual(QuartzModeInfoPtr pMode1,
                       QuartzModeInfoPtr pMode2)
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 74ea86b5c..f54870dd9 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -331,10 +331,6 @@ xprAddScreen(int index, ScreenPtr pScreen)
     DEBUG_LOG("index=%d depth=%d\n", index, depth);
 
     if (depth == -1) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-        depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
-                CGDisplayBitsPerSample(kCGDirectMainDisplay);
-#else
         CGDisplayModeRef modeRef;
         CFStringRef encStrRef;
 
@@ -364,12 +360,9 @@ xprAddScreen(int index, ScreenPtr pScreen)
         }
 
         CFRelease(encStrRef);
-#endif
     }
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 have_depth:
-#endif
     switch (depth) {
     case 8:     // pseudo-working
         dfb->visuals = PseudoColorMask;
commit 6e6db055f8b517ae9d63351d4c00fd480cb6b54a
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:18:35 2021 -0800

    xquartz: Remove support for Tiger and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index f7b139685..39544e953 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -85,11 +85,7 @@ static dispatch_queue_t eventTranslationQueue;
 extern Bool noTestExtensions;
 extern Bool noRenderExtension;
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
 static TISInputSourceRef last_key_layout;
-#else
-static KeyboardLayoutRef last_key_layout;
-#endif
 
 /* This preference is only tested on Lion or later as it's not relevant to
  * earlier OS versions.
@@ -1236,18 +1232,11 @@ X11ApplicationMain(int argc, char **argv, char **envp)
 #endif
 
     /* Set the key layout seed before we start the server */
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
     last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
 
     if (!last_key_layout)
         ErrorF(
             "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
-#else
-    KLGetCurrentKeyboardLayout(&last_key_layout);
-    if (!last_key_layout)
-        ErrorF(
-            "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
-#endif
 
     if (!QuartsResyncKeymap(FALSE)) {
         ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
@@ -1653,11 +1642,6 @@ handle_mouse:
 
     case NSScrollWheel:
     {
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
-        float deltaX = [e deltaX];
-        float deltaY = [e deltaY];
-        BOOL isContinuous = NO;
-#else
         CGFloat deltaX = [e deltaX];
         CGFloat deltaY = [e deltaY];
         CGEventRef cge = [e CGEvent];
@@ -1679,7 +1663,6 @@ handle_mouse:
             deltaY *= lineHeight / 5.0;
         }
 #endif
-#endif
         
 #if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
         /* If we're in the background, we need to send a MotionNotify event
@@ -1806,7 +1789,6 @@ handle_mouse:
     }
 
         if (darwinSyncKeymap) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
             TISInputSourceRef key_layout = 
                 TISCopyCurrentKeyboardLayoutInputSource();
             TISInputSourceRef clear;
@@ -1818,12 +1800,7 @@ handle_mouse:
                 clear = last_key_layout;
                 last_key_layout = key_layout;
                 CFRelease(clear);
-#else
-            KeyboardLayoutRef key_layout;
-            KLGetCurrentKeyboardLayout(&key_layout);
-            if (key_layout != last_key_layout) {
-                last_key_layout = key_layout;
-#endif
+
                 /* Update keyInfo */
                 if (!QuartsResyncKeymap(TRUE)) {
                     ErrorF(
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index c8b501831..84c7ce6d8 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -46,16 +46,6 @@
 #undef BOOL
 #endif
 
-#ifndef NSINTEGER_DEFINED
-#if __LP64__ || NS_BUILD_32_LIKE_64
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-#else
-typedef int NSInteger;
-typedef unsigned int NSUInteger;
-#endif
-#endif
-
 @interface X11Controller : NSObject
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     <NSTableViewDataSource>
diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index 8fdce4699..30d05ecc0 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -316,20 +316,6 @@ xq_asl_init(void)
     atexit(redirect_atexit);
 }
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
-#define fls(v) xq_fls(v)
-
-static inline int fls(int value) {
-    unsigned int b, v;
-
-    v = *((unsigned int *)&value);
-
-    for(b=0 ; v ; v >>= 1 , b++);
-
-    return b;
-}
-#endif
-
 int
 xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd)
 {
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 8cfe1e47d..8a68785c2 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -91,12 +91,8 @@ extern int noPanoramiXExtension;
 static char __crashreporter_info_buff__[4096] = { 0 };
 static const char *__crashreporter_info__ __attribute__((__used__)) =
     &__crashreporter_info_buff__[0];
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-// This is actually a toolchain requirement, but I'm not sure the correct check,
-// but it should be fine to just only include it for Leopard and later.  This line
-// just tells the linker to never strip this symbol (such as for space optimization)
+// This line just tells the linker to never strip this symbol (such as for space optimization)
 asm (".desc ___crashreporter_info__, 0x10");
-#endif
 
 static const char *__crashreporter_info__base =
     "X.Org X Server " XSERVER_VERSION;
@@ -477,14 +473,9 @@ startup_trigger(int argc, char **argv, char **envp)
 
         kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
         if (kr != KERN_SUCCESS) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
             ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name,
                    bootstrap_strerror(
                        kr));
-#else
-            ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name,
-                   (unsigned long)kr);
-#endif
             exit(EXIT_FAILURE);
         }
 
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 756e4ef2d..fad7ea76d 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -61,8 +61,6 @@ aslclient aslc;
 static void
 set_x11_path(void)
 {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-
     CFURLRef appURL = NULL;
     OSStatus osstatus =
         LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(
@@ -104,11 +102,6 @@ set_x11_path(void)
                 (int)osstatus);
         exit(11);
     }
-#else
-    /* TODO: Make Tiger smarter... but TBH, this should never get called on Tiger... */
-    strlcpy(x11_path, "/Applications/Utilities/X11.app/Contents/MacOS/X11",
-            sizeof(x11_path));
-#endif
 }
 
 static int
@@ -291,15 +284,9 @@ main(int argc, char **argv, char **envp)
         }
 
         if (kr != KERN_SUCCESS) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
             asl_log(aslc, NULL, ASL_LEVEL_ERR,
                     "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(
                         kr));
-#else
-            asl_log(aslc, NULL, ASL_LEVEL_ERR,
-                    "Xquartz: bootstrap_look_up(): %ul",
-                    (unsigned long)kr);
-#endif
             return EXIT_FAILURE;
         }
     }
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index c5a07f2d0..1b94097b7 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -36,15 +36,6 @@
 #include <asl.h>
 
 #include <AvailabilityMacros.h>
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
-#if __LP64__ || NS_BUILD_32_LIKE_64
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-#else
-typedef int NSInteger;
-typedef unsigned int NSUInteger;
-#endif
-#endif
 
 #define  Cursor X_Cursor
 #undef _SHAPE_H_
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index bb99e8cd0..cd1f96550 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -733,7 +733,7 @@ DarwinModifierStringToNXMask(const char *str, int separatelr)
     return 0;
 }
 
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#if !defined(__LP64__)
 static inline UniChar
 macroman2ucs(unsigned char c)
 {
@@ -795,7 +795,7 @@ make_dead_key(KeySym in)
 static Bool
 QuartzReadSystemKeymap(darwinKeyboardInfo *info)
 {
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#if !defined(__LP64__)
     KeyboardLayoutRef key_layout;
     int is_uchr = 1;
 #endif
@@ -807,7 +807,6 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
     KeySym *k;
     CFDataRef currentKeyLayoutDataRef = NULL;
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
     TISInputSourceRef currentKeyLayoutRef =
         TISCopyCurrentKeyboardLayoutInputSource();
 
@@ -817,33 +816,28 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
         if (currentKeyLayoutDataRef)
             chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
     }
-#endif
 
 #ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
 #endif
 
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#if !defined(__LP64__)
     if (chr_data == NULL) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
         ErrorF(
             "X11.app: Error detected in determining keyboard layout.  If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
         ErrorF(
             "X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
             (unsigned)keyboard_type, currentKeyLayoutRef,
             currentKeyLayoutDataRef, chr_data);
-#endif
 
         KLGetCurrentKeyboardLayout(&key_layout);
         KLGetKeyboardLayoutProperty(key_layout, kKLuchrData, &chr_data);
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
         if (chr_data != NULL) {
             ErrorF(
                 "X11.app: Fallback succeeded, but this is still a bug.  Please report the above information.\n");
         }
-#endif
     }
 
     if (chr_data == NULL) {
@@ -855,12 +849,10 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
         is_uchr = 0;
         num_keycodes = 128;
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
         if (chr_data != NULL) {
             ErrorF(
                 "X11.app: Fallback succeeded, but this is still a bug.  Please report the above information.\n");
         }
-#endif
     }
 #endif
 
@@ -868,10 +860,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
 #pragma clang diagnostic pop
 #endif
 
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
     if (currentKeyLayoutRef)
         CFRelease(currentKeyLayoutRef);
-#endif
 
     if (chr_data == NULL) {
         ErrorF("Couldn't get uchr or kchr resource\n");
@@ -895,7 +885,7 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
         k = info->keyMap + i * GLYPHS_PER_KEY;
 
         for (j = 0; j < 4; j++) {
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#if !defined(__LP64__)
             if (is_uchr) {
 #endif
             UniChar s[8];
@@ -924,7 +914,7 @@ QuartzReadSystemKeymap(darwinKeyboardInfo *info)
                 k[j] = ucs2keysym(s[0]);
                 if (dead_key_state != 0) k[j] = make_dead_key(k[j]);
             }
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#if !defined(__LP64__)
         }
         else {       // kchr
             UInt32 c, state = 0, state2 = 0;
commit 20b86c4060c1d4fbc099675d5100fe17e4ac0147
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:12:34 2021 -0800

    os: Remove support for Tiger and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/os/log.c b/os/log.c
index 456f05c32..4bd6b7e9a 100644
--- a/os/log.c
+++ b/os/log.c
@@ -128,19 +128,12 @@ static int bufferSize = 0, bufferUnused = 0, bufferPos = 0;
 static Bool needBuffer = TRUE;
 
 #ifdef __APPLE__
-#include <AvailabilityMacros.h>
-
 static char __crashreporter_info_buff__[4096] = { 0 };
 
 static const char *__crashreporter_info__ __attribute__ ((__used__)) =
     &__crashreporter_info_buff__[0];
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-// This is actually a toolchain requirement, but I'm not sure the correct check,
-// but it should be fine to just only include it for Leopard and later.  This line
-// just tells the linker to never strip this symbol (such as for space optimization)
 asm(".desc ___crashreporter_info__, 0x10");
 #endif
-#endif
 
 /* Prefix strings for log messages. */
 #ifndef X_UNKNOWN_STRING
commit 74aef85bd88a1fdb22d445ad14975232a7bebdd7
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jan 27 13:25:54 2021 -0800

    xquartz: Remove support for Panther and earlier versions of macOS
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 565d94f5f..67ea6a006 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -216,12 +216,10 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
     if (pDRIDrawablePriv->sid == 0)
         return;
 
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
     wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
                 : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
     if (wc.depth != XP_DEPTH_NIL)
         flags |= XP_DEPTH;
-#endif
 
     if (pDraw->type == DRAWABLE_WINDOW) {
         WindowPtr pWin = (WindowPtr)pDraw;
@@ -382,17 +380,13 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
 
         if (NULL == pDRIDrawablePriv)
             return FALSE;  /*error*/
-    }
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
-    else if (pDrawable->type == DRAWABLE_PIXMAP) {
+    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
         pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
                                                   (PixmapPtr)pDrawable);
 
         if (NULL == pDRIDrawablePriv)
             return FALSE;  /*error*/
-    }
-#endif
-    else {
+    } else {
         /* We handle GLXPbuffers in a different way (via CGL). */
         return FALSE;
     }
commit 0e272ac458fbd530787273073473e566b0ac306e
Author: Jim DeLaHunt <from.github at jdlh.com>
Date:   Mon Dec 11 00:08:52 2017 -0800

    Fix typo "XQaurtz" in Xquartz.man

diff --git a/hw/xquartz/man/Xquartz.man b/hw/xquartz/man/Xquartz.man
index 14aa872c0..643bea9df 100644
--- a/hw/xquartz/man/Xquartz.man
+++ b/hw/xquartz/man/Xquartz.man
@@ -120,7 +120,7 @@ or you can include extra information such as the file, line, and function where
 .TP 8
 .B $ syslog -w -F '$(Time) $(Sender) <$(Level)> $(File):$(Line) $(Function) :: $(Message)' -k Facility eq @bundle_id_prefix@
 .PP
-By default, XQaurtz sets an ASL mask which prevents it from logging messages
+By default, XQuartz sets an ASL mask which prevents it from logging messages
 below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly
 to the file referenced above).  To force XQuartz to send all log messages to
 syslogd(8), you can adjust this mask using the following syslog(1) command:


More information about the xorg-commit mailing list