jlf@earth.cray.COM (John Freeman) (12/03/88)
I want to change the color of an existing window.
Why doesn't this program do that?
I know it's not good form to hard code a background color,
it's just there for simplicity.
--------------------------------------------------------------------------------
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
{
char *getenv(), *windowid;
Window w;
Display *d;
/* find what window we're in */
windowid = getenv("WINDOWID");
if(!windowid) {
fprintf(stderr, "No window ID\n");
exit(1);
}
w = atoi(windowid);
/*
* Open Display, get defaults
*/
d = XOpenDisplay(NULL);
if (d == NULL) {
fprintf(stderr, "Could not open Display\n");
exit(1);
}
printf(" d = %#x, w = %#x\n", d,w);
XSetWindowBackground(d, w, 4);
XClearWindow(d,w);
XSync(d,0);
}davep@ginsu.apple.COM (12/03/88)
xterm is a toolkit-based application. The WINDOWID environment variable that you're looking at gives you the window id of the top-level shell widget, which is completed obscured by its child widget. Your code is working, you just can't see it. Dave Payne Apple Computer, A/UX Engineering Group (408) 974-5545 davep@apple.com