From ca2598d063219f019ba8e04a4762552f556795ca Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 5 Jul 2009 23:38:39 +0100 Subject: [PATCH] When setting focus on commodities, always use top left corner of table --- pctb/convert.h | 3 ++- pctb/pages.c | 5 +++-- pctb/structure.c | 13 ++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pctb/convert.h b/pctb/convert.h index ba13c43..44784ea 100644 --- a/pctb/convert.h +++ b/pctb/convert.h @@ -69,7 +69,8 @@ static inline Rgb ri_rgb(const RgbImage *ri, int x, int y) { /*----- from structure.c -----*/ -void find_structure(CanonImage *im, int *max_relevant_y_r); +void find_structure(CanonImage *im, int *max_relevant_y_r, + Point *commod_focus_point_r); Rect find_sunshine_widget(void); void canon_colour_prepare(void); diff --git a/pctb/pages.c b/pctb/pages.c index 0102999..ecec334 100644 --- a/pctb/pages.c +++ b/pctb/pages.c @@ -52,6 +52,7 @@ static Display *disp; static struct timeval tv_startup; static unsigned wwidth, wheight; static int max_relevant_y= -1; +static Point commod_focus_point; static XImage *shmim; static XShmSegmentInfo shminfo; @@ -497,7 +498,7 @@ static void set_focus_commodity(void) { debugf("PAGING set_focus\n"); - mouse_1_updown(160,160); + mouse_1_updown(commod_focus_point.x, commod_focus_point.y); sync_after_input(); delay(0.5); @@ -543,7 +544,7 @@ static void prepare_ypp_client(void) { wait_for_stability(¤t,0,0, "checking current YPP client screen..."); test= convert_page(current); - find_structure(test, &max_relevant_y); + find_structure(test, &max_relevant_y, &commod_focus_point); check_correct_commodities(); Rect sunshine= find_sunshine_widget(); diff --git a/pctb/structure.c b/pctb/structure.c index e9df733..85b8f86 100644 --- a/pctb/structure.c +++ b/pctb/structure.c @@ -255,7 +255,8 @@ static int commod_selector_matches(Rect search, const char *const *all, (search).TLBR.XY += increm; \ } -void find_structure(CanonImage *im, int *max_relevant_y_r) { +void find_structure(CanonImage *im, int *max_relevant_y_r, + Point *commod_focus_point_r) { cim= im; Rect whole = { {0,0}, {cim->w-1,cim->h-1} }; @@ -365,6 +366,12 @@ void find_structure(CanonImage *im, int *max_relevant_y_r) { if (max_relevant_y_r) SET_ONCE(*max_relevant_y_r, mainr.br.y + 10); + if (commod_focus_point_r) { + *commod_focus_point_r= mainr.tl; + commod_focus_point_r->x += 10; + commod_focus_point_r->y += comminty/3; + } + MUST( text_h <= OCR_MAX_H, MI(text_h) ); } @@ -632,7 +639,7 @@ void analyse(FILE *tsv_output) { int page, tryrect, colno; for (page=0; pagergb->w, page_images[0]->rgb->h); -- 2.30.2