/*----- from structure.c -----*/
void find_structure(CanonImage *im, int *max_relevant_y_r,
- Point *commod_focus_point_r);
+ Point *commod_focus_point_r,
+ Point *commod_page_point_r,
+ Point *commod_focuslast_point_r);
Rect find_sunshine_widget(void);
void canon_colour_prepare(void);
static struct timeval tv_startup;
static unsigned wwidth, wheight;
static int max_relevant_y= -1;
-static Point commod_focus_point;
+static Point commod_focus_point, commod_page_point, commod_focuslast_point;
static XImage *shmim;
static XShmSegmentInfo shminfo;
Window dummy;
xassert( XTranslateCoordinates(disp, id,attr.root, wx,wy, rx,ry, &dummy) );
}
+static void translate_coords_toroot_p(Point w, int *rx, int *ry) {
+ translate_coords_toroot(w.x, w.y, rx, ry);
+}
static void check_client_window_all_on_screen(void) {
Rect onroot;
}
static void mouse_1_updown_here(void) {
check_not_disturbed();
- XTestFakeButtonEvent(disp,1,1, 50);
- XTestFakeButtonEvent(disp,1,0, 50);
+ XTestFakeButtonEvent(disp,1,1, 10);
+ XTestFakeButtonEvent(disp,1,0, 10);
}
static void mouse_1_updown(int x, int y) {
check_not_disturbed();
XTestFakeMotionEvent(disp, screen, xpos,ypos, 0);
mouse_1_updown_here();
}
+static void pgdown_by_mouse(void) {
+ check_not_disturbed();
+ debugf("PAGING Mouse\n");
+ mouse_1_updown_here();
+ sync_after_input();
+}
static int pgupdown;
debugf("PAGING PageUp x %d\n",i);
sync_after_input();
}
-static void send_pgdown(void) {
- send_key(XK_Next);
- pgupdown++;
- debugf("PAGING PageDown\n");
- sync_after_input();
-}
static void send_pgdown_torestore(void) {
debugf("PAGING PageDown x %d\n", -pgupdown);
while (pgupdown < 0) {
) );
int xpos,ypos;
- translate_coords_toroot(10,10, &xpos,&ypos);
- XTestFakeMotionEvent(disp,screen, xpos,ypos, 0);
+ translate_coords_toroot_p(commod_page_point, &xpos,&ypos);
+ XTestFakeMotionEvent(disp, screen, xpos,ypos, 0);
sync_after_input();
wait_for_stability(¤t,0,0, "checking current YPP client screen...");
test= convert_page(current);
- find_structure(test, &max_relevant_y, &commod_focus_point);
+ find_structure(test, &max_relevant_y,
+ &commod_focus_point,
+ &commod_page_point,
+ &commod_focuslast_point);
check_correct_commodities();
Rect sunshine= find_sunshine_widget();
break;
}
- send_pgdown();
+ pgdown_by_mouse();
npages++;
}
progress("finishing with the YPP client...");
+ mouse_1_updown(commod_focuslast_point.x, commod_focuslast_point.y);
+ sync_after_input();
send_pgdown_torestore();
+ sync_after_input();
debugf("PAGING all done.\n");
progress_log("collected %d screenshots.",npages);
}
void find_structure(CanonImage *im, int *max_relevant_y_r,
- Point *commod_focus_point_r) {
+ Point *commod_focus_point_r,
+ Point *commod_page_point_r,
+ Point *commod_focuslast_point_r) {
cim= im;
Rect whole = { {0,0}, {cim->w-1,cim->h-1} };
Point csb_p; \
Rect csb_r; \
csb_p= mainr.tl; \
+ csb_p.x++; csb_p.y++; \
csb_p.xy= mainr.tlbr.xy; \
if (get_p(csb_p)=='+') { \
csb_r= mainr; \
}
MUST( colno >= MIN_COLUMNS, MI(colno);MR(mainr);MR(across); );
+ const int pagerh= 6;
+ Rect pager= {{ mainr.br.x, mainr.br.y - (pagerh-1) },
+ { mainr.br.x + 1, mainr.br.y }};
+
+ debug_rect("pager",__LINE__,pager);
+ ADJUST_BOX(pager, "o",>=,pagerh-2, whole.br.x,MUST, br,x,+1);
+ debug_rect("pager",__LINE__,pager);
+
+ pager.tl.x= pager.br.x;
+ pager.br.x= pager.br.x + 1;
+ debug_rect("pager",__LINE__,pager);
+ ADJUST_BOX(pager, "o",>=,pagerh-2, whole.br.x,MUST, br,x,+1);
+ debug_rect("pager",__LINE__,pager);
+
+ ADJUST_BOX(pager, "o",>=,RECT_W(pager)-2, mainr.tl.y,LIMIT_QUITEQ, tl,y,-1);
+ debug_rect("pager",__LINE__,pager);
+
#define SET_ONCE(var,val) do{ \
int v= (val); \
if ((var)==-1) (var)= v; \
commod_focus_point_r->x += 10;
commod_focus_point_r->y += comminty/3;
}
+ if (commod_focuslast_point_r) {
+ *commod_focuslast_point_r= mainr.br;
+ commod_focuslast_point_r->x -= 10;
+ commod_focuslast_point_r->y -= comminty/3;
+ }
+ if (commod_page_point_r) {
+ commod_page_point_r->x= (pager.tl.x + pager.br.x) / 2;
+ commod_page_point_r->y= pager.tl.y - 1;
+ }
MUST( text_h <= OCR_MAX_H, MI(text_h) );
}
int page, tryrect, colno;
for (page=0; page<npages; page++) {
- find_structure(page_images[page], 0, 0);
+ find_structure(page_images[page], 0,0,0,0);
if (!page)
check_correct_commodities();
}
void find_islandname(void) {
- find_structure(page_images[0], 0, 0);
+ find_structure(page_images[0], 0,0,0,0);
RgbImage *ri= alloc_rgb_image(page_images[0]->rgb->w,
page_images[0]->rgb->h);