#include #include #include int main( int argc, char **argv ) { Display *d = XOpenDisplay(0); int s = DefaultScreen(d); XSetWindowAttributes xswa; XSizeHints hints; XEvent event; Window w; int i, gx, gy, sx = -1, sy = -1; /* Create a window and map it. */ xswa.event_mask = StructureNotifyMask; w = XCreateWindow(d, RootWindow(d, s), 0, 0, 20, 20, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask, &xswa); XMapWindow(d, w); do { XMaskEvent(d, StructureNotifyMask, &event); } while ((event.type != MapNotify) || (event.xmap.event != w)); /* Set the window gravity. */ hints.flags = PWinGravity; if(argc > 1 && argv[ 1 ][ 0 ] == 's') { fprintf(stderr, "Using StaticGravity...\n"); hints.win_gravity = StaticGravity; } else { fprintf(stderr, "Using NorthWestGravity...\n"); hints.win_gravity = NorthWestGravity; } XSetWMNormalHints(d, w, &hints); /* Move the window to its current location 10 times. */ for(i = 0; i < 10; i++) { Window dw; XTranslateCoordinates(d, w, DefaultRootWindow(d), 0, 0, &gx, &gy, &dw); if(sx < 0) { sx = gx; sy = gy; } XMoveResizeWindow(d, w, gx, gy, 20, 20); XSync(d, False); fprintf(stderr, "%d: (%d, %d)\n", i, gx, gy); usleep(500); } if(sx != gx || sy != gy) { fprintf(stdout, "Test failed: window moved.\n"); } else { fprintf(stdout, "Test passed: window did not move.\n"); } /* Done. */ XDestroyWindow(d, w); XCloseDisplay(d); return 0; }