message: Improve ImGui mouse event queuing
diff: @@ -70,7 +70,7 @@ struct viewer_glut::impl
  // when the mouse button was released in the same frame
  // See: https://github.com/ocornut/imgui/issues/1992
  // TODO: check if new ImGui API has better support for this
  - static bool imgui_was_mouse_down[5];
  + static int imgui_mouse_count[5];
  impl(viewer_glut* instance);
  @@ -105,7 +105,7 @@ viewer_glut* viewer_glut::impl::viewer = nullptr;
  mouse::button viewer_glut::impl::down_button = mouse::NoButton;
  int viewer_glut::impl::win_id = 0;
  GLuint viewer_glut::impl::imgui_font_texture = 0;
  -bool viewer_glut::impl::imgui_was_mouse_down[] = { false };
  +int viewer_glut::impl::imgui_mouse_count[] = { 0 };
  //-------------------------------------------------------------------------------------------------
  @@ -406,12 +406,24 @@ void viewer_glut::impl::display_func()
  for (int i = 0; i < 5; ++i)
  {
  - io.MouseDown[i] = imgui_was_mouse_down[i];
  - imgui_was_mouse_down[i] = false;
  + if (imgui_mouse_count[i] > 0 && imgui_mouse_count[i] % 2 == 0)
  + {
  + io.MouseDown[i] = true;
  + }
  }
  ImGui::NewFrame();
  + for (int i = 0; i < 5; ++i)
  + {
  + if (imgui_mouse_count[i] > 0 && imgui_mouse_count[i] % 2 == 0)
  + {
  + io.MouseDown[i] = false;
  + }
  +
  + imgui_mouse_count[i] = 0;
  + }
  +
  viewer->on_display();
  ImGui::Render();
  @@ -544,13 +556,15 @@ void viewer_glut::impl::mouse_func(int button, int state, int x, int y)
  if (state == GLUT_DOWN)
  {
  - imgui_was_mouse_down[imgui_button] = true;
  + io.MouseDown[imgui_button] = true;
  }
  else if (state == GLUT_UP)
  {
  io.MouseDown[imgui_button] = false;
  }
  + ++imgui_mouse_count[imgui_button];
  +
  // viewer
  mouse::pos p = { x, y };
  