mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	This commit is contained in:
		
							
								
								
									
										15
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -1349,9 +1349,9 @@ void ImGuiIO::ClearInputKeys()
 | 
			
		||||
    MouseWheel = MouseWheelH = 0.0f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ImGuiInputEvent* FindLatestInputEvent(ImGuiInputEventType type, int arg = -1)
 | 
			
		||||
static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    ImGuiContext& g = *ctx;
 | 
			
		||||
    for (int n = g.InputEventsQueue.Size - 1; n >= 0; n--)
 | 
			
		||||
    {
 | 
			
		||||
        ImGuiInputEvent* e = &g.InputEventsQueue[n];
 | 
			
		||||
@@ -1393,8 +1393,11 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
 | 
			
		||||
        BackendUsingLegacyNavInputArray = false;
 | 
			
		||||
 | 
			
		||||
    // Filter duplicate (in particular: key mods and gamepad analog values are commonly spammed)
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Key, (int)key);
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)key);
 | 
			
		||||
    ImGuiContext* prev_ctx = GImGui;
 | 
			
		||||
    ImGui::SetCurrentContext(Ctx);
 | 
			
		||||
    const ImGuiKeyData* key_data = ImGui::GetKeyData(key);
 | 
			
		||||
    ImGui::SetCurrentContext(prev_ctx);
 | 
			
		||||
    const bool latest_key_down = latest_event ? latest_event->Key.Down : key_data->Down;
 | 
			
		||||
    const float latest_key_analog = latest_event ? latest_event->Key.AnalogValue : key_data->AnalogValue;
 | 
			
		||||
    if (latest_key_down == down && latest_key_analog == analog_value)
 | 
			
		||||
@@ -1460,7 +1463,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
 | 
			
		||||
    ImVec2 pos((x > -FLT_MAX) ? ImFloorSigned(x) : x, (y > -FLT_MAX) ? ImFloorSigned(y) : y);
 | 
			
		||||
 | 
			
		||||
    // Filter duplicate
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MousePos);
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MousePos);
 | 
			
		||||
    const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos;
 | 
			
		||||
    if (latest_pos.x == pos.x && latest_pos.y == pos.y)
 | 
			
		||||
        return;
 | 
			
		||||
@@ -1482,7 +1485,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    // Filter duplicate
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MouseButton, (int)mouse_button);
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
 | 
			
		||||
    const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
 | 
			
		||||
    if (latest_button_down == down)
 | 
			
		||||
        return;
 | 
			
		||||
@@ -1519,7 +1522,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
 | 
			
		||||
    ImGuiContext& g = *Ctx;
 | 
			
		||||
 | 
			
		||||
    // Filter duplicate
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Focus);
 | 
			
		||||
    const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
 | 
			
		||||
    const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
 | 
			
		||||
    if (latest_focused == focused)
 | 
			
		||||
        return;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user