}   if ((got_pointer_calls > got_pointer_input) || (got_keyboard_calls > got_keyboard_input)) { eat_viewonly_input(10, 3);
static void watch_loop(void) {	int cnt = 0, tile_diffs = 0, skip_pe = 0;	double tm, dtr, dt = 0.0;	time_t start = time(0);	if (use_threads) {		rfbRunEventLoop(screen, -1, TRUE);	}	while (1) {		got_user_input = 0;		got_pointer_input = 0;		got_keyboard_input = 0;		urgent_update = 0;		if (! use_threads) {			dtime0(&tm);			if (! skip_pe) {				measure_send_rates(1);				rfbPE(-1);				measure_send_rates(0);				fb_update_sent(NULL);			}			dtr = dtime(&tm);			if (! cursor_shape_updates) {				/* undo any cursor shape requests */				disable_cursor_shape_updates(screen);			}			if (screen && screen->clientHead) {				int ret = check_user_input(dt, dtr,				    tile_diffs, &cnt);				/* true means loop back for more input */				if (ret == 2) {					skip_pe = 1;				}				if (ret) {if (debug_scroll) fprintf(stderr, "watch_loop: LOOP-BACK: %d\n", ret);					continue;				}			}		} else {			if (0 && use_xrecord) {				/* XXX not working */				check_xrecord();			}			if (wireframe && button_mask) {				check_wireframe();			}		}		skip_pe = 0;		if (shut_down) {			clean_up_exit(0);		}		if (! urgent_update) {			if (do_copy_screen) {				do_copy_screen = 0;				copy_screen();			}			check_new_clients();			check_xevents();			check_autorepeat();			check_keycode_state();			check_connect_inputs();					check_padded_fb();					check_fixscreen();					check_xdamage_state();			check_xrecord_reset(0);			check_add_keysyms();			if (started_as_root) {				check_switched_user();			}			if (first_conn_timeout < 0) {				start = time(0);				first_conn_timeout = -first_conn_timeout;			}		}		if (! screen || ! screen->clientHead) {			/* waiting for a client */			if (first_conn_timeout) {				if (time(0) - start > first_conn_timeout) {					rfbLog("No client after %d secs.\n",					    first_conn_timeout);					shut_down = 1;				}			}			usleep(200 * 1000);			continue;		}		if (first_conn_timeout && all_clients_initialized()) {			first_conn_timeout = 0;		}		if (nofb) {			/* no framebuffer polling needed */			if (cursor_pos_updates) {				check_x11_pointer();			}			continue;		}		if (button_mask && (!show_dragging || pointer_mode == 0)) {			/*			 * if any button is pressed do not update rfb			 * screen, but do flush the X11 display.			 */			X_LOCK;			XFlush(dpy);			X_UNLOCK;			dt = 0.0;		} else {			static double last_dt = 0.0;			double xdamage_thrash = 0.4; 			check_cursor_changes();			/* for timing the scan to try to detect thrashing */			if (use_xdamage && last_dt > xdamage_thrash)  {				clear_xdamage_mark_region(NULL, 0);			}			dtime0(&tm);			if (use_snapfb) {				int t, tries = 5;				copy_snap();				for (t =0; t < tries; t++) {					tile_diffs = scan_for_updates(0);				}			} else {				tile_diffs = scan_for_updates(0);			}			dt = dtime(&tm);			if (! nap_ok) {				last_dt = dt;			}if ((debug_tiles || debug_scroll > 1 || debug_wireframe > 1)    && (tile_diffs > 4 || debug_tiles > 1)) {	double rate = (tile_x * tile_y * bpp/8 * tile_diffs) / dt;	fprintf(stderr, "============================= TILES: %d  dt: %.4f"	    "  t: %.4f  %.2f MB/s\n", tile_diffs, dt, tm - x11vnc_start,	    rate/1000000.0);}		}		/* sleep a bit to lessen load */		if (! urgent_update) {			int wait = choose_delay(dt);			if (wait > 2*waitms) {				/* bog case, break it up */				nap_sleep(wait, 10);			} else {				usleep(wait * 1000);			}		}		cnt++;	}}