mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
IO: modify io.AddFocusEvent() to tolerate in/out for multi-viewports. Amend 2f40be6
. (merged from docking) (#3532)
This commit is contained in:
22
imgui.cpp
22
imgui.cpp
@ -1185,13 +1185,8 @@ void ImGuiIO::ClearInputCharacters()
|
||||
InputQueueCharacters.resize(0);
|
||||
}
|
||||
|
||||
void ImGuiIO::AddFocusEvent(bool focused)
|
||||
void ImGuiIO::ClearInputKeys()
|
||||
{
|
||||
if (focused)
|
||||
return;
|
||||
|
||||
// Clear buttons state when focus is lost
|
||||
// (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
||||
memset(KeysDown, 0, sizeof(KeysDown));
|
||||
for (int n = 0; n < IM_ARRAYSIZE(KeysDownDuration); n++)
|
||||
KeysDownDuration[n] = KeysDownDurationPrev[n] = -1.0f;
|
||||
@ -1201,6 +1196,13 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
||||
NavInputsDownDuration[n] = NavInputsDownDurationPrev[n] = -1.0f;
|
||||
}
|
||||
|
||||
void ImGuiIO::AddFocusEvent(bool focused)
|
||||
{
|
||||
// We intentionally overwrite this and process in NewFrame(), in order to give a chance
|
||||
// to multi-viewports backends to queue AddFocusEvent(false),AddFocusEvent(true) in same frame.
|
||||
AppFocusLost = !focused;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -4070,6 +4072,14 @@ void ImGui::NewFrame()
|
||||
g.DragDropWithinTarget = false;
|
||||
g.DragDropHoldJustPressedId = 0;
|
||||
|
||||
// Clear buttons state when focus is lost
|
||||
// (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
||||
if (g.IO.AppFocusLost)
|
||||
{
|
||||
g.IO.ClearInputKeys();
|
||||
g.IO.AppFocusLost = false;
|
||||
}
|
||||
|
||||
// Update keyboard input state
|
||||
// Synchronize io.KeyMods with individual modifiers io.KeyXXX bools
|
||||
g.IO.KeyMods = GetMergedKeyModFlags();
|
||||
|
Reference in New Issue
Block a user