Update imgui 1.91.3 -> 1.92.1

This commit is contained in:
Guillaume Meunier
2025-07-26 11:18:58 +02:00
parent 96083cd02e
commit 794f2e3468
9 changed files with 87 additions and 198 deletions
+4 -4
View File
@@ -274,11 +274,11 @@ FetchContent_Declare(stb EXCLUDE_FROM_ALL SYSTEM URL https://github.co
FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM
GIT_REPOSITORY https://github.com/KhronosGroup/KTX-Software
GIT_TAG 91ace88675ac59a97e55d0378a6602a9ae6b98bd)
FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/refs/tags/v0.16.tar.gz
URL_HASH SHA256=961df327d8a756304d1b0a67316eebdb1111d13d559f0d3415114ec0eb30abd1)
FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/3da8bd34299965d3b0ab124df743fe3e076fa222.zip
URL_HASH SHA256=e9b439a94aa6f09fcf12ed9c2cd784efe5e99e96242122aa683e690b29f7a59f)
file(GLOB IMGUI_PATCHES CONFIGURE_DEPENDS patches/imgui/*)
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.3.tar.gz
URL_HASH SHA256=29949d7b300c30565fbcd66398100235b63aa373acfee0b76853a7aeacd1be28
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.1.tar.gz
URL_HASH SHA256=32c237c2abf67a2ffccaac17192f711d4a787554b4133187a153d49057d6109c
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${IMGUI_PATCHES}
)
FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.com/uni-algo/uni-algo/archive/v1.2.0.tar.gz
+39 -139
View File
@@ -382,46 +382,9 @@ imgui_context::imgui_context(vk::raii::PhysicalDevice physical_device, vk::raii:
style.Colors[ImGuiCol_ModalWindowDimBg] = {0, 0, 0, 0};
}
void imgui_context::add_chars(std::string_view sv)
{
for (auto it = sv.begin(); it != sv.end();)
{
ImWchar c = (ImWchar)*it;
if (c < 0x80)
++it;
else
it += ImTextCharFromUtf8(&c, it, sv.end());
if (!glyph_range_builder.GetBit(c))
{
glyph_range_builder.AddChar(c);
glyph_range_dirty = true;
}
}
}
#ifdef __ANDROID__
static std::vector<std::string> find_font(const ImFontGlyphRangesBuilder & glyph_range_builder, const std::string & locale)
static std::vector<std::string> find_font(std::u16string_view sample_text, const std::string & locale)
{
std::u16string wtext;
std::u16string_view wtextview;
for (int i = 0; i < glyph_range_builder.UsedChars.Size; ++i)
{
std::uint32_t used_chars = glyph_range_builder.UsedChars[i];
if (used_chars == 0)
continue;
for (int j = 0; j < 32; ++j)
{
ImWchar c = i * 32 + j;
if (used_chars & (1 << j))
{
wtext += c;
}
}
}
wtextview = wtext;
AFontMatcher * font_matcher = AFontMatcher_create();
if (!font_matcher)
throw std::runtime_error("AFontMatcher_create");
@@ -432,18 +395,18 @@ static std::vector<std::string> find_font(const ImFontGlyphRangesBuilder & glyph
std::vector<std::string> fonts;
while (!wtextview.empty())
while (!sample_text.empty())
{
uint32_t runlength = 0;
AFont * font = AFontMatcher_match(font_matcher, "sans-serif", (uint16_t *)wtextview.data(), wtextview.size(), &runlength);
AFont * font = AFontMatcher_match(font_matcher, "sans-serif", (uint16_t *)sample_text.data(), sample_text.size(), &runlength);
fonts.emplace_back(AFont_getFontFilePath(font));
AFont_close(font);
if (runlength == 0)
break;
wtextview = wtextview.substr(runlength);
sample_text = sample_text.substr(runlength);
}
AFontMatcher_destroy(font_matcher);
@@ -451,7 +414,7 @@ static std::vector<std::string> find_font(const ImFontGlyphRangesBuilder & glyph
return fonts;
}
#else
static std::vector<std::string> find_font(ImFontGlyphRangesBuilder glyph_range_builder, const std::string & locale)
static std::vector<std::string> find_font(std::u16string sample_text, const std::string & locale)
{
// See https://www.camconn.cc/post/how-to-fontconfig-lib-c/
@@ -470,21 +433,8 @@ static std::vector<std::string> find_font(ImFontGlyphRangesBuilder glyph_range_b
// Add the text to the pattern (to determine appropriate characters)
FcCharSet * charset = FcCharSetCreate();
for (int i = 8; i < glyph_range_builder.UsedChars.Size; ++i)
{
std::uint32_t used_chars = glyph_range_builder.UsedChars[i];
if (used_chars == 0)
continue;
for (int j = 0; j < 32; ++j)
{
ImWchar c = i * 32 + j;
if (used_chars & (1 << j))
{
FcCharSetAddChar(charset, c);
}
}
}
for (char16_t c: sample_text)
FcCharSetAddChar(charset, c);
FcPatternAddCharSet(pattern, FC_CHARSET, charset);
FcCharSetDestroy(charset);
@@ -513,28 +463,26 @@ static std::vector<std::string> find_font(ImFontGlyphRangesBuilder glyph_range_b
continue;
bool keep_this_font = false;
for (int i = 0; i < glyph_range_builder.UsedChars.Size; ++i)
{
std::uint32_t & used_chars = glyph_range_builder.UsedChars[i];
if (used_chars == 0)
continue;
for (int j = 0; j < 32; ++j)
std::u16string tmp = sample_text;
for (int i = 0; i < tmp.size();)
{
char16_t c = tmp[i];
if (FcCharSetHasChar(font_charset, c))
{
ImWchar c = i * 32 + j;
if (used_chars & (1 << j))
{
if (FcCharSetHasChar(font_charset, c))
{
keep_this_font = true;
used_chars &= ~(1 << j);
}
}
keep_this_font = true;
tmp[i] = tmp[tmp.size() - 1];
tmp.resize(tmp.size() - 1);
}
else
++i;
}
if (keep_this_font)
fonts.emplace_back((const char *)font_file);
break;
}
FcFontSetDestroy(fs);
@@ -546,29 +494,19 @@ static std::vector<std::string> find_font(ImFontGlyphRangesBuilder glyph_range_b
void imgui_context::initialize_fonts()
{
glyph_ranges.clear();
std::u16string sample_text = u"Hello world";
// Always include Basic Latin and Latin-1 Supplement without control characters
ImWchar default_ranges[] = {0x20, 0x7f, 0xa0, 0xff, 0};
glyph_range_builder.AddRanges(default_ranges);
const auto & locale = application::get_messages_info();
auto it = glyph_set_per_language.find(locale.language + "_" + locale.country);
if (it == glyph_set_per_language.end())
it = glyph_set_per_language.find(locale.language);
{
const auto & locale = application::get_messages_info();
auto it = glyph_set_per_language.find(locale.language + "_" + locale.country);
if (it == glyph_set_per_language.end())
it = glyph_set_per_language.find(locale.language);
if (it != glyph_set_per_language.end())
{
for (ImWchar c: it->second)
glyph_range_builder.AddChar(c);
}
}
glyph_range_builder.BuildRanges(&glyph_ranges);
if (it != glyph_set_per_language.end())
for (char16_t c: it->second)
sample_text += c;
// Load Fonts
auto fonts = find_font(glyph_range_builder, application::get_messages_info().language);
auto fonts = find_font(sample_text, application::get_messages_info().language);
for (auto & i: fonts)
{
spdlog::info("Font {}", i);
@@ -577,40 +515,20 @@ void imgui_context::initialize_fonts()
asset font_awesome_regular("Font Awesome 6 Free-Regular-400.otf");
asset font_awesome_solid("Font Awesome 6 Free-Solid-900.otf");
IM_DELETE(io.Fonts);
io.Fonts = IM_NEW(ImFontAtlas);
ImFontConfig config;
config.FontDataOwnedByAtlas = false;
for (auto & font: fonts)
{
ImFontConfig config;
config.FontDataOwnedByAtlas = false;
for (auto & font: fonts)
{
spdlog::info("Using font {}", font, application::get_messages_info().language);
io.Fonts->AddFontFromFileTTF(font.c_str(), constants::gui::font_size_small, &config, glyph_ranges.Data);
config.MergeMode = true;
}
spdlog::info("Using font {}", font, application::get_messages_info().language);
io.Fonts->AddFontFromFileTTF(font.c_str(), constants::gui::font_size_small, &config);
config.MergeMode = true;
config.GlyphMinAdvanceX = 40; // Use if you want to make the icon monospaced
static const ImWchar icon_ranges[] = {ICON_MIN_FA, ICON_MAX_FA, 0};
io.Fonts->AddFontFromMemoryTTF(const_cast<std::byte *>(font_awesome_regular.data()), font_awesome_regular.size(), constants::gui::font_size_small, &config, icon_ranges);
io.Fonts->AddFontFromMemoryTTF(const_cast<std::byte *>(font_awesome_solid.data()), font_awesome_solid.size(), constants::gui::font_size_small, &config, icon_ranges);
}
{
ImFontConfig config;
config.FontDataOwnedByAtlas = false;
for (auto & font: fonts)
{
large_font = io.Fonts->AddFontFromFileTTF(font.c_str(), constants::gui::font_size_large, &config, glyph_ranges.Data);
config.MergeMode = true;
}
}
glyph_range_dirty = false;
ImGui_ImplVulkan_CreateFontsTexture();
config.MergeMode = true;
config.GlyphMinAdvanceX = 40; // Use if you want to make the icon monospaced
io.Fonts->AddFontFromMemoryTTF(const_cast<std::byte *>(font_awesome_regular.data()), font_awesome_regular.size(), constants::gui::font_size_small, &config);
io.Fonts->AddFontFromMemoryTTF(const_cast<std::byte *>(font_awesome_solid.data()), font_awesome_solid.size(), constants::gui::font_size_small, &config);
}
std::vector<imgui_context::controller_state> imgui_context::read_controllers_state(XrTime display_time)
@@ -844,24 +762,6 @@ void imgui_context::new_frame(XrTime display_time)
controller.second = next_state;
}
// Force recreation of the font atlas
if (glyph_range_dirty)
{
// Wait for fences before ImGui_ImplVulkan_DestroyFontsTexture is called
std::vector<vk::Fence> fences;
for (auto & f: command_buffers)
{
fences.push_back(*f.fence);
}
if (auto result = device.waitForFences(fences, true, 1'000'000'000); result != vk::Result::eSuccess)
spdlog::error("vkWaitForfences: {}", vk::to_string(result));
ImGui_ImplVulkan_DestroyFontsTexture();
initialize_fonts();
ImGui_ImplVulkan_CreateFontsTexture();
}
// Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame();
@@ -1143,7 +1043,7 @@ ImTextureID imgui_context::load_texture(const std::string & filename, vk::raii::
device.updateDescriptorSets(ds_write, nullptr);
ImTextureID id = *ds;
ImTextureID id = reinterpret_cast<ImTextureID>(VkDescriptorSet(*ds));
textures.emplace(
id,
-6
View File
@@ -160,10 +160,6 @@ private:
bool button_pressed = false;
bool fingertip_touching = false;
ImFontGlyphRangesBuilder glyph_range_builder;
ImVector<ImWchar> glyph_ranges;
bool glyph_range_dirty = true;
ImGuiID hovered_item = 0; // Hovered item in the current frame, reset at the beginning of the frame
ImGuiID hovered_item_prev = 0; // Hovered item at the previous frame
@@ -198,7 +194,6 @@ public:
void new_frame(XrTime display_time);
std::vector<std::pair<int, XrCompositionLayerQuad>> end_frame();
ImFont * large_font;
size_t get_focused_controller() const
{
return focused_controller;
@@ -215,7 +210,6 @@ public:
void free_texture(ImTextureID);
void set_current();
void add_chars(std::string_view sv);
bool is_modal_popup_shown() const;
void vibrate_on_hover();
+1 -1
View File
@@ -915,7 +915,7 @@ void scenes::lobby::on_unfocused()
renderer->wait_idle(); // Must be before the scene data because the renderer uses its descriptor sets
about_picture = nullptr;
about_picture = 0;
imgui_ctx.reset();
world.clear(); // Must be cleared before the renderer so that the descriptor sets are freed before their pools
+8 -13
View File
@@ -95,7 +95,7 @@ static void InputText(const char * label, std::string & text, const ImVec2 & siz
static void display_recentering_tip(imgui_context & ctx, const std::string & tip)
{
ImGui::PushFont(ctx.large_font);
ImGui::PushFont(nullptr, constants::gui::font_size_large);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::window_padding);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 2);
ImGui::SetNextWindowPos(ctx.layers()[3].vp_center(), ImGuiCond_Always, {0.5, 0.5});
@@ -216,7 +216,7 @@ void scenes::lobby::gui_connecting(locked_notifiable<pin_request_data> & pin_req
ImGui::Dummy({1000, 1});
ImGui::PushFont(imgui_ctx->large_font);
ImGui::PushFont(nullptr, constants::gui::font_size_large);
if (server_name == "")
CenterTextH(fmt::format(_F("Connection")));
else
@@ -245,7 +245,7 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
const int pin_size = 6;
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, constants::style::pin_entry_item_spacing);
ImGui::PushFont(imgui_ctx->large_font);
ImGui::PushFont(nullptr, constants::gui::font_size_large);
const auto & style = ImGui::GetStyle();
const auto window = ImGui::GetCurrentWindow();
@@ -447,7 +447,7 @@ void scenes::lobby::gui_server_list()
std::string cookie_to_remove;
if (sorted_cookies.empty())
{
ImGui::PushFont(imgui_ctx->large_font);
ImGui::PushFont(nullptr, constants::gui::font_size_large);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 0.5));
CenterTextHV(_("Start a WiVRn server on your\nlocal network"));
ImGui::PopStyleColor();
@@ -835,7 +835,7 @@ void scenes::lobby::gui_settings()
ImPlot::PushStyleColor(ImPlotCol_AxisBgActive, IM_COL32(0, 0, 0, 0));
ImPlot::PushStyleColor(ImPlotCol_AxisBgHovered, IM_COL32(0, 0, 0, 0));
if (ImPlot::BeginPlot(_S("CPU time"), plot_size, ImPlotFlags_CanvasOnly | ImPlotFlags_NoChild))
if (ImPlot::BeginPlot(_S("CPU time"), plot_size, ImPlotFlags_CanvasOnly))
{
auto col = ImPlot::GetColormapColor(0);
@@ -849,7 +849,7 @@ void scenes::lobby::gui_settings()
ImGui::SameLine();
if (ImPlot::BeginPlot(_S("GPU time"), plot_size, ImPlotFlags_CanvasOnly | ImPlotFlags_NoChild))
if (ImPlot::BeginPlot(_S("GPU time"), plot_size, ImPlotFlags_CanvasOnly))
{
auto col = ImPlot::GetColormapColor(1);
@@ -1077,7 +1077,7 @@ void scenes::lobby::gui_debug()
void scenes::lobby::gui_about()
{
ImGui::PushFont(imgui_ctx->large_font);
ImGui::PushFont(nullptr, constants::gui::font_size_large);
CenterTextH(std::string("WiVRn ") + wivrn::git_version);
ImGui::PopFont();
@@ -1091,7 +1091,7 @@ void scenes::lobby::gui_about()
void scenes::lobby::gui_licenses()
{
ImGui::PushFont(imgui_ctx->large_font);
ImGui::PushFont(nullptr, constants::gui::font_size_large);
ImGui::Text("%s", _("Licenses").c_str());
ImGui::PopFont();
@@ -1630,11 +1630,6 @@ static bool is_gui_visible(imgui_context & ctx, XrTime predicted_display_time)
std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTime predicted_display_time)
{
for (const auto & [key, server]: application::get_config().servers)
{
imgui_ctx->add_chars(server.service.name);
}
imgui_ctx->new_frame(predicted_display_time);
ImGuiStyle & style = ImGui::GetStyle();
+10 -10
View File
@@ -319,14 +319,14 @@ virtual_keyboard::key_status virtual_keyboard::button_behavior(const ImRect & bb
float prev_held_duration = held_duration;
held_duration += g.IO.DeltaTime;
if ((flags & ImGuiButtonFlags_Repeat) and held_duration > g.IO.KeyRepeatDelay)
{
int n1 = (prev_held_duration - g.IO.KeyRepeatDelay) / g.IO.KeyRepeatRate;
int n2 = (held_duration - g.IO.KeyRepeatDelay) / g.IO.KeyRepeatRate;
if (n2 != n1)
pressed = true;
}
// if ((flags & ImGuiButtonFlags_Repeat) and held_duration > g.IO.KeyRepeatDelay)
// {
// int n1 = (prev_held_duration - g.IO.KeyRepeatDelay) / g.IO.KeyRepeatRate;
// int n2 = (held_duration - g.IO.KeyRepeatDelay) / g.IO.KeyRepeatRate;
//
// if (n2 != n1)
// pressed = true;
// }
}
else
{
@@ -381,8 +381,8 @@ virtual_keyboard::key_status virtual_keyboard::draw_single_key(const key & k, in
ImGuiButtonFlags flags = ImGuiButtonFlags_None;
if (k.flag & key_flag_repeat)
flags |= ImGuiButtonFlags_Repeat;
// if (k.flag & key_flag_repeat)
// flags |= ImGuiButtonFlags_Repeat;
auto status = button_behavior(bb, id, window_hovered, flags);
+2 -2
View File
@@ -232,7 +232,7 @@ void scenes::stream::gui_performance_metrics()
int n = 0;
for (const auto & [title, subplots, unit]: plots)
{
if (ImPlot::BeginPlot(title.c_str(), plot_size, ImPlotFlags_NoTitle | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText | ImPlotFlags_NoChild))
if (ImPlot::BeginPlot(title.c_str(), plot_size, ImPlotFlags_NoTitle | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText))
{
float min_v = 0;
float max_v = 0;
@@ -279,7 +279,7 @@ void scenes::stream::gui_performance_metrics()
for (auto && [index, metrics]: utils::enumerate(decoder_metrics))
{
std::string title = fmt::format(_F("Decoder {}"), std::to_string(index));
if (ImPlot::BeginPlot(title.c_str(), plot_size, ImPlotFlags_NoTitle | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText | ImPlotFlags_NoChild))
if (ImPlot::BeginPlot(title.c_str(), plot_size, ImPlotFlags_NoTitle | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText))
{
float min_v = 0;
float max_v = compute_plot_max_value(&(metrics.data()->displayed), metrics.size(), sizeof(decoder_metric));
@@ -1,4 +1,4 @@
From 748060ccb60bdc3df47dc44f1b1dcb57dfd5b488 Mon Sep 17 00:00:00 2001
From bf64125b461a33d9e67e9b6f3da2f0e0726cfb03 Mon Sep 17 00:00:00 2001
From: Guillaume Meunier <guillaume.meunier@centraliens.net>
Date: Wed, 16 Oct 2024 20:51:52 +0200
Subject: [PATCH 1/2] Change ImGui::ButtonBehavior default flags when using
@@ -12,10 +12,10 @@ Subject: [PATCH 1/2] Change ImGui::ButtonBehavior default flags when using
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/imgui.cpp b/imgui.cpp
index 3bbaf018f..44eed7900 100644
index 99819ffe..c1a16c42 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -9969,7 +9969,7 @@ static const char* GetInputSourceName(ImGuiInputSource source)
@@ -10140,7 +10140,7 @@ static const char* GetInputSourceName(ImGuiInputSource source)
}
static const char* GetMouseSourceName(ImGuiMouseSource source)
{
@@ -25,10 +25,10 @@ index 3bbaf018f..44eed7900 100644
return mouse_source_names[source];
}
diff --git a/imgui.h b/imgui.h
index 77ca8e04f..647090b9e 100644
index a2b2a1fa..64d5f758 100644
--- a/imgui.h
+++ b/imgui.h
@@ -1838,6 +1838,8 @@ enum ImGuiMouseSource : int
@@ -1935,6 +1935,8 @@ enum ImGuiMouseSource : int
ImGuiMouseSource_Mouse = 0, // Input is coming from an actual mouse.
ImGuiMouseSource_TouchScreen, // Input is coming from a touch screen (no hovering prior to initial press, less precise initial press aiming, dual-axis wheeling possible).
ImGuiMouseSource_Pen, // Input is coming from a pressure/magnetic pen (often used in conjunction with high-sampling rates).
@@ -38,12 +38,12 @@ index 77ca8e04f..647090b9e 100644
};
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index 8df1755fb..69f200218 100644
index 991676f7..b360e69e 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -7350,6 +7350,11 @@ static void ShowDemoWindowInputs()
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
@@ -7768,6 +7768,11 @@ static void DemoWindowInputs()
ImGui::Text("Mouse clicked count:");
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseClickedCount[i] > 0) { ImGui::SameLine(); ImGui::Text("b%d: %d", i, io.MouseClickedCount[i]); }
+ const char* mouse_source_names[] = { "Mouse", "TouchScreen", "Pen", "VRHandTracking", "VRController" };
+ IM_ASSERT(IM_ARRAYSIZE(mouse_source_names) == ImGuiMouseSource_COUNT && io.MouseSource >= 0 && io.MouseSource < ImGuiMouseSource_COUNT);
@@ -54,14 +54,14 @@ index 8df1755fb..69f200218 100644
// displaying the data for old/new backends.
// User code should never have to go through such hoops!
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 322c0846c..26a8ffdcd 100644
index a0c4f14f..11709bd1 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -501,7 +501,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
@@ -557,7 +557,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
// Default behavior requires click + release inside bounding box
if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0)
- flags |= ImGuiButtonFlags_PressedOnDefault_;
- flags |= (item_flags & ImGuiItemFlags_ButtonRepeat) ? ImGuiButtonFlags_PressedOnClick : ImGuiButtonFlags_PressedOnDefault_;
+ {
+ if (g.IO.MouseSource == ImGuiMouseSource_VRHandTracking)
+ flags |= ImGuiButtonFlags_PressedOnClick;
@@ -69,8 +69,8 @@ index 322c0846c..26a8ffdcd 100644
+ flags |= ImGuiButtonFlags_PressedOnDefault_;
+ }
// Default behavior inherited from item flags
// Note that _both_ ButtonFlags and ItemFlags are valid sources, so copy one into the item_flags and only check that.
ImGuiWindow* backup_hovered_window = g.HoveredWindow;
const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindow == window->RootWindow;
--
2.47.0
2.50.0
@@ -1,4 +1,4 @@
From 265d4ef46317d87b8d22926e7ee99fda6e2b940d Mon Sep 17 00:00:00 2001
From cdb8a40a9363019e33ecf9428cc2e1c6319aea1f Mon Sep 17 00:00:00 2001
From: Guillaume Meunier <guillaume.meunier@centraliens.net>
Date: Tue, 22 Oct 2024 15:09:14 +0200
Subject: [PATCH 2/2] Add ImGuiWindowFlags_NoFocusOnClick flag
@@ -9,10 +9,10 @@ Subject: [PATCH 2/2] Add ImGuiWindowFlags_NoFocusOnClick flag
2 files changed, 4 insertions(+)
diff --git a/imgui.cpp b/imgui.cpp
index 44eed7900..46f3ea877 100644
index c1a16c42..115371b2 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -4879,6 +4879,9 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
@@ -5134,6 +5134,9 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
// Handle the edge case of a popup being closed while clicking in its empty space.
// If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
@@ -23,17 +23,17 @@ index 44eed7900..46f3ea877 100644
if (root_window != NULL && !is_closed_popup)
diff --git a/imgui.h b/imgui.h
index 647090b9e..e9e453195 100644
index 64d5f758..cff44a55 100644
--- a/imgui.h
+++ b/imgui.h
@@ -1079,6 +1079,7 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No gamepad/keyboard navigation within the window
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
@@ -1161,6 +1161,7 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No keyboard/gamepad navigation within the window
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with keyboard/gamepad navigation (e.g. skipped by CTRL+TAB)
ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
+ ImGuiWindowFlags_NoFocusOnClick = 1 << 19, // Disable taking focus when clicked
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
--
2.47.0
2.50.0