chiark / gitweb /
check for unexpected mouse pointer motion 4.3
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 21 Oct 2009 22:46:03 +0000 (23:46 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 21 Oct 2009 22:46:03 +0000 (23:46 +0100)
yarrg/pages.c

index ff2672d9709b271bfb870f432a2e840b29df664f..28364a07381d0035b21b5907af7486bc7aaab53f 100644 (file)
@@ -154,6 +154,28 @@ static void check_not_disturbed(void) {
   }
 }      
 
+static void check_pointer_not_disturbed(void) {
+  Window got_root, got_child;
+  int got_root_x, got_root_y;
+  int got_win_x, got_win_y;
+  unsigned got_mask;
+
+  int r= XQueryPointer(disp,id, &got_root,&got_child,
+                      &got_root_x, &got_root_y,
+                      &got_win_x, &got_win_y,
+                      &got_mask);
+  if (!r ||
+      got_win_x!=commod_page_point.x ||
+      got_win_y!=commod_page_point.y) {
+    progress("");
+    fprintf(stderr,"\nunexpected mouse position:"
+           " samescreen=%d got=%dx%d want=%dx%d",
+           r, got_win_x,got_win_y,
+           commod_page_point.x,commod_page_point.y);
+    fatal("Mouse pointer moved.");
+  }
+}
+
 static void send_key(KeySym sym) {
   check_not_disturbed();
   XTestFakeKeyEvent(disp, keycode(sym),1, 0);
@@ -174,6 +196,7 @@ static void send_mouse_1_updown(int x, int y) {
 }
 static void pgdown_by_mouse(void) {
   check_not_disturbed();
+  check_pointer_not_disturbed();
   debugf("PAGING   Mouse\n");
   send_mouse_1_updown_here();
   sync_after_input();