Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 152

KTD-S0057-I
Page 148 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
disp = XOpenDisplay (NULL);
if (disp == (Display *) NULL)
{
fprintf (stderr, "Cannot connect the X server\n");
return
EXIT_FAILURE;
}
if (!XMatchVisualInfo (disp, 0, 32, TrueColor, &vinfo))
if (!XMatchVisualInfo (disp, 0, 24, TrueColor, &vinfo))
if (!XMatchVisualInfo (disp, 0, 16, TrueColor, &vinfo))
{
fprintf (stderr, "Cannot get TrueColor Visual\n");
XCloseDisplay
(disp);
return
EXIT_FAILURE;
}
visual = vinfo.visual;
depth = vinfo.depth;
screen = vinfo.screen;
cmap = XCreateColormap (disp, RootWindow (disp, screen), visual, AllocNone);
wa.background_pixel = WhitePixel (disp, screen);
wa.border_pixel = BlackPixel (disp, screen);
wa.colormap = cmap;
win = XCreateWindow (disp, RootWindow (disp, screen), LEFT, TOP, WIDTH, HEIGHT, BORDER, depth,
InputOutput,
visual,
CWBorderPixel | CWBackPixel | CWColormap, &wa);
gc = XCreateGC (disp, win, 0, NULL);
if (! gc)
{
fprintf (stderr, "Cannot create graphics context\n");
XDestroyWindow (disp, win);
XFreeColormap (disp, cmap);
XCloseDisplay
(disp);
return
EXIT_FAILURE;
}
font = XLoadQueryFont (disp, STAT_FONT);
sh.min_width = WIDTH;
sh.min_height
=
HEIGHT;
sh.flags = PMinSize;
XSetWMNormalHints (disp, win, &sh);
XStringListToTextProperty (&txt, 1, &name);
XSetWMName (disp, win, &name);
XSelectInput (disp, win, ButtonPressMask | ExposureMask | StructureNotifyMask);
close = XInternAtom (disp, "WM_DELETE_WINDOW", TRUE);
if
(close)
XSetWMProtocols (disp, win, (Atom *) &close, 1);
XMapWindow (disp, win);