CGWindowServerCFMachPort()
Returns a Core Foundation Mach port (CFMachPort) that corresponds to the macOS window server.
Declaration
func CGWindowServerCFMachPort() -> CFMachPort?Return Value
A Core Foundation Mach port, or NULL if the window server is not running. When you no longer need the port, you should release it using the function CFRelease.
Discussion
You can use this function to detect whether the window server process exits or is not running. If this function returns NULL, the window server is not running. This code example shows how to register a callback function to detect when the window server exits:
static void handleWindowServerDeath( CFMachPortRef port, void *info )
{
printf( "Window Server port death detected!\n" );
CFRelease(port);
exit(1);
}
static void watchForWindowServerDeath()
{
CFMachPortRef port = CGWindowServerCFMachPort();
CFMachPortSetInvalidationCallBack(port, handleWindowServerDeath);
}Note that this callback only works if your program has an active run loop.
See Also
Functions
CGAcquireDisplayFadeReservation(_:_:)CGAssociateMouseAndMouseCursorPosition(_:)CGBeginDisplayConfiguration(_:)CGCancelDisplayConfiguration(_:)CGCaptureAllDisplays()CGCaptureAllDisplaysWithOptions(_:)CGCompleteDisplayConfiguration(_:_:)CGConfigureDisplayFadeEffect(_:_:_:_:_:_:)CGConfigureDisplayMirrorOfDisplay(_:_:_:)CGConfigureDisplayMode(_:_:_:)CGConfigureDisplayOrigin(_:_:_:_:)CGConfigureDisplayStereoOperation(_:_:_:_:)CGConfigureDisplayWithDisplayMode(_:_:_:_:)CGCursorIsDrawnInFramebuffer()CGCursorIsVisible()