39

I am familiar with how the X11 system works, where clients connect via a socket to the server process and send operations to the window server to perform certain operations on their behalf.

But I do not understand (and I could not find good documents) describing how a GUI application interacts with the window system on Mac OS X. Some of the questions that I have include:

  • How does an app receive events from the windowing system?
  • Does the app need to register with the kernel, or some windowing system server?
  • How does the windowing system request that an app update its display?
  • How does an app trigger a re-display operation?
  • Is there a socket-based protocol, or some other RPC system to the windowing system?
  • Does the windowing system, or the application, have direct hardware access?
  • What are the operations available between client apps and the windowing system?

5 Answers 5

14

This is what I have been able to gather so far:

Applications communicate over some sort of private API to the WindowServer process, the WindowServer process is the one that actually gets hardware events (mouse, keyboard) and dispatches those to the client applications. (this is still an open question: what protocol do they use if any, do they use Mach ports and MIG, or some Socket-based API, not sure).

Some information is here:

https://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/OSX_Technology_Overview/GraphicsTechnologies/GraphicsTechnologies.html#//apple_ref/doc/uid/TP40001067-CH273-SW1

The WindowServer is the Quartz Compositor. Typically applications use the Quartz2D API which exposed in the CoreGraphics API (CGXXX funtions). Applications create CoreGraphics "Contexts" (CGContext) and draw there. Whether the context is pushed when it is done as big bitmap, or if the operations are sent to the server like they are on X11 is still an open question.

There is a limited API exposed to control certain aspects of the WindowServer process, the sort of configuration settings that are typically done from the Settings application, but there is no documentation on how apps actually communicate graphic requests or pump messages from the server, other than the Carbon/Cocoa APIs exposed.

4
3

The "What is Cocoa?" section of the Cocoa Fundamentals Guide has a bunch of great illustrations of the architecture from the bottom up.

1
  • 2
    (sorry, can't post notes yet): Quartz or Core Graphics is the drawing and windowing system in OS X (replacing QuickDraw). Core Graphics is one part of Cocoa (Cocoa as a whole being more comparable to the entire Win32 API, rather than GDI, Direct2D or X) Aug 21, 2010 at 21:57
2

The best resource for OS X internals is Amit Singh's Mac OS X Internals. It is astonishingly detailed, but unfortunately only covers OS X up to 10.4. Google books has a preview.

Apple's documentation for OS X is also a nice resource, and is obviously more up-to-date.

1

XQuartz is the open-source project of the X.org X Window System that runs on Mac OS X. Their developer wiki and mailing list should help you with your questions, seems like you need someone deeply involved in the project to answer those.

1
  • 4
    Right, but that only covers XQuartz, which is just a program that talks to their real windowing system. The question was about how do apps like XQuarts or Finder talk to this windowing system Aug 17, 2010 at 2:34
1

In prior MacOS versions, the lifting was done by QuickDraw; in OS X, that has been superseded by Cocoa...

It doesn't simply parallel X11 though. For example, X11 doesn't include audio, but Cocoa does.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .