1. Introduction to the Solaris X Server
2. DPS Features and Enhancements
3. Visuals on the Solaris X Server
6. Transparent Overlay Windows
What are Transparent Overlay Windows?
Basic Characteristics of Transparent Overlay Windows
More on Transparent Overlay Characteristics
Choosing Visuals for Overlay/Underlay Windows
Overview of the Solaris Transparent Overlay Window API
Creating Transparent Overlay Windows
Setting the Paint Type of a Graphics Context
Setting the Background State of a Transparent Overlay Window
Rendering to a Transparent Overlay Window
Querying the Characteristics of a Transparent Overlay Window
Determining Whether a Window is an Overlay Window
Determining the Paint Type of a Graphics Context
Filling an Area Using the Source Area Paint Type
Copying an Area and Its Paint Type
Retrieving Overlay Color Information
Using Existing Xlib Pixel Transfer Routines
Designing an Application for Portability
Selecting a Visual for an Overlay/Underlay Window
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
Example 6-1 Transparent Overlay Example Program
#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);}