CanonImage *page_images[MAX_PAGES];
int npages;
+static XWindowAttributes attr;
static Window id;
static Display *disp;
static struct timeval tv_startup;
static unsigned wwidth, wheight;
+static int wxpos, wypos;
static KeyCode keycode(KeySym sym) {
return XKeysymToKeycode(disp,sym);
fprintf(stderr,"PAGING wait_for_stability done.\n");
}
-static void raise_and_set_focus(void) {
+static void raise_and_get_details(void) {
int r;
- XWindowAttributes attr;
- int xpos,ypos, evbase,errbase,majver,minver;
+ int evbase,errbase,majver,minver;
unsigned bd,depth;
Window dummy;
- fprintf(stderr,"PAGING raise_and_set_focus\n");
+ fprintf(stderr,"PAGING raise_and_get_details\n");
r= XTestQueryExtension(disp, &evbase,&errbase,&majver,&minver);
eassert(r==True);
r= XGetWindowAttributes(disp, id, &attr); eassert(r);
r= XGetGeometry(disp,id, &attr.root,
- &xpos,&ypos, &wwidth,&wheight,
+ &wxpos,&wypos, &wwidth,&wheight,
&bd,&depth);
eassert(r);
- r= XTranslateCoordinates(disp, id,attr.root, 160,160, &xpos,&ypos,
+ r= XTranslateCoordinates(disp, id,attr.root, 160,160, &wxpos,&wypos,
&dummy);
eassert(r);
+}
+static void set_focus(void) {
int screen= XScreenNumberOfScreen(attr.screen);
- XTestFakeMotionEvent(disp,screen, xpos, ypos, 0);
+
+ fprintf(stderr,"PAGING set_focus\n");
+
+ XTestFakeMotionEvent(disp,screen, wxpos,wypos, 0);
XTestFakeButtonEvent(disp,1,1, 50);
XTestFakeButtonEvent(disp,1,0, 50);
assert(sm->rshift < LONG_BIT);
}
-static void store_page(int pageno, Snapshot *sn) {
- eassert(pageno < MAX_PAGES);
+static CanonImage *convert_page(Snapshot *sn) {
ShMask shiftmasks[3];
CanonImage *im;
rgb |= ((xrgb << shiftmasks[i].lshift)
>> shiftmasks[i].rshift) & shiftmasks[i].mask;
});
-
- page_images[pageno]= im;
+
+ return im;
}
static void read_pages(void) {
Snapshot *current=0, *last=0;
+ CanonImage *test;
- raise_and_set_focus();
+ /* find the window and check it's on the right kind of screen */
+ raise_and_get_details();
+ snapshot(¤t);
+ test= convert_page(current);
+ find_structure(test);
+ free(test);
/* page to the top - keep pressing page up until the image stops changing */
+ set_focus();
wait_for_stability(¤t,0, send_pgup_many);
/* now to actually page down */
for (;;) {
- fprintf(stderr,"PAGING page %d\n",npages);
- store_page(npages, current);
+ fprintf(stderr,"paging page %d\n",npages);
+
+ eassert(npages < MAX_PAGES);
+ page_images[npages]= convert_page(current);
free_snapshot(&last); last=current; current=0;
+
fprintf(stderr,"PAGING page %d converted\n",npages);
wait_for_stability(¤t,last, 0);