static Display *disp;
static struct timeval tv_startup;
static unsigned wwidth, wheight;
-static int wxpos, wypos;
DEBUG_DEFINE_DEBUGF(pages)
void screenshot_startup(void) {
int r;
+ progress("starting...");
disp= XOpenDisplay(0); eassert(disp);
r= gettimeofday(&tv_startup,0); eassert(!r);
}
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<rwidth && rypos<rheight);
}
static void set_focus(void) {
int screen= XScreenNumberOfScreen(attr.screen);
+ progress("taking control of YPP client window ...\n");
+
debugf("PAGING set_focus\n");
- XTestFakeMotionEvent(disp,screen, wxpos,wypos, 0);
+ int xpos, ypos;
+ translate_coords_toroot(160,160, &xpos,&ypos);
+ XTestFakeMotionEvent(disp,screen, xpos,ypos, 0);
XTestFakeButtonEvent(disp,1,1, 50);
XTestFakeButtonEvent(disp,1,0, 50);
sync_after_input();
+
+ translate_coords_toroot(10,10, &xpos,&ypos);
+ XTestFakeMotionEvent(disp,screen, xpos,ypos, 0);
+
+ sync_after_input();
+
debugf("PAGING raise_and_set_focus done.\n");
}
debugfind(" YES!\n");
id= w2;
nfound++;
+ progress_log("found YPP client window 0x%lx: %s on the %s ocean\n",
+ (unsigned long)id, pirate, ocean);
}
if (children2) XFree(children2);
}