kang@ARISIA.XEROX.COM ("Steven S. Kang ES AE") (10/16/89)
All, I know this is a very basic question but none of the references seems to give me a coherent answer. After XCreateWindow and XMapWindow calls, I still don't get a visible window on the screen. I simply want to create a window that I could do (non-interactive) drawing. I have to call XNextEvent in order to get the server to create the window on the screen. Also, if I want to do all my input via files, this would mean I don't need to handle any events.... event_mask = 0. But, how could I do this and still call XNextEvent to get the window on the screen. Thanks in advance, Steve
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (10/16/89)
I have to call XNextEvent in order to get the server to create the window on the screen. No, you have to flush Xlib's output buffer to create the window on the screen. XNextEvent is simply one convenient way to make this happen. XFlush is another way to make this happen.
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (10/16/89)
> Also, if I want to do all my input via files, this would mean > I don't need to handle any events.... event_mask = 0. There is no way to write a proper X program that does not handle events. You must have a window visable on display, or all your drawing commands will be tossed in the bit bucket. The only way to make sure that this is true is to wait for expose events. Since the X model also requires the application to repair any damage to the window caused by it being obscured, you must also be prepared to redraw the contents of your window on any expose event. I would strongly suggest that you have a routine that repaints the contents of the window whenever an expose event with count == 0 is received. If you set things up properly you should be able just set up your internal data structure, create the windows, and the wait for expose events. I hope this helps. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
paquin@kahua.esd.sgi.com (Tom Paquin) (10/18/89)
. . > There is no way to write a proper X program that does not > handle events. Hogwash. xsetroot, xhost, xset... You can even do it properly with a window, depending on what you want done. > You must have a window visable on display, or all your drawing > commands will be tossed in the bit bucket. The only way to > make sure that this is true is to wait for expose events. Don't forget Map events > Since the X model also requires the application to repair > any damage to the window caused by it being obscured, you > must also be prepared to redraw the contents of your window > on any expose event. Hogwash again. The X model does not require interest in Expose events and therefore interest in those events is selectable. The server will paint the background of your window as it exposes. Thus, if all you want is a window with its background (maybe the background is the mona lisa), you can ignore exposes ad nauseum. (Besides, X doesn't require applications to have windows.) -Tom ***** Opinions are mine, not SGI's
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (10/27/89)
I will attempt to not let the tone of this message affect my respone, but... > > There is no way to write a proper X program that does not > > handle events. > Hogwash. xsetroot, xhost, xset... You can even do it properly with > a window, depending on what you want done. Okay, fine but 99% of the time if you are not dealing with events you are doing something wrong, and asking for trouble. Perhaps my words were a bit to strong, but unless you REALLY know what you are doing then you had better handle events. The intended audience for this message was novices. Why bother picking this nit? > > You must have a window visable on display, or all your drawing > > commands will be tossed in the bit bucket. The only way to > > make sure that this is true is to wait for expose events. > Don't forget Map events Forget Map events, in this case they are not useful. Mapped windows will not necesarily be visable, or even mapped on the screen. What if you are mapped and you ancestor is unmapped? Exposure is what you want to use when drawing. I stand by my original answer. > > Since the X model also requires the application to repair > > any damage to the window caused by it being obscured, you > > must also be prepared to redraw the contents of your window > > on any expose event. > Hogwash again. The X model does not require interest in Expose events and > therefore interest in those events is selectable. The server will paint > the background of your window as it exposes. Thus, if all you want is > a window with its background (maybe the background is the mona lisa), > you can ignore exposes ad nauseum. (Besides, X doesn't require applications > to have windows.) Seems that this is an nit also. If you are drawing on a window then you will have to repair the damage caused by someone unobscuring a section of that window. Sure the server will fix your background, and if you have nothing of interest to repair you are not required to select for expose events, but that does not change the truth of my original statement. I did write a program that did all the drawing on background pixmaps, but this sucker was a real memory hog. You can get around the X model of exposures and redraws, but you will have a much better application (smaller, and faster) if you work with X and handle your exposure events properly. Attempting to hack things up by using the background pixmap so simulate backing store may seem like the easy way out, but in the long run it is not worth it. Do it "right" the first time and you will be very happy that you did. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213