The program below demonstrates a simple example of a transparent overlay. The program creates a transparent overlay window, draws the window border in white, displays a text string in white, and draws a white filled rectangle. The paint type is opaque by default, and the window background is transparent by default. Use the following Makefile to compile and link the program.
simple: simple.c cc -I../ -I/usr/openwin/include -o simple simple.c \ -L/usr/openwin/lib -lX11 -lXext
#include <stdio.h> #include <X11/Xlib.h> #include “X11/Xmd.h” #include <X11/extensions/transovl.h> #include <X11/extensions/transovlstr.h> Display *display; Window window; XSetWindowAttributes attribs; GC gc; XGCValues gcvalues; main() { display = XOpenDisplay(““); attribs.override_redirect = True; attribs.border_pixel = WhitePixel(display,0); window = XSolarisOvlCreateWindow(display, DefaultRootWindow(display), 100, 100, 500, 500, 10, CopyFromParent, InputOutput,CopyFromParent, CWBorderPixel | CWOverrideRedirect, &attribs); gcvalues.font = XLoadFont(display, “fixed”); gcvalues.foreground =WhitePixel(display, 0); gc = XCreateGC(display, window, GCFont | GCForeground,&gcvalues); XMapWindow(display, window); XDrawString(display, window, gc, 50, 50, “This is a test”, 14); XFillRectangle(display,window, gc, 70, 70, 100, 100); XFlush(display); while (1);}