7
all_events (Display *display,
16
get_size (Display *d, Drawable draw,
17
int *xp, int *yp, int *widthp, int *heightp)
20
unsigned int width, height, border, depth;
23
XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);
37
main (int argc, char **argv)
44
int x, y, width, height;
48
gboolean redraw_pending;
50
d = XOpenDisplay (NULL);
52
screen = DefaultScreen (d);
59
zero_min_size = XCreateSimpleWindow (d, RootWindow (d, screen),
60
x, y, width, height, 0,
61
WhitePixel (d, screen),
62
WhitePixel (d, screen));
64
XSelectInput (d, zero_min_size,
65
ButtonPressMask | ExposureMask | StructureNotifyMask);
67
hints.flags = PMinSize;
72
XSetWMNormalHints (d, zero_min_size, &hints);
73
XMapWindow (d, zero_min_size);
75
redraw_pending = FALSE;
83
if (ev.xbutton.button == 1)
85
g_print ("Exiting on button 1 press\n");
93
width = ev.xconfigure.width;
94
height = ev.xconfigure.height;
96
redraw_pending = TRUE;
100
redraw_pending = TRUE;
107
/* Primitive event compression */
108
if (XCheckIfEvent (d, &ev, all_events, NULL))
110
XPutBackEvent (d, &ev);
112
else if (redraw_pending)
114
pix = XCreatePixmap (d, zero_min_size, width, height,
115
DefaultDepth (d, screen));
117
gc_vals.foreground = WhitePixel (d, screen);
119
gc = XCreateGC (d, pix, GCForeground, &gc_vals);
121
XFillRectangle (d, pix, gc, 0, 0, width, height);
123
XCopyArea (d, pix, zero_min_size, gc, 0, 0, width, height, 0, 0);
125
XFreePixmap (d, pix);
128
redraw_pending = FALSE;