XDestroyWindow can not really close the window

Alan Coopersmith alan.coopersmith at oracle.com
Fri May 11 17:21:12 UTC 2018


On 05/11/18 10:04 AM, Ilya Anfimov wrote:
> On Thu, May 10, 2018 at 06:23:08PM -0700, Alan Coopersmith wrote:
>> On 05/10/18 06:17 PM, pengyixiang wrote:
>>> Hello, everyone!
>>>     I'm a newbie in xlib, I need to close the window while won't close the
>>> program, [1] is my test code, here's the result in [2], XDestroyWindow passed,
>>> but the window haven't close, Haven't I get the key to code it?
>>
>> XDestroyWindow() just puts the request in the Xlib buffer but does not send
>> it to the X server.
> 
>  I  think, it could be useful to note, that it does not necessary
> send request to a server. It may. In  some  circumstances  or  on
> some implementations. But it is not required to do so.

This is true of all Xlib functions that don't explictly say they do,
it's not unique to XDestroyWindow but something people need to learn
when doing Xlib programming in general.

https://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html#Overview_of_the_X_Window_System
describes this as:

  Most of the functions in Xlib just add requests to an output buffer.
  These requests later execute asynchronously on the X server. Functions
  that return values of information stored in the server do not return
  (that is, they block) until an explicit reply is received or an error
  occurs. You can provide an error handler, which will be called when
  the error is reported.

  If a client does not want a request to execute asynchronously, it can
  follow the request with a call to XSync, which blocks until all previously
  buffered asynchronous events have been sent and acted on. As an important
  side effect, the output buffer in Xlib is always flushed by a call to any
  function that returns a value from the server or waits for input.

-- 
	-Alan Coopersmith-               alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - https://blogs.oracle.com/alanc


More information about the xorg mailing list