Date: Wed, 26 Mar 1997 10:59:24 +0100 (MET) From: Christoph Kukulies <kuku@gilberto.physik.rwth-aachen.de> To: zach@blizzard.gaffaneys.com (Zach Heilig) Cc: questions@freebsd.org Subject: Re: X11 programming... Message-ID: <199703260959.KAA13357@gilberto.physik.rwth-aachen.de> In-Reply-To: <19970325201750.16289@gaffaneys.com> from Zach Heilig at "Mar 25, 97 08:17:50 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <stdio.h>
> #include <stdlib.h>
>
> #include <sysexits.h>
>
> #include <X11/Xlib.h>
>
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703260959.KAA13357>
