#include #include #include int main(void) { int event_base, error_base; Display *display; Screen *screen; Window root; XSetWindowAttributes attr; const int w1 = 400, h1 = 300, w2 = 300, h2 = 400; Window window1, window2; XRenderPictFormat *format; Picture pict1, pict2; XTransform xform; static const XRenderColor green = { 0, 0xffff, 0, 0xffff }; display = XOpenDisplay(NULL); if (display == NULL) { return 1; } if (!XRenderQueryExtension(display, &event_base, &error_base)) { XCloseDisplay(display); return 1; } screen = DefaultScreenOfDisplay(display); root = RootWindowOfScreen(screen); attr.override_redirect = True; window1 = XCreateWindow(display, root, w2 / 2, h2 / 2, w1, h1, 0, CopyFromParent, InputOutput, CopyFromParent, CWOverrideRedirect, &attr); window2 = XCreateWindow(display, root, w1 + w2 / 2, 0, w2, h2, 0, CopyFromParent, InputOutput, CopyFromParent, CWOverrideRedirect, &attr); XMapWindow(display, window1); XMapWindow(display, window2); format = XRenderFindVisualFormat(display, DefaultVisualOfScreen(screen)); pict1 = XRenderCreatePicture(display, window1, format, 0, NULL); pict2 = XRenderCreatePicture(display, window2, format, 0, NULL); xform.matrix[0][0] = (w1 << 16) / w2; xform.matrix[0][1] = 0; xform.matrix[0][2] = 0; xform.matrix[1][0] = 0; xform.matrix[1][1] = (h1 << 16) / h2; xform.matrix[1][2] = 0; xform.matrix[2][0] = 0; xform.matrix[2][1] = 0; xform.matrix[2][2] = 0; XRenderSetPictureTransform(display, pict1, &xform); XRenderFillRectangle(display, PictOpSrc, pict1, &green, 0, 0, w1, h1); XRenderComposite(display, PictOpSrc, pict1, None, pict2, 0, 0, 0, 0, 0, 0, w2, h2); XFlush(display); sleep(5); XDestroyWindow(display, window1); XDestroyWindow(display, window2); XCloseDisplay(display); return 0; }