rendered paste body#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <X11/Xlib.h>#include <X11/keysymdef.h>#include <X11/extensions/Xrender.h>#define KERNEL_SIZE 5intmain (int argc, char** argv){ Display* pDisplay = NULL; XEvent event; Bool bKeepGoing = True; Bool bGotEvent = False; int iEventBase; int iErrorBase; int iMajorVersion; int iMinorVersion; XSetWindowAttributes values; Window window; XRenderPictFormat* pPictFormat = NULL; XRenderPictureAttributes pictAttribs; XRenderColor colorBlue = {0, 0, 255, 127}; Picture picture; XFixed aiConvolutionKernel[KERNEL_SIZE] = {0, 2, 7, 2, 0}; int iWindowAttribsMask; /* connect to display */ pDisplay = XOpenDisplay (NULL); if (!pDisplay) { printf ("Could not open display\n"); return 1; } /* check for Xrender-extension */ if (!XRenderQueryExtension (pDisplay, &iEventBase, &iErrorBase)) { XCloseDisplay (pDisplay); printf ("Xrender-extension not found\n"); return 2; } /* see which version is available */ XRenderQueryVersion (pDisplay, &iMajorVersion, &iMinorVersion); printf ("Found Xrender %d.%d\n", iMajorVersion, iMinorVersion); /* make behave synchronous */ XSynchronize (pDisplay, True); /* create and open window */ values.background_pixel = WhitePixel (pDisplay, 0); values.event_mask = KeyPressMask; iWindowAttribsMask = CWEventMask | CWBackPixel; window = XCreateWindow (pDisplay, RootWindow (pDisplay, 0), 50, 50, 400, 400, 0, DefaultDepth (pDisplay, 0), InputOutput, DefaultVisual (pDisplay, 0), iWindowAttribsMask, &values); XMapWindow (pDisplay, window); /* now the guessing work starts, ** because Xrender is so "thoroughly" documented :-( */ pPictFormat = XRenderFindVisualFormat (pDisplay, DefaultVisual (pDisplay, 0)); picture = XRenderCreatePicture (pDisplay, window, pPictFormat, 0, &pictAttribs); /* results in a black rectangle ? */ XRenderFillRectangle (pDisplay, PictOpSrc, picture, &colorBlue, 100, 200, 120, 80); while (bKeepGoing) { bGotEvent = XCheckWindowEvent (pDisplay, window, KeyPressMask, &event); if (bGotEvent) { switch (event.type) { case KeyPress : if (XLookupKeysym (&event.xkey, 0) == XK_Escape) bKeepGoing = False; break; } } else usleep (10000); } XUnmapWindow (pDisplay, window); XDestroyWindow (pDisplay, window); XCloseDisplay (pDisplay); return 0;}