Fix of asserting ImGui:

ImGui does not want the io flags to change in between NewFrame and EndFrame.
We did that - e.g. after a key down-key up combination with no render in between,
or when key down and mouse move event were processed with no render in between.
An assert was added in imgui to detect this between 1.75 and 1.83, which
made the issue visible.
Solution: only call the new_frame function in update_key_data/update_mouse_data
when imgui actually consumes the input. This forces immediate render so
EndFrame will be called.
This commit is contained in:
Lukas Matena 2021-07-21 12:55:25 +02:00
parent 9264b79be7
commit 7acaf58c15

View File

@ -204,7 +204,8 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
unsigned buttons = (evt.LeftIsDown() ? 1 : 0) | (evt.RightIsDown() ? 2 : 0) | (evt.MiddleIsDown() ? 4 : 0);
m_mouse_buttons = buttons;
new_frame();
if (want_mouse())
new_frame();
return want_mouse();
}
@ -222,9 +223,6 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
if (key != 0) {
io.AddInputCharacter(key);
}
new_frame();
return want_keyboard() || want_text_input();
} else {
// Key up/down event
int key = evt.GetKeyCode();
@ -235,10 +233,11 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
io.KeyCtrl = evt.ControlDown();
io.KeyAlt = evt.AltDown();
io.KeySuper = evt.MetaDown();
new_frame();
return want_keyboard() || want_text_input();
}
bool ret = want_keyboard() || want_text_input();
if (ret)
new_frame();
return ret;
}
void ImGuiWrapper::new_frame()