diff options
Diffstat (limited to 'progs')
-rw-r--r-- | progs/xdemos/glxdemo.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/progs/xdemos/glxdemo.c b/progs/xdemos/glxdemo.c index 843aabb329..75e11443d2 100644 --- a/progs/xdemos/glxdemo.c +++ b/progs/xdemos/glxdemo.c @@ -69,7 +69,7 @@ static Window make_rgb_db_window( Display *dpy, attr.background_pixel = 0; attr.border_pixel = 0; attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); - attr.event_mask = StructureNotifyMask | ExposureMask; + attr.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow( dpy, root, 0, 0, width, height, @@ -90,6 +90,17 @@ static Window make_rgb_db_window( Display *dpy, } +static void new_colour(Display *dpy, Window win) +{ + GLfloat r, g, b; + r = (GLfloat)random() / (GLfloat)RAND_MAX; + g = (GLfloat)random() / (GLfloat)RAND_MAX; + b = (GLfloat)random() / (GLfloat)RAND_MAX; + glClearColor(r, g, b, 1.0); + redraw(dpy, win); +} + + static void event_loop( Display *dpy ) { XEvent event; @@ -104,6 +115,9 @@ static void event_loop( Display *dpy ) case ConfigureNotify: resize( event.xconfigure.width, event.xconfigure.height ); break; + case ButtonPress: + new_colour(dpy, event.xany.window); + break; } } } |