mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-26 13:18:30 +00:00
Backends: SDL2,SDL3: avoid using the SDL_GetGlobalMouseState() path when one of our window is hovered. Fix mouse coordinate issue in fullscreen apps with macOS notch + better X11 perfs. (#7919, #7786)
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2025-09-24: Skip using the SDL_GetGlobalMouseState() state when one of our window is hovered, as the SDL_MOUSEMOTION data is reliable. Fix macOS notch mouse coordinates issue in fullscreen mode + better perf on X11. (#7919, #7786)
|
||||||
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
||||||
// 2025-09-15: Content Scales are always reported as 1.0 on Wayland. (#8921)
|
// 2025-09-15: Content Scales are always reported as 1.0 on Wayland. (#8921)
|
||||||
// 2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
// 2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
||||||
@@ -674,9 +675,10 @@ static void ImGui_ImplSDL2_UpdateMouseData()
|
|||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
||||||
|
|
||||||
// (Optional) Fallback to provide unclamped mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
|
// (Optional) Fallback to provide unclamped mouse position when focused but not hovered (SDL_MOUSEMOTION already provides this when hovered or captured)
|
||||||
|
SDL_Window* hovered_window = SDL_GetMouseFocus();
|
||||||
const bool is_relative_mouse_mode = SDL_GetRelativeMouseMode() != 0;
|
const bool is_relative_mouse_mode = SDL_GetRelativeMouseMode() != 0;
|
||||||
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode)
|
if (hovered_window == NULL && bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode)
|
||||||
{
|
{
|
||||||
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2025-09-24: Skip using the SDL_GetGlobalMouseState() state when one of our window is hovered, as the SDL_EVENT_MOUSE_MOTION data is reliable. Fix macOS notch mouse coordinates issue in fullscreen mode + better perf on X11. (#7919, #7786)
|
||||||
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
// 2025-09-18: Call platform_io.ClearPlatformHandlers() on shutdown.
|
||||||
// 2025-09-15: Use SDL_GetWindowDisplayScale() on Mac to output DisplayFrameBufferScale. The function is more reliable during resolution changes e.g. going fullscreen. (#8703, #4414)
|
// 2025-09-15: Use SDL_GetWindowDisplayScale() on Mac to output DisplayFrameBufferScale. The function is more reliable during resolution changes e.g. going fullscreen. (#8703, #4414)
|
||||||
// 2025-06-27: IME: avoid calling SDL_StartTextInput() again if already active. (#8727)
|
// 2025-06-27: IME: avoid calling SDL_StartTextInput() again if already active. (#8727)
|
||||||
@@ -636,9 +637,10 @@ static void ImGui_ImplSDL3_UpdateMouseData()
|
|||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
|
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
|
||||||
|
|
||||||
// (Optional) Fallback to provide unclamped mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
|
// (Optional) Fallback to provide unclamped mouse position when focused but not hovered (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
|
||||||
|
SDL_Window* hovered_window = SDL_GetMouseFocus();
|
||||||
const bool is_relative_mouse_mode = SDL_GetWindowRelativeMouseMode(bd->Window);
|
const bool is_relative_mouse_mode = SDL_GetWindowRelativeMouseMode(bd->Window);
|
||||||
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode)
|
if (hovered_window == NULL && bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0 && !is_relative_mouse_mode)
|
||||||
{
|
{
|
||||||
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
float mouse_x, mouse_y;
|
float mouse_x, mouse_y;
|
||||||
|
@@ -57,6 +57,10 @@ Other Changes:
|
|||||||
which may be dangling when using backend in e.g. DLL. (#8945, #2769)
|
which may be dangling when using backend in e.g. DLL. (#8945, #2769)
|
||||||
- Backends: OpenGL3: fixed GL loader to work on Haiku OS which does not support
|
- Backends: OpenGL3: fixed GL loader to work on Haiku OS which does not support
|
||||||
`RTLD_NOLOAD`. (#8952) [@Xottab-DUTY, @threedeyes]
|
`RTLD_NOLOAD`. (#8952) [@Xottab-DUTY, @threedeyes]
|
||||||
|
- Backends: SDL2,SDL3: avoid using the SDL_GetGlobalMouseState() path when one of our
|
||||||
|
window is hovered, as the event data is reliable and enough in this case.
|
||||||
|
- Fix mouse coordinates issue in fullscreen apps with macOS notch. (#7919, #7786)
|
||||||
|
- Better perf on X11 as querying global position requires a round trip to X11 server.
|
||||||
- Backends: Win32: minor optimization not submitting gamepad io again if
|
- Backends: Win32: minor optimization not submitting gamepad io again if
|
||||||
XInput's dwPacketNumber has not changed. (#8556) [@MidTerm-CN]
|
XInput's dwPacketNumber has not changed. (#8556) [@MidTerm-CN]
|
||||||
- Examples: SDL2+DirectX11: Try WARP software driver if hardware driver is
|
- Examples: SDL2+DirectX11: Try WARP software driver if hardware driver is
|
||||||
|
2
imgui.h
2
imgui.h
@@ -29,7 +29,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.92.4 WIP"
|
#define IMGUI_VERSION "1.92.4 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19231
|
#define IMGUI_VERSION_NUM 19232
|
||||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user