以下のコードが気になる。

message_count を減少させるのは唯一、wait_message() しか見つからなかった。
後は、check_for_driver_events() の中で単調増加してしまう。
メッセージがたまって初めて、flush_window_surfaces() が呼び出されるような
コードにも

/* check for driver events if we detect that the app is not properly consuming messages */
static inline void check_for_driver_events( UINT msg )
{
  if (get_user_thread_info()->message_count > 200) {
    flush_window_surfaces( FALSE );
    USER_Driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_ALLINPUT, 0 );
  }
  else if (msg == WM_TIMER || msg == WM_SYSTIMER) {
    /* driver events should have priority over timers, so make sure we'll check for them soon */
    get_user_thread_info()->message_count += 100;
  }
  else get_user_thread_info()->message_count++;
}

static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags )
{
  DWORD ret = USER_Driver->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
  if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution();
  if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0;
  return ret;
}