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

Page 124

Advertising
background image

KTD-S0057-I

Page 120 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


XEvent

e;

Pixmap

pict;

XSystem

xsys;

XButton

xbtn;

char *txt = HEADER;

disp = XOpenDisplay (NULL);

if (disp == (Display *) NULL)

{

fprintf (stderr, "Cannot connect the X server\n");

return

EXIT_FAILURE;

}

memset ((void *) &xsys, 0, sizeof (xsys));

memset ((void *) &xbtn, 0, sizeof (xbtn));

xsys.disp = disp;

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");

free_resources

(xsys);

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);

sh.min_width =

WIDTH;

sh.min_height =

HEIGHT;

sh.flags

=

PMinSize;

XSetWMNormalHints (disp, win, &sh);

XStringListToTextProperty (&txt, 1, &name);

XSetWMName (disp, win, &name);

xsys.win

=

win;

xsys.screen

=

screen;

xsys.cmap

=

cmap;

gc = XCreateGC (disp, win, 0, NULL);

if (! gc)

{

fprintf (stderr, "Cannot create graphics context\n");

free_resources

(xsys);

return

EXIT_FAILURE;

}

Advertising
This manual is related to the following products: