|
@@ -7973,17 +7973,17 @@ static const char* GetInputSourceName(ImGuiInputSource source)
|
|
|
IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT && source >= 0 && source < ImGuiInputSource_COUNT);
|
|
|
return input_source_names[source];
|
|
|
}
|
|
|
-#endif
|
|
|
-
|
|
|
-/*static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
|
|
|
+static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
|
|
|
{
|
|
|
- if (e->Type == ImGuiInputEventType_MousePos) { IMGUI_DEBUG_LOG_IO("%s: MousePos (%.1f %.1f)\n", prefix, e->MousePos.PosX, e->MousePos.PosY); return; }
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ if (e->Type == ImGuiInputEventType_MousePos) { IMGUI_DEBUG_LOG_IO("%s: MousePos (%.1f, %.1f)\n", prefix, e->MousePos.PosX, e->MousePos.PosY); return; }
|
|
|
if (e->Type == ImGuiInputEventType_MouseButton) { IMGUI_DEBUG_LOG_IO("%s: MouseButton %d %s\n", prefix, e->MouseButton.Button, e->MouseButton.Down ? "Down" : "Up"); return; }
|
|
|
- if (e->Type == ImGuiInputEventType_MouseWheel) { IMGUI_DEBUG_LOG_IO("%s: MouseWheel (%.1f %.1f)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY); return; }
|
|
|
+ if (e->Type == ImGuiInputEventType_MouseWheel) { IMGUI_DEBUG_LOG_IO("%s: MouseWheel (%.1f, %.1f)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY); return; }
|
|
|
if (e->Type == ImGuiInputEventType_Key) { IMGUI_DEBUG_LOG_IO("%s: Key \"%s\" %s\n", prefix, ImGui::GetKeyName(e->Key.Key), e->Key.Down ? "Down" : "Up"); return; }
|
|
|
if (e->Type == ImGuiInputEventType_Text) { IMGUI_DEBUG_LOG_IO("%s: Text: %c (U+%08X)\n", prefix, e->Text.Char, e->Text.Char); return; }
|
|
|
if (e->Type == ImGuiInputEventType_Focus) { IMGUI_DEBUG_LOG_IO("%s: AppFocused %d\n", prefix, e->AppFocused.Focused); return; }
|
|
|
-}*/
|
|
|
+}
|
|
|
+#endif
|
|
|
|
|
|
// Process input queue
|
|
|
// We always call this with the value of 'bool g.IO.ConfigInputTrickleEventQueue'.
|
|
@@ -8006,13 +8006,14 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|
|
int event_n = 0;
|
|
|
for (; event_n < g.InputEventsQueue.Size; event_n++)
|
|
|
{
|
|
|
- const ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
|
|
|
+ ImGuiInputEvent* e = &g.InputEventsQueue[event_n];
|
|
|
if (e->Type == ImGuiInputEventType_MousePos)
|
|
|
{
|
|
|
ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY);
|
|
|
if (IsMousePosValid(&event_pos))
|
|
|
event_pos = ImVec2(ImFloorSigned(event_pos.x), ImFloorSigned(event_pos.y)); // Apply same flooring as UpdateMouseInputs()
|
|
|
- if (io.MousePos.x != event_pos.x || io.MousePos.y != event_pos.y)
|
|
|
+ e->IgnoredAsSame = (io.MousePos.x == event_pos.x && io.MousePos.y == event_pos.y);
|
|
|
+ if (!e->IgnoredAsSame)
|
|
|
{
|
|
|
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
|
|
|
if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputted))
|
|
@@ -8025,7 +8026,8 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|
|
{
|
|
|
const ImGuiMouseButton button = e->MouseButton.Button;
|
|
|
IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
|
|
|
- if (io.MouseDown[button] != e->MouseButton.Down)
|
|
|
+ e->IgnoredAsSame = (io.MouseDown[button] == e->MouseButton.Down);
|
|
|
+ if (!e->IgnoredAsSame)
|
|
|
{
|
|
|
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
|
|
if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
|
|
@@ -8036,7 +8038,8 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|
|
}
|
|
|
else if (e->Type == ImGuiInputEventType_MouseWheel)
|
|
|
{
|
|
|
- if (e->MouseWheel.WheelX != 0.0f || e->MouseWheel.WheelY != 0.0f)
|
|
|
+ e->IgnoredAsSame = (e->MouseWheel.WheelX == 0.0f && e->MouseWheel.WheelY == 0.0f);
|
|
|
+ if (!e->IgnoredAsSame)
|
|
|
{
|
|
|
// Trickling Rule: Stop processing queued events if we got multiple action on the event
|
|
|
if (trickle_fast_inputs && (mouse_moved || mouse_button_changed != 0))
|
|
@@ -8052,7 +8055,8 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|
|
IM_ASSERT(key != ImGuiKey_None);
|
|
|
const int keydata_index = (key - ImGuiKey_KeysData_OFFSET);
|
|
|
ImGuiKeyData* keydata = &io.KeysData[keydata_index];
|
|
|
- if (keydata->Down != e->Key.Down || keydata->AnalogValue != e->Key.AnalogValue)
|
|
|
+ e->IgnoredAsSame = (keydata->Down == e->Key.Down && keydata->AnalogValue == e->Key.AnalogValue);
|
|
|
+ if (!e->IgnoredAsSame)
|
|
|
{
|
|
|
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
|
|
if (trickle_fast_inputs && keydata->Down != e->Key.Down && (key_changed_mask.TestBit(keydata_index) || text_inputted || mouse_button_changed != 0))
|
|
@@ -8093,7 +8097,10 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|
|
{
|
|
|
// We intentionally overwrite this and process lower, in order to give a chance
|
|
|
// to multi-viewports backends to queue AddFocusEvent(false) + AddFocusEvent(true) in same frame.
|
|
|
- io.AppFocusLost = !e->AppFocused.Focused;
|
|
|
+ const bool focus_lost = !e->AppFocused.Focused;
|
|
|
+ e->IgnoredAsSame = (io.AppFocusLost == focus_lost);
|
|
|
+ if (!e->IgnoredAsSame)
|
|
|
+ io.AppFocusLost = focus_lost;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -8107,9 +8114,11 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|
|
g.InputEventsTrail.push_back(g.InputEventsQueue[n]);
|
|
|
|
|
|
// [DEBUG]
|
|
|
- /*if (event_n != 0)
|
|
|
+#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
|
|
+ if (event_n != 0 && (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO))
|
|
|
for (int n = 0; n < g.InputEventsQueue.Size; n++)
|
|
|
- DebugPrintInputEvent(n < event_n ? "Processed" : "Remaining", &g.InputEventsQueue[n]);*/
|
|
|
+ DebugPrintInputEvent(n < event_n ? (g.InputEventsQueue[n].IgnoredAsSame ? "Processed (Same)" : "Processed") : "Remaining", &g.InputEventsQueue[n]);
|
|
|
+#endif
|
|
|
|
|
|
// Remaining events will be processed on the next frame
|
|
|
if (event_n == g.InputEventsQueue.Size)
|
|
@@ -13265,6 +13274,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
|
|
SameLine(); CheckboxFlags("Focus", &g.DebugLogFlags, ImGuiDebugLogFlags_EventFocus);
|
|
|
SameLine(); CheckboxFlags("Popup", &g.DebugLogFlags, ImGuiDebugLogFlags_EventPopup);
|
|
|
SameLine(); CheckboxFlags("Nav", &g.DebugLogFlags, ImGuiDebugLogFlags_EventNav);
|
|
|
+ SameLine(); CheckboxFlags("IO", &g.DebugLogFlags, ImGuiDebugLogFlags_EventIO);
|
|
|
|
|
|
if (SmallButton("Clear"))
|
|
|
g.DebugLogBuf.clear();
|