Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / x11 / xorg / darwin / stub.patch
blob0005c3568dff9920e3f7ac64c572c802b04f29cb
1 When the X / Xquartz server initializes, it starts the XQuartz.app and
2 hands-off the display FD. To start the XQuartz.app, Xquartz normally uses some
3 system calls to get the path of the application by app bundle id, and then
4 executes the Contents/MacOS/X11 script contained inside, which in turn executes
5 Contents/MacOS/X11.bin (the actual app).
7 This patch replaces that discovery technique with a simple call to
8 `getenv' and a hardcoded default. In order to make Xquartz work if the
9 app is moved, we'll need another wrapper that sets the `XQUARTZ_X11'
10 environment variable to point to the `X11' script.
12 diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
13 index 83252e805..f1974215b 100644
14 --- a/hw/xquartz/mach-startup/stub.c
15 +++ b/hw/xquartz/mach-startup/stub.c
16 @@ -52,7 +52,6 @@
18 #include "launchd_fd.h"
20 -static CFURLRef x11appURL;
21 static FSRef x11_appRef;
22 static pid_t x11app_pid = 0;
23 aslclient aslc;
24 @@ -60,29 +59,21 @@ aslclient aslc;
25 static void
26 set_x11_path(void)
28 - OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId),
29 - nil, &x11_appRef, &x11appURL);
30 + unsigned char *xquartzApp = getenv("XQUARTZ_APP");
31 + if (!xquartzApp) {
32 + xquartzApp = "@XQUARTZ_APP@";
33 + }
35 + OSStatus osstatus = FSPathMakeRef(xquartzApp, &x11_appRef, NULL);
37 switch (osstatus) {
38 case noErr:
39 - if (x11appURL == NULL) {
40 - asl_log(aslc, NULL, ASL_LEVEL_ERR,
41 - "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
42 - kX11AppBundleId);
43 - exit(1);
44 - }
45 break;
47 - case kLSApplicationNotFoundErr:
48 - asl_log(aslc, NULL, ASL_LEVEL_ERR,
49 - "Xquartz: Unable to find application for %s",
50 - kX11AppBundleId);
51 - exit(10);
53 default:
54 asl_log(aslc, NULL, ASL_LEVEL_ERR,
55 - "Xquartz: Unable to find application for %s, error code = %d",
56 - kX11AppBundleId, (int)osstatus);
57 + "Xquartz: Unable to find FSRef for %s, error code = %d",
58 + xquartzApp, (int)osstatus);
59 exit(11);