Ticket #290: border.c

File border.c, 1.3 KB (added by otte@…, 2 years ago)

Simple program demonstrating borders not being drawn

Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <X11/Xlib.h>
4
5int main() {
6  Display *display;
7  Window win, subwin;
8  int screen;
9  int depth;
10  Pixmap pixmap; 
11  Visual *visual;
12  XSetWindowAttributes attributes; 
13  unsigned int white;
14  unsigned int black;
15  XEvent event;
16  int i;
17 
18  display = XOpenDisplay(NULL);
19  screen  = DefaultScreen(display);
20  visual  = DefaultVisual(display,screen); 
21  depth   = DefaultDepth(display,screen); 
22 
23  white = WhitePixel(display,screen);
24  black = BlackPixel(display,screen);
25
26  attributes.background_pixel      = white;
27  attributes.border_pixel          = black;
28  attributes.override_redirect     = 0; 
29
30  /* Create main window */
31
32  win = XCreateWindow(display, XRootWindow(display,screen),
33                200, 200, 400, 400, 0, depth, InputOutput, visual,
34                CWBackPixel | CWBorderPixel | CWOverrideRedirect, 
35                &attributes);
36
37  XSelectInput(display,win,ExposureMask | ButtonPressMask | KeyPressMask);
38  XMapWindow(display, win);
39  XFlush(display);
40 
41  /* Create subwindow. The borders are not shown in 1.5 servers */
42 
43  subwin = XCreateSimpleWindow(display, win, 100, 100, 200, 200, 10, black, white);
44  XMapWindow(display, subwin);
45  XFlush(display);
46
47  i = 1;
48  do {
49    XNextEvent(display,&event); 
50    switch(event.type) {
51    case ButtonPress:
52    case KeyPress:
53      i = 0;
54      break;
55    }
56  } while (i);
57
58  return(0);
59}
60