The architecture of Mac OS X’s windowing system

osxwindow-manager

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?

Best Answer

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.

Related Question