Remove the ConfigureNotify event handling and get the current parent size in the expose processing. This ignores the queued Configure Notify events the give a history of the parent size rather that the current parent window size.
So modifying the code you posted in the comments.
if (e.type == Expose) {
if (e.xexpose.count == 0) {
Window r;
int x,y;
unsigned int wd,ht, bw, dep;
XGetGeometry(d,w,&r,&x,&y,&wd,&ht,&bw,&dep);
width = wd - 20;
height = ht - 20;
XMoveResizeWindow (d, ww, 10, 10, width, height);
for (i=0;i<1000;i++) {
XFillRectangle(d, ww, DefaultGC(d, s), 20, 20, 10, 10);
XFillRectangle(d, ww, DefaultGC(d, s), width-30, height-30, 10, 10);
XFillRectangle(d, ww, DefaultGC(d, s), 20, height-30, 10, 10);
XFillRectangle(d, ww, DefaultGC(d, s), width-30, 20, 10, 10);
}
}
}
Update: To fix the lack of expose events, add the following:
if (e.type == ConfigureNotify) {
{
while (XCheckTypedWindowEvent(d, w, ConfigureNotify, &e) == True);
width = e.xconfigure.width - 20;
height = e.xconfigure.height - 20;
XMoveResizeWindow (d, ww, 10, 10, width, height);
}
This will cause some more expose events. The XCheckTypedWindowEvent
may not be necessary, it removes any all the ConfigureNotify events from the queue leaving the last one found in e
.