One trick must be solved in order to integrate the xwinclip functionality into XWin.exe:
We need a way to cause XNextEvent to return when the X Server is about to be shutdown. The X Server shutdown can either be caused by the user clicking the close button in the upper right-hand corner of the X Server window, or it can happen by the last X Client exiting and causing the X Server to reset. The latter case is particularly important to catch... otherwise Xlib will call IOErrorHandler which must call exit (). You may get the clever idea of just writing an IOErrorHandler that does not call exit (), however, Xlib will call exit () for you if your IOErrorHandler does return. Thus, that clever idea doesn't work. There may be a way to get a DestroyNotify event or something similar to be sent to the xwinclip client, however, the following mask does not cause the desired result: StructureNotifyMask | PropertyChangeMask | SubstructureNotifyMask In fact, that same event mask on the root window does not cause an event to occur before the X Server shuts down. I'm at a loss for anymore ideas, and I really need an X guru to step forward and tell me a way to get notified that the X Server is about to shutdown. Harold P.S. It should be self-evident that xwinclip cannot be integrated into the X Server if, upon X Server reset, xwinclip will call exit (), because then you would have an X Server that exited upon every reset...
