-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Fix event capture in multi-window applications on macOS #8644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix event capture in multi-window applications on macOS #8644
Conversation
[OSX] Fix event handling to prevent ImGui from capturing events from other windows
Hello, I believe it should be something like:
It would be good to test it. |
…-window-mouse-event
convert to void pointer before comparation and ignore event when null pointer. verfied for docking branch, also work in main.
Following code has been verified in docking branch. And sync code to this pr. static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
{
// get window of event and view
void *event_handle = (__bridge void*)(event.window);
void *view_handle = (__bridge void*)(view.window);
// check if the event and view are valid
if (event_handle == nullptr || view_handle == nullptr)
{
return false;
}
// find viewport by platform handle, if not found return false
ImGuiViewport *viewport = ImGui::FindViewportByPlatformHandle(view_handle);
if(viewport == nullptr)
{
return false;
}
// check if the event and view are the same, handle event from same window
if(viewport->PlatformHandleRaw != event_handle)
{
return false;
}
ImGuiIO& io = ImGui::GetIO();
// ... rest of the event handling logic
} |
…dow containing our view. (#8644)
// find viewport by platform handle, if not found return false
ImGuiViewport *viewport = ImGui::FindViewportByPlatformHandle(view_handle);
if(viewport == nullptr)
{
return false;
}
// check if the event and view are the same, handle event from same window
if(viewport->PlatformHandleRaw != event_handle)
{
return false;
} Can you clarify with the later check is used? isn't the |
I merged both patches (docking as d896eab) but it would be good to get answer for my last question. I absolutely don't want to add any non necessary check, because they tend to make things more confusing, so wanted to confirm how/why every statement was necessary. Thank you! |
I'm sorry for the late reply. I found this bug while creating a SwiftUI binding for ImGui. During my tests, I noticed that ImGui was capturing mouse events from another window that didn't contain an ImGui view but was positioned over it. That means event may not comes from windows contain ImGui. My approach was to fix this with minimal changes: simply get the window that fired the event and compare it with the window containing the current view. I've checked the ImGui implementation for macOS, and it seems the view is always created by ImGui. Therefore, I think the code can be simplified as follows, although I haven't tested this new version. static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
{
// get window of event
void *event_handle = (__bridge void*)(event.window);
// find window is not created by imgui, ignore event
ImGuiViewport *viewport = ImGui::FindViewportByPlatformHandle(event_handle);
if(viewport == nullptr)
{
return false;
}
ImGuiIO& io = ImGui::GetIO();
// ... rest of the event handling logic
}
|
* origin/docking-dev: (1059 commits) Backends: Vulkan: Fix failing assertion for platforms where viewports are not supported (ocornut#8734) Backends: GLFW: Fixed not installing WndProc hook in all GLFW version, so AddMouseSourceEvent() logic was missing for some viewports. Backends: GLFW: Fixed crash when using GLFW 3.3 (ocornut#8713, ocornut#8676, ocornut#8239, ocornut#8069) Backends: warning fixes (for docking branch). Backends: GLFW: amend for multi-context support with multi-viewport. (ocornut#8676, ocornut#8239, ocornut#8069) Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing our viewports. Amend 7ac99a4 for docking. (ocornut#8644) Fixed duplicate symbols in some compile-time configurations. Fonts: Misc merge fixes. Examples: set ConfigDpiScaleFonts / ConfigDpiScaleViewports in all examples already setup for scaling. Backends: GLFW, SDL2, SDL3, update for docking to use helpers. (Breaking) renamed/moved ImGuiConfigFlags_DpiEnableScaleFonts -> ioConfigDpiScaleFonts, ImGuiConfigFlags_DpiEnableScaleViewports -> io.ConfigDpiScaleViewports Backends: Win32: Viewports: handle WM_DPICHANGED in backend when ImGuiConfigFlags_DpiEnableScaleViewports flag is enabled. Viewports: fixed handling of simultaneous move + resize (e.g. toggling maximized) when ImGuiConfigFlags_DpiEnableScaleViewports is enabled. Refactor: move SetCurrentFont(), PushFont(), PopFont() to a section. Platform IME: Fixed multi-viewports IME support, affecting SDL backends. (ocornut#8648, ocornut#8584, ocornut#7492, ocornut#6341) Viewports: added per-viewport FramebufferScale, Platform_GetWindowFramebufferScale() + Backends: GLFW, SDL2, SDL3, Apple: added support. (ocornut#1065, ocornut#1542, ocornut#1676, ocornut#1786, ocornut#2826, ocornut#3757, ocornut#5081, ocornut#5580, ocornut#5592, ocornut#6465, ocornut#7273, ocornut#7779 etc.) ) Backends: OSX: rename internal struct for consistency with other backends. Viewports: fallback DpiScale pulled from fallback Monitor for consistency. Backends: Vulkan: fixed build with VK_NO_PROTOTYPES. Backends: Vulkan: fixed validation errors during window detach in multi-viewport mode. [docking branch amend] (ocornut#8600, ocornut#8176) ...
* Fonts: Comments, remove ImFontAtlas facing BuildGrowTexture(), BuildCompactTexture(). Make IsBuilt() obsolete. * Fonts: ImFontAtlasBuildInit() uses the occasion to sync HasTexUpdates from imgui context, narrowing the scope where it isn't set. * Fonts: Added back support for AddCustomRectFontGlyph() Legacy path naturally works. * (Breaking) Fonts: remove ImFontAtlasCustomRect which is now the same as ImTextureRect * Fonts: Fixed/improved support for legacy backend. SetTexID() writes into our ImTextureData to keep the indirection, clear TexIsBuilt. The idea is that a legacy backend can somehow add a if (!atlas->IsBuilt()) ImGui_ImplXXXXX_CreateFontsTexture() call _after_ Render() and some features are supported. * Fonts: Removed BuildClearGlyphs(), conflated with ClearOutputData() * Fonts: Added a bit of user facing tooling. * Fonts: Reduced reliance on ImFontConfig::DstFont. * Fonts: stb_truetype loader: Reworked scale handling to suggest this is not required caching. * Fonts: Fixed leak due to indirectly recursing ImFontAtlasPackInit(). * Internals: added ImStableVector<> helper. * (Breaking) Fonts: CalcWordWrapPositionA() -> CalcWordWrapPosition(), takes size instead of scale as this will be needed. * Fonts: Baked system, with auto-bind, v10. # Conflicts: # imgui_internal.h * Fonts: clarify ClearTexData() as not supported with dynamic atlases. * Fonts: Added PushFontSize(), PopFontSize() api. Added font_size param to PushFont() as well. Fonts: Fixed PopFont() recovery. (To squash into "Added PushFontSize(), PopFontSize() api." * Fonts: Texture resizing favor growing height, halve pack nodes. * Fonts: Debug dump to disk, debug log. * Textures: Comments around ImTextureID type. * Fonts: Baked system, v11. * Fonts: Baked system, v12: support GlyphOffset / GlyphMinAdvanceX / GlyphMaxAdvanceX by scaling from ref value. Overwriting cfg->PixelSnapH = true; in imgui_freetype is weird. * Fonts: Reordered ImFont fields. * Fonts: Allow PushFont/NewFrame/PopFont idioms to function. * Fonts: PushFontSize() with -1 uses sources[0]'s size for now (backward compat design) * Fonts: Fixed _OnChangedTextureID() asserting when calling on e.g. finalized drawlists. * Fonts: Create a fallback glyph if none is available (fix crash on fonts with no fallback) * Fonts: ImFontConfig: added GlyphExcludeRanges[]. * Fonts: Restore a functional AddCustomRectFontGlyph(). * Fonts: Exposed CompactCache(). Hide ClearCache(). * Fonts: ImFontFlags: ImFontFlags_NoLoadGlyphs + add ImFontFlags_LockBakedSizes * Fonts: Baked system, fix subsequent sources overriding shared font metrics. * Fonts: Added ImFontAtlasBakedSetFontGlyphBitmap(). * Fonts: reinstated ImFontAtlasBuildSetupFontCreateEllipsisFromDot() compatible with baked system, lazily baked. * Fonts: Core allocates per-baked-per-src backend buffers, to allow having custom backend per font source. Backend BakedInit/Destroy/AddGlyph process a single source. * Fonts: A font source can specify its own loader/backend. * Fonts: Rework ImFontLoader signatures. InitBaked may return false to signify this size is not supported. * imgui_freetype: no need to store metrics locally. * Fonts: Fallback glyph is now lazily loaded on demand (yay!). Moving ImFontBaked:: functions outside of class. * Fonts: removed LockSingleSrcConfigIdx which isn't needed anymore since we don't load glyphs in ImFontAtlasBuildAddFont(). * Fonts: tidying up font scale logic. # Conflicts: # imgui_internal.h * Textures: Added ImTextureData::UsedRect. # Conflicts: # imgui_internal.h * Fonts: GetFontBaked() default to searching for closest size font. * Demo: Add a "Fonts" section for visibility. * Textures: Detect when using a texture that's about to be destroyed. * Fonts: Added a ImFontFlags_NoLoadError flag to let user code try file paths. (3611) * Fonts: Fixed various small warnings / build issues. * Fonts: Obsolete GetGlyphRangesXXX() functions. Update font documentation. * Fonts: ImFontConfig::GlyphExcludeRanges is owner and copied. * Fonts: in ShowFontAtlas() preserve open-state for latest texture. Improve debug display. * Fonts: Added UI to edit FreeType loader flags. Added ImFontAtlasBuildReloadAll() / ImFontAtlasBuildReloadFont() * Demo: Exposed some basic UI in demo for sanity. * Fonts: fixed a bug using size specified by secondary font sources. * Textures: ImTextureData pixels are not immediately destroyed on setting ImTextureStatus_WantDestroy. * Fonts: fixed memory leaks, shutting down font loader, and on AddFont() failure in FreeType backend. * Fonts: fixed an issue calling legacy ImFontAtlas::Clear(). * Fonts: fixed implicit init when calling AddCustomRectRegular(). LoaderShutdown match BuildDestroy. * Fonts: change uses of ImFontAtlasRect to ImTextureRect for simplicity. * Fonts: narrowed invalid value for ImFontAtlasRectId to -1 a we will change implementation. * (Breaking) Fonts: rename GetCustomRectByIndex() to GetCustomRect(). Made return struct const. * Fonts: rename ImFontAtlasBuildClearTexture() to ImFontAtlasBuildClear(). * (Breaking) Fonts: renamed CalcCustomRectUV() to GetCustomRectUV() for simplicity. * Fonts: fixed crashing password fields. # Conflicts: # imgui_internal.h * Textures: Added ImTextureRef::GetTexID() mostly for consistency. Without it the logic may seem more confusing to grok for end-user. * Fonts: fixed ImTextureID() being zero-cleared instead of using ImTextureUserID_Invalid. . * Fonts: comments, tweaks, minor amends. Comments, tweaks * Fonts: avoid both ImTextureRef fields being set simultaneously. * Fonts: detect if backend assign to texture on creation but doesn't update Status. * Fonts: awkwardly alias old TexID name to TexRef using an union (may backtrack and just keep old name) * Fonts: fixed legacy backend path preloading all sources sizes erroneously + failing to use ellipsis. * Fonts: removed size rounding in AddFont() which breaks relative sizing of merged fonts (8502) # Conflicts: # imgui.cpp * (Breaking) Fonts: PushFont() default to preserve current font size. * Fonts: fixed calling AddFontXXX not invalidating texture for legacy backends. * Fonts: fixed GetCustomRectUV(). Fixing typo. Broken by fe598f7 * Fonts: Comments. * (Breaking) Fonts: renamed AddCustomRectRegular() -> AddCustomRect(). * (Breaking) Fonts: rework GetCustomRect() api. Reintroduce ImFontAtlasRect. * Fonts: added ImFontAtlasRectId_Invalid == -1 * Fonts: moved ImFontAtlasRectId back to public API. * Fonts: added RemoveCustomRect(). + internally add ImFontAtlasPackReuseRectEntry() * Fonts: GC Compact All exposed in Metrics->Memory Allocations includes compacting texture data. * Fonts: add optional out parameter to AddCustomRect() * Fonts: tidying up. * Fonts: changing loader/backend or loader flags may be done without losing custom rects. Sharing more code. * Fonts: do not mark whole ImTextureData struct as IMGUI_API to fix warning when used in ImVector<> (8559) * Fonts: internal rendering uses higher level functions. * Fonts: misc tidying up. * Fonts: fixed compaction gc-ing baked fonts used in the current frame + rename. * Fonts: encode additional data in ImFontAtlasRectId to detect invalid id + added Rects debug browser. * Fonts: packing of shared basic/line/cursor data uses more public API. * Fonts: no need to load current baked on SkipItems window? + removed unused field. Avoid baked staying active after GC. Might cause issues. # Conflicts: # imgui.cpp * Fonts: fixed unused variable warning. * Fonts: ImFontAtlasBuildInit() is always called with atlas->Builder == NULL. * Fonts: Extract ImFontAtlasBuildGetFontBaked() out of ImFont::GetFontBaked() mostly for consistency with upcoming changes + tweak locals in AddFont(). * Fonts: add ImFontGlyph::SourceIdx. Extract code out of DebugNodeFont() into DebugNodeFontGlyphesForSrcMask(). (src_mask unused in this commit) * Fonts: rename many internal functions for consistency. No other changes. * Fonts: shallow rework of ImFontAtlasBakedAddFontGlyph() to facilitate upcoming change. * Fonts: make ImFont::Sources a vector. Later it should become a ImSpan<> * Fonts: rework toward reducing reliance on ImFontConfig::DstFont since we ought to separate them. * imgui_freetype: moving data out of ImGui_ImplFreeType_FontSrcData. The reasoning behind that we would ideally transition ImGui_ImplFreeType_FontSrcData to be shared between fonts using same source. * imgui_freetype: removed anonymous namespace + extracting two functions outside of ImGui_ImplFreeType_FontSrcData. * Fonts: comments on ImTextureData fields. * Fonts: make RasterizerDensity a dynamic field. (temporarily exposed as SetFontRasterizerDensity()). # Conflicts: # imgui.cpp # imgui.h * Fonts: don't pretend to half recover from OOM for now + debug log filename on load failure. * Fonts: rework ImFontLoader::FontBakedLoadGlyph() interface * Fonts: adding ImFontHooks for codepoint remapping. * Fonts: remove ImFontHooks in favor of a AddRemapChar() implementation. * Fonts: Debug display status. Fixed truncated raw texture id. Fixed FormatTextureIDForDebugDisplay(). Comments. * Fonts: remove unnecessary ImDrawListSharedData::FontAtlas which is actually getting in the way of using multiple atlases. * Fonts: fixed broken support for legacy backend due to a mismatch with initial pre-build baked id. * Fonts: fixed support for multiple atlases. Moved FontAtlasOwnedByContext to OwnerContext # Conflicts: # imgui.cpp # imgui_internal.h * Fonts: proof of concept support for user textures. # Conflicts: # imgui.h # imgui_internal.h * Fonts: moved compare operators to internal. Removed commented out ones aimed legacy backends: not needed anymore since we didn't rename ImTextureID. * Fonts: reorder ImFontFlags according likelihood of being useful. * Fonts: automatically set current rasterizer density to viewport density. Effectively should fix most things on macOS. # Conflicts: # imgui.cpp # imgui.h * Fonts: fixed ImFontAtlas::RemoveFont() with multiple sources. Thanks cyfewlp! * Fonts: fixed support for IMGUI_STB_NAMESPACE. * Fonts: added notes/comments and dummy type about renaming ImFontBuilderIO::GetBuilderForFreeType() to ImFontLoader::GetFontLoader(). * Fonts: adding GetFontBaked() in public API. * Fonts: comments + made IMGUI_DEBUG_LOG_FONT() work without an ImGui context. * Fonts: fallback to default default rasterizer density + pick one from existing viewports at the time of calling AddUpdateViewport(). # Conflicts: # imgui.cpp * Fonts: fixed edge case calling RenderText() without priming with CalcTextSize(). * Fonts: detect if ImFontAtlasUpdateNewFrame() is not being called. * Fonts: added "Input Glyphs Overlap Detection Tool". Added "Clear bakes", "Clear unused" buttons. Move code. * (Breaking) Fonts: removing obsolete ImFont::Scale. * Fonts: ImFont::DefaultSize -> ImFont::LegacySize. ImFontFlags_UseDefaultSize -> ImFontFlags_DefaultToLegacySize. * Fonts: comments and slight packing of ImFontConfig fields. * Fonts: avoid calling GetFontBaked() during SetFontSize(). Also fixes loading extraneous baked on atlas that will be locked e.g. PushFontSize() before NewFrame() on legacy backend. * Fonts: added ImGuiStyle::FontSizeBase. Ensuring PushFontSize() works before main loop and across NewFrame(). # Conflicts: # imgui.cpp * Fonts: fixed passing negative sizes to stb_truetype loader. * Fonts: ground work for allowing SizePixels to be optional. * (Breaking) Fonts: obsoleting SetWindowFontScale(). + Comments # Conflicts: # imgui.cpp * (Breaking) Renamed io.FontGlobalScale to style.FontScaleMain. # Conflicts: # imgui.cpp * Added style.FontScaleDpi which is the field overwritten by ImGuiConfigFlags_DpiEnableScaleFonts. # Conflicts: # imgui.cpp # imgui.h # imgui_demo.cpp * Fonts: internals: renamed g.FontScale to g.FontBakedScale for clarity. Comments. * Fonts: internals: renamed g.FontSizeBeforeScaling to g.FontSizeBase for consistency. # Conflicts: # imgui_internal.h * Examples: remove comments/references about baking and GetGlyphRangesJapanese(). * Backends: SDL2: added ImGui_ImplSDL2_GetDpiScaleForDisplay(), ImGui_ImplSDL2_GetContentScaleForWindow() helpers. * Backends: GLFW: added ImGui_ImplGlfw_GetContentScaleForMonitor(), ImGui_ImplGlfw_GetContentScaleForWindow() helpers. # Conflicts: # backends/imgui_impl_glfw.cpp * Backends: SDL2, SDL3, GLFW: Backport small part of c90ea13 from docking. * Examples: Win32+DX9/DX10/DX11/DX12, SDL2+DX11/OpenGL2/OpenGL3/SDLRenderer/Vulkan, SDL3+OpenGL/SDLGPU/SDLRenderer/Vulkan: made example DPI aware by default. (master + docking: partial support for multi-dpi by scaling fonts + viewports but not style) We don't bother with WIN32_LEAN_AND_MEAN. # Conflicts: # examples/example_glfw_opengl3/main.cpp # examples/example_sdl2_directx11/main.cpp # examples/example_sdl2_opengl2/main.cpp # examples/example_sdl2_opengl3/main.cpp # examples/example_sdl2_vulkan/main.cpp # examples/example_sdl3_opengl3/main.cpp # examples/example_sdl3_sdlgpu3/main.cpp # examples/example_sdl3_vulkan/main.cpp # examples/example_win32_directx10/main.cpp # examples/example_win32_directx11/main.cpp # examples/example_win32_directx12/main.cpp # examples/example_win32_directx9/main.cpp * Fonts: AddFont() functions now allow size_pixels==0.0f (only required when using certain functions) Fonts: AddFont() funcitons allow size_pixels==0 for merged fonts. * Examples: remove explicit font sizes from AddFontXXX() calls. Add commented out style.FontSizeBase assignment. * Fonts: rename to ImFontAtlasBuildLegacyPreloadAllGlyphRanges(). * Fonts: fixed PopFont() broken recovery. "misc_recover_1" test would assert in EndFrame() * Fonts: amend UpdateCurentFontSize() early out optimization. * Fonts: demote ImFont::GetFontBaked() as slighty internal. * Fonts: fixed NewFrame() when atlas builder has been created but fonts not added. Fixed GetCustomRect() after atlas clear. * (Breaking) renamed ImFontConfig::FontBuilderFlags -> FontLoaderFlags. ImFontAtlas::FontBuilderFlags -> FontLoaderFlags. ImGuiFreeTypeBuilderFlags -> ImGuiFreeTypeLoaderFlags. * Fonts: tweaks demo and exposure to sliders, etc. * Docs: update Changelog, FAQ, Fonts docs. * Backends: GLFW, SDL2, SDL3, update for docking to use helpers. * Examples: set ConfigDpiScaleFonts / ConfigDpiScaleViewports in all examples already setup for scaling. * Fonts: Misc merge fixes. * Various/misc fixes following back-and-forth dynamic_fonts->master->docking merges. Added missing API BREAKING CHANGES section. * Removed unneeded check in RenderText() loop + disable static analyzer false-positive warnings. * imgui_freetype: fixed using legacy names. * Fixed using IMGUI_DISABLE_DEMO_WINDOWS without IMGUI_DISABLE_DEBUG_TOOLS and without linking with imgui_demo.cpp * TreeNode: fixed runtime asan warning (ocornut#2920) imgui_widgets.cpp:6923:52: runtime error: shift exponent -1 is negative * Fixed duplicate symbols in some compile-time configurations. * Fixed duplicate symbols in some compile-time configurations. * Fonts: add has_textures parameters to ImFontAtlasUpdateNewFrame(). * Fonts: update misc comments, docs. * Backends: WebGPU: moved sampler creation out of ImGui_ImplWGPU_CreateFontsTexture(). * Backends: WGPU: added ImGuiBackendFlags_RendererHasTextures support. (ocornut#8465) * Docs: reformat Changelog. * Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing our view. (ocornut#8644) * Fonts: clarify assert. (ocornut#8680) * Fonts: fixed FontBaked=NULL in initial call to SetCurrentWindow() in Begin() using previous frame value of SkipItems. (ocornut#8465) ref 0e769c5 * Fonts: UpdateCurrentFontSize() early out doesn't need to clear FontBaked. This was meant when the code would be lower in the function (after updating e.g. g.FontSize) Amend 0e769c5. * Windows: clicking on a window close button doesn't claim focus and bring to front. (ocornut#8683) Added ImGuiItemFlags_NoFocus, ImGuiButtonFlags_NoFocus. Neither are well specified so marking as experimental. * Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing our viewports. Amend 7ac99a4 for docking. (ocornut#8644) * Backends: Vulkan: correct minimum pool size assertion (ocornut#8691) * imgui_freetype: fix conversion null -> bool in FontBakedLoadGlyph (ocornut#8696) * DrawList, Fonts: fixed ImFontAtlasTextureRepack() overwriting draw list shared data UV's etc. even when not bound. (ocornut#8694, ocornut#8465) ImFontAtlasUpdateDrawListsSharedData() call from ImFontAtlasTextureRepack() would trigger this. For simplicity we also track current atlas in ImDrawListSharedData, but we could probably use Font->ContainerAtlas. * DrawList, Fonts: fixed PushFont()/AddImage() not restoring correct atlas texture id when using multiple atlas (ocornut#8694) This also needs 24f7328. * Windows: BeginChild(): fixed being unable to combine manual resize on one axis and automatic resize on the other axis. (ocornut#8690) + removed obsolete TODO entries. * Misc: removed static linkage from operators to facilitate using in C++ modules. (ocornut#8682, ocornut#8358) [@radjkarl] * Revert "Misc: removed static linkage from operators to facilitate using in C++ modules. (ocornut#8682, ocornut#8358) [@radjkarl]" This reverts commit 39a90ac. * Misc: removed static linkage from operators to facilitate using in C++ modules. (ocornut#8682, ocornut#8358) * InputText: minor changes to match for both insert chars paths to look more similar. * InputText: fixed a buffer overrun that could happen when using dynamically resizing buffers. (ocornut#8689) * imgui_freetype: fixed NULL that creeped in instead of nullptr. * Backends: GLFW: fixed WndProc relying on current context. (ocornut#8676, ocornut#8239, ocornut#8069) This makes the backend closer to support multi-context. * Backends: GLFW: Added support for multiple Dear ImGui contexts. (ocornut#8676, ocornut#8239, ocornut#8069) * Backends: GLFW: amend for multi-context support with multi-viewport. (ocornut#8676, ocornut#8239, ocornut#8069) * Backends: DirectX12: fixed build on MinGW. (ocornut#8702, ocornut#4594) * Backends: Allegro5: Fixed missing invisible mouse cursor, broken by ee8941e. * Backends: DX10, DX11, DX12, OpenGL3, Vulkan, WGPU: Assert when CreateDeviceObjects() calls return false. * Comments on ImGuiMod_XXXX and ImGuiKey_GamepadXXXX values. * Bsckends: SDL2, GLFW: fixed ImGui_ImplXXXX_GetContentScaleXXX functions never using SDL 2.0.4 & GLFW 3.3 path in master. Amend 9da3e66, 8269924 (was broken for master) * Textures: ImTextureData::GetPixels() returns void* for clarity. * Backends: Fixed various warnings discovered when using MinGW GCC 15/Clang on latest backends. dx12: 'ImGui_ImplDX12_Data* bd' shadowed local in spite of being in lambda. * Backends: warning fix. * Backends: warning fixes (for docking branch). * Backends: GLFW: Fixed crash when using GLFW 3.3 (ocornut#8713, ocornut#8676, ocornut#8239, ocornut#8069) Amend 2a8c75f * Backends: GLFW: Fixed not installing WndProc hook in all GLFW version, so AddMouseSourceEvent() logic was missing for some viewports. * InputText: fix for InsertChars() to work on read-only buffer. (ocornut#8714, ocornut#8689, ocornut#8242) Ill defined feature but memory editor use InsertChars etc on a read-only buffer. `if (init_state)` block of InputTextEx() intentionally does not resize TextA, as unneeded. Amend b2c7359 Amend e900571 * Fonts: AddFontDefault() adds to GlyphOffset.y instead of overriding it. * Fonts: add comments and examples for GlyphExcludeRanges[]. * Fonts: fixed RenderText() asserting when crossing VtxOffset change boundaries. (ocornut#8720, ocornut#8465) * Demo: fixed ID conflicts. (ocornut#8723) * (Breaking) Fonts: Removed support for PushFont(NULL) which was a shortcut for "default font". * Fonts: moved GetFont(), GetFontSize(), GetFontBaked() to higher section. * Fonts: fixed PVS Studio false positive "expression 'cmd_count != draw_list->CmdBuffer.Size' is always false." (ocornut#8720, ocornut#8465) Amend 608dd96 * Backends: SDL3: fixed pulling SDL_PROP_WINDOW_COCOA_WINDOW_POINTER into viewport->PlatformHandleRaw. (ocornut#8725, ocornut#8726) SDL_VIDEO_DRIVER_COCOA does not exist on SDL3. * (Breaking) Fonts: obsolete PushFont() default parameter. * (Breaking) Fonts: removed PushFontSize(), PopFontSize(). * (Breaking) Fonts: removed ImFontFlags_DefaultToLegacySize. * Fonts: comments. * Backends: SDLGPU: fixes call to SDL_MapGPUTransferBuffer(). Fixes artifacts on OSX/Metal. (ocornut#8465, ocornut#8703) * Fonts: fix PushFont(NULL) to work as advertised. Didn't properly finish ca72eb0. * Additional comments on ErrorCheckUsingSetCursorPosToExtendParentBoundaries(). (ocornut#5548) * Fonts: removing assert from legacy PushFont() to mirror new PushFont(). for consistency. * Layout: commented out legacy ErrorCheckUsingSetCursorPosToExtendParentBoundaries() fallback. (ocornut#5548, ocornut#4510, ocornut#3355, ocornut#1760, ocornut#1490, ocornut#4152, ocornut#150) * Demo: added TextLinkOpenurl("") call in Widgets section. * Version 1.92.0 * Docs: update binaries. * Replace IMGUI_API with inline for PushTextureID() and PopTextureID() (ocornut#8729) * Backends: Vulkan: Fix failing assertion for platforms where viewports are not supported (ocornut#8734) * Demo: Fixed font scaling warning if ImGuiBackendFlags_RendererHasTextures is set (ocornut#8736) * Version 1.92.1 WIP * Backends: OSX: added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support. (ocornut#8739) Yet another undocumented standard cursor. Amend 8a35386. * Docs: tidying up Backends.md, add index, prepare for adding more docs. * Docs: update Backends with direction for implementing RenderDrawData function and supporting ImGuiBackendFlags_RendererHasTextures. (ocornut#8735, ocornut#8465) * Docs: update Backends with basic Platform backend instructions. * Backends: Vulkan: use nonCoherentAtomSize to align upload_size, fixing validation error on some setups. (ocornut#8743, ocornut#8744) * Backends: SDL3: avoid calling SDL_StartTextInput() again if already active. (ocornut#8727) * Demo: Added "Widgets/Text/Different Size Text" section to show font system changes in v1.92. (ocornut#8738) * Demo: amend "Font Size" demo. (ocornut#8738) * Textures: Fixed support for `#define ImTextureID_Invalid` to non-zero value. * Docs: tweak/fixed comments. (ocornut#8750, ocornut#8749) * Backends: SDL2: undef Status for X11. (ocornut#8751) * Tables: fixed comments about DisableDefaultContextMenu. (ocornut#8746) * CI: Fixed dllimport/dllexport tests. (ocornut#8757) * Fonts: added ImFontAtlas::SetFontLoader() to dynamically change font loader at runtime without using internal API. (ocornut#8752, ocornut#8465) * Fonts: set a maximum font size of 512.0f at ImGui:: API level to reduce edge cases. * Fonts: for large size fonts, layout/size calculation only load glyphs metrics. Actual glyphs are renderer+packed when used by drawing functions. (ocornut#8758, ocornut#8465) (Breaking) breaks signature of ImFontLoader::FontBakedLoadGlyph, sorry. --------- Co-authored-by: ocornut <omar@miracleworld.net> Co-authored-by: ocornut <omarcornut@gmail.com> Co-authored-by: Shawn Hatori <5499686+shawnhatori@users.noreply.github.com> Co-authored-by: Pascal Thomet <pthomet@gmail.com> Co-authored-by: PlayDay <18056374+playday3008@users.noreply.github.com> Co-authored-by: Geert Bleyen <geert.bleyen@materialise.be> Co-authored-by: Aidan Sun <aidansun05@gmail.com> Co-authored-by: Stanislav Vasilev <stanv.contact176@gmail.com> Co-authored-by: Ves Georgiev <1884844+VesCodes@users.noreply.github.com> Co-authored-by: Christian Fillion <contact@cfillion.ca> Co-authored-by: omar <ocornut@users.noreply.github.com> Co-authored-by: Thomas Quante <th.quante@yahoo.de> Co-authored-by: morrazzzz <123486080+morrazzzz@users.noreply.github.com> Co-authored-by: Demonese <git@chuikingshek.com>
Applied your last suggestion as ee8fd53. |
Description:
When using Dear ImGui in a macOS application with multiple windows, input events from windows without ImGui views are incorrectly captured by the global event monitor in the OSX backend.
Reproduction steps:
Fix:
Added window check in ImGui_ImplOSX_HandleEvent to ensure events are only processed when they originate from the window containing the ImGui view:
Testing: