xserver: Branch 'server-1.18-branch' - 15 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 14 05:09:50 UTC 2022


 Xext/shm.c                     |    3 
 dix/devices.c                  |   37 +++++++---
 glx/glxext.c                   |   21 ------
 hw/xquartz/X11Application.h    |    3 
 hw/xquartz/X11Application.m    |  141 +++++++++++++++++++++++++----------------
 hw/xquartz/darwin.c            |    1 
 hw/xquartz/man/Xquartz.man     |    2 
 hw/xquartz/pbproxy/Makefile.am |    5 -
 hw/xquartz/pbproxy/app-main.m  |    3 
 hw/xquartz/pbproxy/main.m      |   18 -----
 hw/xquartz/quartzStartup.c     |    9 ++
 hw/xquartz/xpr/driWrap.c       |    2 
 os/connection.c                |   31 +++++++--
 randr/randr.c                  |    3 
 14 files changed, 155 insertions(+), 124 deletions(-)

New commits:
commit 243c2d76fbf4cb28f328c7c83e3aa6f8f85de204
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Fri Mar 5 22:57:24 2021 -0800

    xquartz: Fix appFlags build failure with macOS 10.15+ SDKs
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit e59848548a462f1a0ac751bb8bb6afe56258cf4e)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index e826d97da..3d3725e9a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -82,6 +82,10 @@ static dispatch_queue_t eventTranslationQueue;
 #endif
 #endif
 
+#ifndef APPKIT_APPFLAGS_HACK
+#define APPKIT_APPFLAGS_HACK 1
+#endif
+
 extern Bool noTestExtensions;
 extern Bool noRenderExtension;
 
@@ -111,6 +115,50 @@ CFStringRef app_prefs_domain_cfstr = NULL;
 #define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | \
                        NSAlternateKeyMask | NSCommandKeyMask)
 
+#if APPKIT_APPFLAGS_HACK && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
+// This was removed from the SDK in 10.15
+ at interface NSApplication () {
+ at protected
+    /* All instance variables are private */
+    short               _running;
+    struct __appFlags {
+        unsigned int        _hidden:1;
+        unsigned int        _appleEventActivationInProgress:1;
+        unsigned int        _active:1;
+        unsigned int        _hasBeenRun:1;
+        unsigned int        _doingUnhide:1;
+        unsigned int        _delegateReturnsValidRequestor:1;
+        unsigned int        _deactPending:1;
+        unsigned int        _invalidState:1;
+        unsigned int        _invalidEvent:1;
+        unsigned int        _postedWindowsNeedUpdateNote:1;
+        unsigned int        _wantsToActivate:1;
+        unsigned int        _doingHide:1;
+        unsigned int        _dontSendShouldTerminate:1;
+        unsigned int        _ignoresFullScreen:1;
+        unsigned int        _finishedLaunching:1;
+        unsigned int        _hasEventDelegate:1;
+        unsigned int        _appTerminating:1;
+        unsigned int        _didNSOpenOrPrint:1;
+        unsigned int        _inDealloc:1;
+        unsigned int        _pendingDidFinish:1;
+        unsigned int        _hasKeyFocus:1;
+        unsigned int        _panelsNonactivating:1;
+        unsigned int        _hiddenOnLaunch:1;
+        unsigned int        _openStatus:2;
+        unsigned int        _batchOrdering:1;
+        unsigned int        _waitingForTerminationReply:1;
+        unsigned int        _unused:1;
+        unsigned int        _enumeratingMemoryPressureHandlers:1;
+        unsigned int        _didTryRestoringPersistentState:1;
+        unsigned int        _windowDragging:1;
+        unsigned int        _mightBeSwitching:1;
+    }                   _appFlags;
+    id                  _mainMenu;
+}
+ at end
+#endif
+
 @interface NSApplication (Internal)
 - (void)_setKeyWindow:(id)window;
 - (void)_setMainWindow:(id)window;
@@ -430,10 +478,12 @@ message_kit_thread(SEL selector, NSObject *arg)
                 BOOL order_all_windows = YES, workspaces, ok;
                 for_appkit = NO;
 
+#if APPKIT_APPFLAGS_HACK
                 /* FIXME: This is a hack to avoid passing the event to AppKit which
                  *        would result in it raising one of its windows.
                  */
                 _appFlags._active = YES;
+#endif
 
                 [self set_front_process:nil];
 
commit 15b99dc4a1db379e22b63858160919a07d2dee8c
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat Feb 20 15:17:18 2021 -0800

    xquartz: Fix a compiler warning about const incompatible pointer assignment
    
    driWrap.c:541:30: error: assigning to 'GCOps *' (aka 'struct _GCOps *') from 'const GCOps *' (aka 'const struct _GCOps *') discards
          qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
            pGCPriv->originalOps = pGC->ops;
                                 ^ ~~~~~~~~
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 6a83fb51b7a8b2e167e7d6380229b69e5452f91f)

diff --git a/hw/xquartz/xpr/driWrap.c b/hw/xquartz/xpr/driWrap.c
index 42282d52b..f588a834d 100644
--- a/hw/xquartz/xpr/driWrap.c
+++ b/hw/xquartz/xpr/driWrap.c
@@ -45,7 +45,7 @@
 #include <OpenGL/OpenGL.h>
 
 typedef struct {
-    GCOps *originalOps;
+    GCOps const *originalOps;
 } DRIGCRec;
 
 typedef struct {
commit 06e37990fe004d51b57e053d8980e99284dfb64a
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Thu Feb 18 12:43:53 2021 -0800

    xquartz: Silence a compiler warning about missing internal methods on NSApplication
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 279bcbd9cf9e557a6789d6e4cede8e8799c3788e)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index dce8c288c..e826d97da 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -111,6 +111,11 @@ CFStringRef app_prefs_domain_cfstr = NULL;
 #define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | \
                        NSAlternateKeyMask | NSCommandKeyMask)
 
+ at interface NSApplication (Internal)
+- (void)_setKeyWindow:(id)window;
+- (void)_setMainWindow:(id)window;
+ at end
+
 @interface X11Application (Private)
 - (void) sendX11NSEvent:(NSEvent *)e;
 @end
commit f20142534e5745c7c213e1ff43e3c8dff528902c
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Tue Jul 18 21:35:49 2017 -0700

    XQuartz: Hack around an issue that can occur on macOS due to background apps incorrectly stealing focus
    
    Works around <rdar://problem/7150340>.
    
    Tested-by: Martin Otte <martinjotte at gmail.com>
    Tested-by: Tom Lane <tgl at sss.pgh.pa.us>
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit dd0b721c977e88d7c3830cc2a672c2793bca4fa0)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 19e9451f7..dce8c288c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -275,13 +275,32 @@ message_kit_thread(SEL selector, NSObject *arg)
             if (_x_active) [self activateX:NO];
         }
         else if ([self modalWindow] == nil) {
-            /* Must be an X window. Tell appkit it doesn't have focus. */
+            /* Must be an X window. Tell appkit windows to resign main/key */
             for_appkit = NO;
 
-            if ([self isActive]) {
-                [self deactivate];
-                if (!_x_active && quartzProcs->IsX11Window([e windowNumber]))
-                    [self activateX:YES];
+            if (!_x_active && quartzProcs->IsX11Window([e windowNumber])) {
+                if ([self respondsToSelector:@selector(_setKeyWindow:)] && [self respondsToSelector:@selector(_setMainWindow:)]) {
+                    NSWindow *keyWindow = [self keyWindow];
+                    if (keyWindow) {
+                        [self _setKeyWindow:nil];
+                        [keyWindow resignKeyWindow];
+                    }
+
+                    NSWindow *mainWindow = [self mainWindow];
+                    if (mainWindow) {
+                        [self _setMainWindow:nil];
+                        [mainWindow resignMainWindow];
+                   }
+                 } else {
+                    /* This has a side effect of causing background apps to steal focus from XQuartz.
+                     * Unfortunately, there is no public and stable API to do what we want, but this
+                     * is a decent fallback in the off chance that the above selectors get dropped
+                     * in the future.
+                     */
+                    [self deactivate];
+                }
+
+                [self activateX:YES];
             }
         }
 
commit f724cbf61105eb9c2bf721c1dbd06414ed7f9913
Author: Jim DeLaHunt <from.github at jdlh.com>
Date:   Mon Dec 11 00:08:52 2017 -0800

    Fix typo "XQaurtz" in Xquartz.man
    
    (cherry picked from commit 039d68238de67af9db46b6dbc919955a1c6a0467)

diff --git a/hw/xquartz/man/Xquartz.man b/hw/xquartz/man/Xquartz.man
index 0ea6e6eb8..74f0e36a0 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:
commit 7e7480ff47dc0789d224f2074f8478ec027008af
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 11 02:47:00 2016 -0700

    glx: Initialize glx even if there are currently no screens attached
    
    Failure to do so causes an overvlow in glxClientCallback
    
    Application Specific Information:
    X.Org X Server 1.18.99.1 Build Date: 20160911
    =================================================================
    ==52118==ERROR: AddressSanitizer: SEGV on unknown address 0x000102b27b80 (pc 0x000103433245 bp 0x70000de67c20 sp 0x70000de67c00 T6)
        #0 0x103433244 in __asan::asan_free(void*, __sanitizer::BufferedStackTrace*, __asan::AllocType) (libclang_rt.asan_osx_dynamic.dylib+0x3244)
        #1 0x10347aeee in wrap_free (libclang_rt.asan_osx_dynamic.dylib+0x4aeee)
        #2 0x102e6a5ed in glxClientCallback glxext.c:301
        #3 0x102b672a3 in _CallCallbacks dixutils.c:737
        #4 0x102b2f0c6 in CallCallbacks callback.h:83
        #5 0x102b5c15a in NextAvailableClient dispatch.c:3562
        #6 0x102d7060c in AllocNewConnection connection.c:777
        #7 0x102d71355 in EstablishNewConnections connection.c:863
        #8 0x102b662f0 in ProcessWorkQueue dixutils.c:523
        #9 0x102d52a7f in WaitForSomething WaitFor.c:175
        #10 0x102b204f6 in Dispatch dispatch.c:411
        #11 0x102b61e01 in dix_main main.c:301
        #12 0x10254c42a in server_thread quartzStartup.c:66
        #13 0x7fffc5f16aaa in _pthread_body (libsystem_pthread.dylib+0x3aaa)
        #14 0x7fffc5f169f6 in _pthread_start (libsystem_pthread.dylib+0x39f6)
        #15 0x7fffc5f161fc in thread_start (libsystem_pthread.dylib+0x31fc)
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 42a41fabd58ec5c572c7affd095ee15f57883a0d)

diff --git a/glx/glxext.c b/glx/glxext.c
index c201fba86..0ce8faa76 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -320,23 +320,6 @@ GlxPushProvider(__GLXprovider * provider)
     __glXProviderStack = provider;
 }
 
-static Bool
-checkScreenVisuals(void)
-{
-    int i, j;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        ScreenPtr screen = screenInfo.screens[i];
-        for (j = 0; j < screen->numVisuals; j++) {
-            if (screen->visuals[j].class == TrueColor ||
-                screen->visuals[j].class == DirectColor)
-                return True;
-        }
-    }
-
-    return False;
-}
-
 /*
 ** Initialize the GLX extension.
 */
@@ -355,10 +338,6 @@ GlxExtensionInit(void)
         *stack = &__glXDRISWRastProvider;
     }
 
-    /* Mesa requires at least one True/DirectColor visual */
-    if (!checkScreenVisuals())
-        return;
-
     __glXContextRes = CreateNewResourceType((DeleteType) ContextGone,
                                             "GLXContext");
     __glXDrawableRes = CreateNewResourceType((DeleteType) DrawableGone,
commit 6f13c13ed69078d4ed33cfb53b804b04c2cb702d
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 11 02:19:19 2016 -0700

    randr: Initialize RandR even if there are currently no screens attached
    
    Failure to do so causes an overvlow in RRClientCallback().
    
    =================================================================
    ==41262==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000103ccfbc8 at pc 0x0001034f32b9 bp 0x7000035a94c0 sp 0x7000035a94b8
    WRITE of size 4 at 0x000103ccfbc8 thread T6
        #0 0x1034f32b8 in RRClientCallback randr.c:72
        #1 0x1038c75e3 in _CallCallbacks dixutils.c:737
        #2 0x10388f406 in CallCallbacks callback.h:83
        #3 0x1038bc49a in NextAvailableClient dispatch.c:3562
        #4 0x103ad094c in AllocNewConnection connection.c:777
        #5 0x103ad1695 in EstablishNewConnections connection.c:863
        #6 0x1038c6630 in ProcessWorkQueue dixutils.c:523
        #7 0x103ab2dbf in WaitForSomething WaitFor.c:175
        #8 0x103880836 in Dispatch dispatch.c:411
        #9 0x1038c2141 in dix_main main.c:301
        #10 0x1032ac75a in server_thread quartzStartup.c:66
        #11 0x7fffc5f16aaa in _pthread_body (libsystem_pthread.dylib+0x3aaa)
        #12 0x7fffc5f169f6 in _pthread_start (libsystem_pthread.dylib+0x39f6)
        #13 0x7fffc5f161fc in thread_start (libsystem_pthread.dylib+0x31fc)
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 7d901d6ecc179020e213664da475ae9e2888ea1d)

diff --git a/randr/randr.c b/randr/randr.c
index ad1dda227..51aaa1938 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -387,9 +387,6 @@ RRExtensionInit(void)
 {
     ExtensionEntry *extEntry;
 
-    if (RRNScreens == 0)
-        return;
-
     if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT,
                                sizeof(RRClientRec) +
                                screenInfo.numScreens * sizeof(RRTimesRec)))
commit c464bd531d00b531e025ff81549aa58f84f398cd
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat Sep 10 22:32:56 2016 -0700

    os/connection: Improve abstraction for launchd secure sockets
    
    This changes away from hard-coding the /tmp/launch-* path to now
    supporting a generic <absolute path to unix socket>[.<screen>]
    format for $DISPLAY.
    
    cf-libxcb: d978a4f69b30b630f28d07f1003cf290284d24d8
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    CC: Adam Jackson <ajax at kemper.freedesktop.org>
    (cherry picked from commit bf2bb516a584937cd45728fdb6e21bc84dce365a)

diff --git a/os/connection.c b/os/connection.c
index 9c41c7cf3..c852d12a4 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -79,6 +79,8 @@ SOFTWARE.
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <sys/stat.h>
+
 #ifndef WIN32
 #include <sys/socket.h>
 
@@ -1267,15 +1269,34 @@ MakeClientGrabPervious(ClientPtr client)
 void
 ListenOnOpenFD(int fd, int noxauth)
 {
-    char port[256];
+    char port[PATH_MAX];
     XtransConnInfo ciptr;
     const char *display_env = getenv("DISPLAY");
 
-    if (display_env && (strncmp(display_env, "/tmp/launch", 11) == 0)) {
-        /* Make the path the launchd socket if our DISPLAY is set right */
-        strcpy(port, display_env);
+    /* First check if display_env matches a <absolute path to unix socket>[.<screen number>] scheme (eg: launchd) */
+    if (display_env && display_env[0] == '/') {
+        struct stat sbuf;
+
+        strlcpy(port, display_env, sizeof(port));
+
+        /* If the path exists, we don't have do do anything else.
+         * If it doesn't, we need to check for a .<screen number> to strip off and recheck.
+         */
+        if (0 != stat(port, &sbuf)) {
+            char *dot = strrchr(port, '.');
+            if (dot) {
+                *dot = '\0';
+
+                if (0 != stat(port, &sbuf)) {
+                    display_env = NULL;
+                }
+            } else {
+                display_env = NULL;
+            }
+        }
     }
-    else {
+
+    if (!display_env) {
         /* Just some default so things don't break and die. */
         snprintf(port, sizeof(port), ":%d", atoi(display));
     }
commit 2490a6fbbe32ac6786056e4d9c1cf35edda17772
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 18 23:17:19 2016 -0700

    XQuartz: pbproxy shouldn't need to wait for server initialization.
    
    Just block on the socket like every other client does.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 8bc4727f475321a8adcbbd859f3f8dd9eeb64aa4)

diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 37b578223..eda9a9e67 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -40,9 +40,6 @@ CFStringRef app_prefs_domain_cfstr;
 
 /* Stubs */
 char *display = NULL;
-BOOL serverRunning = YES;
-pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
 
 static void
 signal_handler(int sig)
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index abedb0839..2d2f76108 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -48,22 +48,6 @@ BOOL xpbproxy_is_standalone = NO;
 
 x_selection *_selection_object;
 
-extern BOOL serverRunning;
-extern pthread_mutex_t serverRunningMutex;
-extern pthread_cond_t serverRunningCond;
-
-static inline void
-wait_for_server_init(void)
-{
-    /* If the server hasn't finished initializing, wait for it... */
-    if (!serverRunning) {
-        pthread_mutex_lock(&serverRunningMutex);
-        while (!serverRunning)
-            pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
-        pthread_mutex_unlock(&serverRunningMutex);
-    }
-}
-
 static int
 x_io_error_handler(Display *dpy)
 {
@@ -97,8 +81,6 @@ xpbproxy_run(void)
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     size_t i;
 
-    wait_for_server_init();
-
     for (i = 0, xpbproxy_dpy = NULL; !xpbproxy_dpy && i < 5; i++) {
         xpbproxy_dpy = XOpenDisplay(NULL);
 
commit cde13c2f07464cf94fb072c7072009ef30102960
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 18 23:13:20 2016 -0700

    XQuartz: Remove X11ApplicationFatalError
    
    AppKit handles crashes on app launch with their own dialog now, so we shouldn't need to do this ourselves.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 81493d30981d7deb38f57bca2a35487add5ea509)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 87cba6dec..740a8070a 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -86,9 +86,6 @@ X11ApplicationLaunchClient(const char *cmd);
 Bool
 X11ApplicationCanEnterRandR(void);
 
-void
-X11ApplicationFatalError(const char *f, va_list args) __printflike(1, 0);
-
 void
 X11ApplicationMain(int argc, char **argv, char **envp);
 
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 9a2290990..19e9451f7 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -84,7 +84,6 @@ static dispatch_queue_t eventTranslationQueue;
 
 extern Bool noTestExtensions;
 extern Bool noRenderExtension;
-extern BOOL serverRunning;
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
 static TISInputSourceRef last_key_layout;
@@ -1096,53 +1095,6 @@ X11ApplicationCanEnterRandR(void)
     }
 }
 
-void
-X11ApplicationFatalError(const char *f, va_list args)
-{
-#ifdef HAVE_LIBDISPATCH
-    NSString *title, *msg;
-    char *error_msg;
-
-    /* This is called by FatalError() in the server thread just before
-     * we would abort.  If the server never got off the ground, We should
-     * inform the user of the error rather than letting the ever-so-friendly
-     * CrashReporter do it for us.
-     *
-     * This also has the benefit of forcing user interaction rather than
-     * allowing an infinite throttled-restart if the crash occurs before
-     * we can drain the launchd socket.
-     */
-
-    if (serverRunning) {
-        return;
-    }
-
-    title = NSLocalizedString(@"The application X11 could not be opened.",
-                              @"Dialog title when encountering a fatal error");
-    msg = NSLocalizedString(
-        @"An error occurred while starting the X11 server: \"%s\"\n\nClick Quit to quit X11. Click Report to see more details or send a report to Apple.",
-        @"Dialog when encountering a fatal error");
-
-    vasprintf(&error_msg, f, args);
-    msg = [NSString stringWithFormat:msg, error_msg];
-
-    /* We want the AppKit thread to actually service the alert or we will race [NSApp run] and create an
-     * 'NSInternalInconsistencyException', reason: 'NSApp with wrong _running count'
-     */
-    dispatch_sync(dispatch_get_main_queue(), ^{
-                      if (NSAlertDefaultReturn ==
-                          NSRunAlertPanel (title, @"%@",
-                                           NSLocalizedString (@"Quit", @""),
-                                           NSLocalizedString (@"Report...", @""),
-                                           nil, msg)) {
-                          exit (EXIT_FAILURE);
-                      }
-                  });
-
-    /* fall back to caller to do the abort() in the DIX */
-#endif
-}
-
 static void
 check_xinitrc(void)
 {
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 340343672..97fe7e90e 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -675,7 +675,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 void
 OsVendorFatalError(const char *f, va_list args)
 {
-    X11ApplicationFatalError(f, args);
 }
 
 /*
commit 3acb9d7ee2f4819c7ef28d6a9b529b1d44f24101
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 18 22:45:16 2016 -0700

    XQuartz: Don't respond to SIGALRM on the AppKit thread
    
    ==================
    WARNING: ThreadSanitizer: data race (pid=69627)
      Write of size 8 at 0x00010dae73f8 by main thread (mutexes: write M262):
        #0 SmartScheduleTimer utils.c:1245 (X11.bin+0x0001004b21f9)
        #1 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, bool, int, my_siginfo_t*, void*) <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000279f6)
        #2 __CFRunLoopRun <null>:77 (CoreFoundation+0x000000087e17)
        #3 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062)
        #4 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b)
        #5 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5)
        #6 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9)
        #7 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44)
        #8 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
        #9 start <null>:29 (libdyld.dylib+0x000000005254)
    
      Previous read of size 8 at 0x00010dae73f8 by thread T7:
        [failed to restore the stack]
    
      Location is global 'SmartScheduleTime' at 0x00010dae73f8 (X11.bin+0x0001005b03f8)
    
      Mutex M262 (0x7d300000bd10) created at:
        #0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3)
        #1 __CFRunLoopCreate <null>:77 (CoreFoundation+0x000000054e63)
        #2 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062)
        #3 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b)
        #4 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5)
        #5 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9)
        #6 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44)
        #7 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
        #8 start <null>:29 (libdyld.dylib+0x000000005254)
    
      Thread T7 (tid=4051693, running) created by main thread at:
        #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490)
        #1 create_thread quartzStartup.c:78 (X11.bin+0x0001000398dd)
        #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039813)
        #3 X11ApplicationMain X11Application.m:1286 (X11.bin+0x00010001c804)
        #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062)
        #5 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b)
        #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5)
        #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9)
        #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44)
        #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
        #10 start <null>:29 (libdyld.dylib+0x000000005254)
    
    SUMMARY: ThreadSanitizer: data race utils.c:1245 in SmartScheduleTimer
    ==================
    ==================
    WARNING: ThreadSanitizer: signal handler spoils errno (pid=69627)
        #0 SmartScheduleTimer utils.c:1244 (X11.bin+0x0001004b21a0)
        #1 __CFRunLoopRun <null>:77 (CoreFoundation+0x000000087e17)
        #2 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062)
        #3 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b)
        #4 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5)
        #5 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9)
        #6 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44)
        #7 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186)
        #8 start <null>:29 (libdyld.dylib+0x000000005254)
    
    SUMMARY: ThreadSanitizer: signal handler spoils errno utils.c:1244 in SmartScheduleTimer
    ==================
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 9153ec8464336c280f2a6e79ffa443104bbeb98c)

diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 4dc4dd630..bb92b6d3c 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -95,6 +95,15 @@ QuartzInitServer(int argc, char **argv, char **envp)
     if (!create_thread(server_thread, args)) {
         FatalError("can't create secondary thread\n");
     }
+
+    /* Block signals on the AppKit thread that the X11 expects to handle on its thread */
+    sigset_t set;
+    sigemptyset(&set);
+    sigaddset(&set, SIGALRM);
+#ifdef BUSFAULT
+    sigaddset(&set, SIGBUS);
+#endif
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
 }
 
 int
commit cf04dc3cb03f5b7eea9820ea2facca399ed4d6dc
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Mon Sep 19 01:13:02 2016 -0700

    dix: Make InitCoreDevices() failures more verbose.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit d0c5d205a919fc1d2eb599356090b58b1bf0176d)

diff --git a/dix/devices.c b/dix/devices.c
index a532dcfaa..8a93b3898 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -702,17 +702,32 @@ CorePointerProc(DeviceIntPtr pDev, int what)
 void
 InitCoreDevices(void)
 {
-    if (AllocDevicePair(serverClient, "Virtual core",
-                        &inputInfo.pointer, &inputInfo.keyboard,
-                        CorePointerProc, CoreKeyboardProc, TRUE) != Success)
-         FatalError("Failed to allocate core devices");
-
-    if (ActivateDevice(inputInfo.pointer, TRUE) != Success ||
-        ActivateDevice(inputInfo.keyboard, TRUE) != Success)
-         FatalError("Failed to activate core devices.");
-    if (!EnableDevice(inputInfo.pointer, TRUE) ||
-        !EnableDevice(inputInfo.keyboard, TRUE))
-         FatalError("Failed to enable core devices.");
+    int result;
+
+    result = AllocDevicePair(serverClient, "Virtual core",
+                             &inputInfo.pointer, &inputInfo.keyboard,
+                             CorePointerProc, CoreKeyboardProc, TRUE);
+    if (result != Success) {
+        FatalError("Failed to allocate virtual core devices: %d", result);
+    }
+
+    result = ActivateDevice(inputInfo.pointer, TRUE);
+    if (result != Success) {
+        FatalError("Failed to activate virtual core pointer: %d", result);
+    }
+
+    result = ActivateDevice(inputInfo.keyboard, TRUE);
+    if (result != Success) {
+        FatalError("Failed to activate virtual core keyboard: %d", result);
+    }
+
+    if (!EnableDevice(inputInfo.pointer, TRUE)) {
+         FatalError("Failed to enable virtual core pointer.");
+    }
+
+    if (!EnableDevice(inputInfo.keyboard, TRUE)) {
+         FatalError("Failed to enable virtual core keyboard.");
+    }
 
     InitXTestDevices();
 }
commit 0d573b03e0f32aec94b6cb49d4a1dffe0b548c73
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 11 19:47:47 2016 -0700

    Xext/shm: Fix usage of F_GETFD to match standard
    
    flags = fcntl(fd, F_GETFD) is compliant.
    
    fcntl(fd, F_GETFD, &flags) is non-compliant (Linux extension?)
    
    cf: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    (cherry picked from commit a5769de0f5399053e9864b753fa9755220d65ae0)

diff --git a/Xext/shm.c b/Xext/shm.c
index 2a3448dbc..fd99b943d 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1214,7 +1214,8 @@ shm_tmpfile(void)
 	if (fd < 0)
 		return -1;
 	unlink(template);
-	if (fcntl(fd, F_GETFD, &flags) >= 0) {
+	flags = fcntl(fd, F_GETFD);
+	if (flags != -1) {
 		flags |= FD_CLOEXEC;
 		(void) fcntl(fd, F_SETFD, &flags);
 	}
commit 07a9841c037f4db2e284225e80951e8dc1578952
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat Sep 10 22:16:11 2016 -0700

    XQuartz: Cleanup CPPFLAGS that are no longer necessary on darwin
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 4f4ecd0f41cf1c710d3ef1626b747847e6184f4c)

diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index 1b14dffce..9429ea25d 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -1,7 +1,6 @@
-AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \
-	-DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\"
+AM_CPPFLAGS=-DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\"
 
-AM_CFLAGS=$(XPBPROXY_CFLAGS) 
+AM_CFLAGS=$(XPBPROXY_CFLAGS)
 AM_OBJCFLAGS=$(XPBPROXY_CFLAGS)
 
 noinst_LTLIBRARIES = libxpbproxy.la
commit fe53d94239adc8c302757fd8204a5b2c0c5a9850
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun May 29 14:01:38 2016 -0700

    XQuartz: Fix the issue where the h key could be come "stuck" after hiding XQuartz with cmd-h
    
    The issue was that we set a flag to ignore the k key's up event when sent
    the cmd-h down event, but because the cmd-h keycode hides XQuartz, we
    became !_x_active by the time the event is delivered which caused us to
    go down a differnet codepath rather than getting a chance to ignore it.
    We then incorrectly ignored the next h up key.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=92648
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 33d595255d4206df0d136014de33100817cbe344)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index d2c5d3083..9a2290990 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -366,6 +366,15 @@ message_kit_thread(SEL selector, NSObject *arg)
                 else {
                     /* No kit window is focused, so send it to X. */
                     for_appkit = NO;
+
+                    /* Reset our swallow state if we're seeing the same keyCode again.
+                     * This can happen if we become !_x_active when the keyCode we
+                     * intended to swallow is delivered.  See:
+                     * https://bugs.freedesktop.org/show_bug.cgi?id=92648
+                     */
+                    if ([e keyCode] == swallow_keycode) {
+                        do_swallow = NO;
+                    }
                 }
             }
             else {       /* KeyUp */


More information about the xorg-commit mailing list