+static void translate_coords_toroot(int wx, int wy, int *rx, int *ry) {
+ int r;
+ Window dummy;
+ r= XTranslateCoordinates(disp, id,attr.root, wx,wy, rx,ry, &dummy);
+ eassert(r);
+}
+
+static void check_client_window_all_on_screen(void) {
+ int r;
+ int rxpos, rypos;
+ unsigned rwidth, rheight;
+ Window dummy;
+ unsigned bd, depth;
+
+ r= XGetGeometry(disp,attr.root, &dummy, &rxpos,&rypos,
+ &rwidth, &rheight,
+ &bd,&depth);
+
+ translate_coords_toroot(0,0, &rxpos,&rypos);
+ eassert(rxpos>=0 && rypos>=0);
+
+ translate_coords_toroot(wwidth-1,wheight-1, &rxpos,&rypos);
+ eassert(rxpos<rwidth && rypos<rheight);
+}
+
+static void check_not_disturbed(void) {
+ XEvent ev;
+ int r;
+
+ for (;;) {
+ r= XCheckMaskEvent(disp, ~0, &ev);
+ if (r==False) return;
+
+ switch (ev.type) {
+ case VisibilityNotify:
+ eassert(ev.xvisibility.state == VisibilityUnobscured);
+ break;
+ case ConfigureNotify:
+ check_client_window_all_on_screen();
+ break;
+ case FocusOut:
+ eassert(!"focus left YPP client window");
+ break;
+ case FocusIn:
+ warning("focus entered YPP client window ?!");
+ break;
+ default:
+ eassert(!"unexpected X11 event");
+ }
+ }
+}
+