Use LaunchServices to start main app from stub
There are four possible execution relationships between Xquartz and X11 binaries in the current version:
A Xquartz is parent of X11: e.g. everything is started by a client connecting to launchd socket, which runs startx -> xinit -> Xquartz -> X11 -> X11.sh -> X11.bin.
B. X11 is parent of Xquartz: e.g. user double-clicks the app bundle and the launchd job is disabled: X11 -> X11.sh -> X11.bin -> startx -> xinit -> Xquartz.
C. Unrelated: e.g., user double-clicks the app bundle and the launchd job is enabled: X11 -> X11.sh -> X11 connects to launchd socket, and then launchd runs startx -> xinit -> Xquartz.
D. None: e.g., the X11 binary is run directly as a traditional X server might be: ./X11.bin :0.
This patch:
- fixes A in favor of C by using LaunchServices to launch the app bundle;
- moves the "notification" to
xinitto after the launchd socket handoff, which is more accurate than before but not perfect.