chiark / gitweb /
When setting focus on commodities, always use top left corner of table
[ypp-sc-tools.main.git] / pctb / pages.c
index 433ea36bfcbf9900385a86414a434a0e85dfdab2..ecec334e88d24ba51fbc1a29c5041441871a98e6 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);
@@ -516,18 +517,16 @@ static void set_focus_commodity(void) {
   debugf("PAGING raise_and_set_focus done.\n");
 }
 
-static CanonImage *convert_page(Snapshot *sn) {
+static CanonImage *convert_page(const Snapshot *sn) {
   CanonImage *im;
 
   fwrite_ppmraw(screenshot_file, sn);
 
-  unsigned char *pixel= sn->data;
+  const unsigned char *pixel= sn->data;
   CANONICALISE_IMAGE(im, sn->w, sn->h, {
-    rgb=
-      (pixel[0] << 16) |
-      (pixel[1] <<  8) |
-      (pixel[2]      );
-    pixel += 3;
+    r= *pixel++;
+    g= *pixel++;
+    b= *pixel++;
   });
     
   sysassert(!ferror(screenshot_file));
@@ -545,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();