X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=pctb%2Fpages.c;h=99f4af2adb562be8e340981f78f5b0416b0e17b3;hb=4903e3f2fbd534bde1bc3ebc4d84328297e0b388;hp=b9e1ac1649dc2c5aa8a57997e58cabba430b54f1;hpb=451e1b1ed16a7a53395c030598a83031e266f973;p=ypp-sc-tools.db-test.git diff --git a/pctb/pages.c b/pctb/pages.c index b9e1ac1..99f4af2 100644 --- a/pctb/pages.c +++ b/pctb/pages.c @@ -18,7 +18,6 @@ static Window id; static Display *disp; static struct timeval tv_startup; static unsigned wwidth, wheight; -static int wxpos, wypos; DEBUG_DEFINE_DEBUGF(pages) @@ -28,6 +27,7 @@ static KeyCode keycode(KeySym sym) { void screenshot_startup(void) { int r; + progress("starting..."); disp= XOpenDisplay(0); eassert(disp); r= gettimeofday(&tv_startup,0); eassert(!r); } @@ -152,41 +152,81 @@ static void wait_for_stability(Snapshot **output, debugf("PAGING wait_for_stability done.\n"); } +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 raise_and_get_details(void) { int r; int evbase,errbase,majver,minver; + int wxpos, wypos; unsigned bd,depth; Window dummy; - + + progress("raising and checking YPP client window ...\n"); + debugf("PAGING raise_and_get_details\n"); r= XTestQueryExtension(disp, &evbase,&errbase,&majver,&minver); eassert(r==True); r= XRaiseWindow(disp, id); eassert(r); + /* in case VisibilityNotify triggers right away before we have had a + * change to raise; to avoid falsely detecting lowering in that case */ + + r= XSelectInput(disp, id, + StructureNotifyMask| + VisibilityChangeMask + ); eassert(r); + + r= XRaiseWindow(disp, id); eassert(r); + /* in case the window was lowered between our Raise and our SelectInput; + * to avoid failing to detect that lowering */ r= XGetWindowAttributes(disp, id, &attr); eassert(r); r= XGetGeometry(disp,id, &attr.root, &wxpos,&wypos, &wwidth,&wheight, &bd,&depth); - eassert(r); - r= XTranslateCoordinates(disp, id,attr.root, 160,160, &wxpos,&wypos, - &dummy); - eassert(r); + eassert(wwidth >= 320 && wheight >= 320); + + int rxpos, rypos; + unsigned rwidth, rheight; + 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