Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!bloom-beacon!LARRY.MCRCIM.MCGILL.EDU!mouse From: mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) Newsgroups: comp.windows.x Subject: XGetWindowAttributes: documentation/reality clash Message-ID: <8904240439.AA12537@Larry.McRCIM.McGill.EDU> Date: 24 Apr 89 04:39:29 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 52 I think XGetWindowAttributes is not behaving according to the documentation. (System: Sun-3s running release 3.5, X11R3 with Purdue patches in place, and it's not any specific machine that it's failing on.) I'm writing my own window manager and I have occasion to want to inquire as to whether a given window ID still refers to a window. In the Xlib document, I find the following promising lines: 4.1. Obtaining Window Information Xlib provides functions that you can use to obtain informa- tion about the window tree, the window's current attributes, the window's current geometry, or the current pointer coor- NOTE> dinates. Because they are most frequently used by window NOTE> managers, these functions all return a status to indicate NOTE> whether the window still exists. [documentation for XQueryTree omitted] To obtain the current attributes of a given window, use XGetWindowAttributes. [documentation for XGetWindowAttributes omitted] Fine, think I, and write int window_exists(w) Window w; { XWindowAttributes attr; return(XGetWindowAttributes(disp,w,&attr)?1:0); } but then I get a rude shock when my wm crashes the first time this function is called under circumstances when I would expect it to return false (ie, the window doesn't exist). I see the following printed by the wm when it dies: X Protocol error: not a valid window ID Major opcode of failed request: 3 (X_GetWindowAttributes) Minor opcode of failed request: 0 Resource id in failed request: 0x1100002 Serial number of failed request: 1657 Current serial number in output stream: 1657 What am I misreading? What *is* the proper way to tell whether a window still exists? (I want to avoid XSync()ing and looking for window destruction events - which certainly ought to work! This function is called only with the server grabbed.) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu