Browse Source

Inputs, Viewports: fix UpdateViewportsNewFrame() running before UpdateInputEvents(), leading to MouseViewport lagging by a frame on transitions. (#5837, #4921)

Will merge the swap in master.
cfillion 2 years ago
parent
commit
ced92d9c52
2 changed files with 8 additions and 4 deletions
  1. 3 0
      docs/CHANGELOG.txt
  2. 5 4
      imgui.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -418,6 +418,9 @@ Docking+Viewports Branch:
 - Docking: Fixed incorrect focus highlight on docking node when focusing empty central node
   or a child window which was manually injected into a dockspace window.
 - Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401)
+- Viewports: Fixed an issue where MouseViewport was lagging by a frame when using 1.87 Input Queue.
+  A common side-effect would be that when releasing a window drag the underlying window would highlight
+  for a frame. (#5837, #4921) [@cfillion]
 - Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057)
 - Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize
   when multi-viewports are disabled. (#4900)

+ 5 - 4
imgui.cpp

@@ -4666,6 +4666,11 @@ void ImGui::NewFrame()
     g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame));
     g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX;
 
+    // Process input queue (trickle as many events as possible), turn events into writes to IO structure
+    g.InputEventsTrail.resize(0);
+    UpdateInputEvents(g.IO.ConfigInputTrickleEventQueue);
+
+    // Update viewports (after processing input queue, so io.MouseHoveredViewport is set)
     UpdateViewportsNewFrame();
 
     // Setup current font and draw list shared data
@@ -4788,10 +4793,6 @@ void ImGui::NewFrame()
     //if (g.IO.AppFocusLost)
     //    ClosePopupsExceptModals();
 
-    // Process input queue (trickle as many events as possible)
-    g.InputEventsTrail.resize(0);
-    UpdateInputEvents(g.IO.ConfigInputTrickleEventQueue);
-
     // Update keyboard input state
     UpdateKeyboardInputs();