Path: utzoo!attcan!uunet!cs.utexas.edu!usc!bloom-beacon!BOOTES.GSFC.NASA.GOV!pmr From: pmr@BOOTES.GSFC.NASA.GOV (Pat Ryan) Newsgroups: comp.windows.x Subject: Re: event queue (close) Message-ID: <8907201356.AA03059@expo.lcs.mit.edu> Date: 20 Jul 89 13:55:26 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 88 > >> if the user closes one >> of the program's windows with the mouse (i.e. clicks on the 'Close' >> option of the window's menu), what, if any, signal is generated? >> >If by 'Close' you mean "Iconify", your window will be unmapped (if the >window manager conforms to the ICCCM). You can select for StructureNotify >on your window to receive the UnmapNotify event. > >If by 'Close' you mean "Destroy", your window will be destroyed (and >unmapped as well, if it was mapped). You can select for StructureNotify >on your window to receive the DestroyNotify event. By 'Close' I mean the user clicks the mouse on the top-left corner of the window and then clicks the 'Close' option. I have selected 'StructureNotifyMask' for XCheckWindowEvent and then loop around until either I come upon a DestroyNotify event or I run out of StructureNotify events. For some reason, no DestroyNotify event seems to be appearing. I have included the suspect code below. There are arrays of the data structures used by XWindows and there is an array called 'used' that is set to TRUE when the window is created. If you have the tim to look at it, I would be most appreciative. Pat ------------------------------------------------------------------ #include #include #include #include #include "skw_defs.h" #include "xdefs.h" #include "xstruct.h" #define CLASS extern #include "xglobal.h" int update_alloc() /* * 'update_alloc' is called before a new batch of windows is * processed. It traverses the usage array and if a window is * said to be in use, it will look at the event queue for that * particular window and see if it has been closed by the user * since the last time windows were plotted. * * right now, this does not work. * * 890701 PMR created */ { int i, stop; XEvent report; /* * traverse the usage array looking for used windows */ for (i = 0; i < MAX_WIN; ++i) /* * if it is in use, check to see if it has been destroyed * since the last time windows were plotted */ if (used[i]) { stop = FALSE; while ((!stop) && (XCheckWindowEvent(display[i],win[i], StructureNotifyMask, &report))) /* * if it has been destroyed, free the graphics context, * close the display, and reset the usage flag. */ if (report.type == DestroyNotify) { XFreeGC(display[i], gc[i]); XCloseDisplay(display[i]); used[i]= FALSE; stop = TRUE; printf("reallocated window %d\n",i); } } return(OK); }