chiark / gitweb /
When setting focus on commodities, always use top left corner of table
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Jul 2009 22:38:39 +0000 (23:38 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Jul 2009 22:38:39 +0000 (23:38 +0100)
pctb/convert.h
pctb/pages.c
pctb/structure.c

index ba13c43..44784ea 100644 (file)
@@ -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);
index 0102999..ecec334 100644 (file)
@@ -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(&current,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();
 
index e9df733..85b8f86 100644 (file)
@@ -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; page<npages; page++) {
-    find_structure(page_images[page], 0);
+    find_structure(page_images[page], 0, 0);
 
     if (!page)
       check_correct_commodities();
@@ -693,7 +700,7 @@ Rect find_sunshine_widget(void) {
 }
 
 void find_islandname(void) {
-  find_structure(page_images[0], 0);
+  find_structure(page_images[0], 0, 0);
 
   RgbImage *ri= alloc_rgb_image(page_images[0]->rgb->w,
                                page_images[0]->rgb->h);