reallly simple X program to test a setup

Pat Kane pekane52 at gmail.com
Wed Apr 11 06:00:10 PDT 2007


> Yan Seiner wrote:
>
> I am looking for a really simple X program to test an embedded setup.


Below  is a simple very  X program to draw a  single line.

Pat
---

/*
 * Draw a line
 *
 * build with:  gcc xline.c -lX11 -o xline
 *
 * PEK 2007
 */
#define WIDTH    128
#define HEIGHT   128

main()
{
  Display * dpy;
  Window    win;
  XEvent    event;
  int       scrn;
  int       x1, y1, x2, y2;

  if ((dpy = XOpenDisplay("")) == NULL)
  {
      printf("Can not connect to X server.\n");
      exit(1);
  }
  scrn = DefaultScreen(dpy);

  win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
                            0, 0,
                            WIDTH, HEIGHT,
                            5,
                            BlackPixel(dpy,scrn), WhitePixel(dpy,scrn));

  XSelectInput(dpy, win, KeyPressMask|ExposureMask|ButtonPressMask);

  XMapRaised(dpy,win);

  /* wait for first expose event */
  XWindowEvent(dpy, win, ExposureMask, &event);

  x1 = 0;        y1 = 0;
  x2 = WIDTH-1;  y2 = HEIGHT-1;
  XDrawLine (dpy, win, DefaultGC(dpy, scrn), x1, y1, x2, y2);

  /* wait for key or button */
  XWindowEvent(dpy, win, KeyPressMask|ButtonPressMask, &event);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20070411/bc30e6e7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xline.c
Type: text/x-csrc
Size: 950 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20070411/bc30e6e7/attachment.c>


More information about the xorg mailing list