From owner-freebsd-questions Wed Mar 26 01:48:11 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id BAA29711 for questions-outgoing; Wed, 26 Mar 1997 01:48:11 -0800 (PST) Received: from Campino.Informatik.RWTH-Aachen.DE (campino.Informatik.RWTH-Aachen.DE [137.226.116.240]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id BAA29706 for ; Wed, 26 Mar 1997 01:48:07 -0800 (PST) Received: from gilberto.physik.rwth-aachen.de (gilberto.physik.rwth-aachen.de [137.226.31.2]) by Campino.Informatik.RWTH-Aachen.DE (RBI-Z-5/8.6.12) with ESMTP id KAA23121; Wed, 26 Mar 1997 10:48:13 +0100 (MET) Received: (from kuku@localhost) by gilberto.physik.rwth-aachen.de (8.8.5/8.6.9) id KAA13357; Wed, 26 Mar 1997 10:59:24 +0100 (MET) From: Christoph Kukulies Message-Id: <199703260959.KAA13357@gilberto.physik.rwth-aachen.de> Subject: Re: X11 programming... In-Reply-To: <19970325201750.16289@gaffaneys.com> from Zach Heilig at "Mar 25, 97 08:17:50 pm" To: zach@blizzard.gaffaneys.com (Zach Heilig) Date: Wed, 26 Mar 1997 10:59:24 +0100 (MET) Cc: questions@freebsd.org Reply-To: Christoph Kukulies X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > I know I should get a book, but I haven't figured out which of the available > books are good. Any hints here would be appreciated (cost isn't really a > very big issue; <= US$500 would be great). > > So, I thought I would see how far I could go just reading the man pages. > Basically, I am just trying to get a window (white... or actually _any_ > background) up on the screen. This is as far as I have gotten, but I just > can't seem to get the window to display. I don't get any compile errors or > run-time errors (anymore :-), but still I get nothing. I wonder what I am > missing? You have to wait for the EXPOSE event. The sleep() isn't good for anything but putting your whole process to sleep ;-) > > /* > * xtest.c: testing X functions... > */ > > #include > #include > > #include > > #include > > int > main(void) > { > Display *disp; > Window root; > Window mainwin; > int scrn; > unsigned long black; > unsigned long white; > char *display; > > display = getenv("DISPLAY"); > if (!display) > display = ":0.0"; > > if (!(disp = XOpenDisplay(display))) { > fprintf(stderr, "Error: Could not open the '%s' display.\n", display); > exit(EX_UNAVAILABLE); > } > > scrn = DefaultScreen(disp); > root = RootWindow(disp, scrn); > > white = WhitePixel(disp, scrn); > black = BlackPixel(disp, scrn); > > mainwin = XCreateSimpleWindow(disp, root, 10, 10, 150, 50, 2, white, > white); > XMapWindow(disp, mainwin); while(1) { XEvent rep; XNextEvent(disp , &rep); switch(rep.type){ case EXPOSE: XClearWindow(dpy,((XExposeEvent *)&rep)->window); break; /* case ... process other events here */ default: break; } } > > sleep(5); > > XCloseDisplay(disp); > > return 0; > } > > > -- > Zach Heilig (zach@blizzard.gaffaneys.com) | ALL unsolicited commercial email > /var/spool/news is 110% full, | is unwelcome. I avoid dealing > please delete all the spam you can. | with companies that email ads. > -- Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de