diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 399216916..cb05031b0 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -38,7 +38,6 @@ // (the multi-viewports feature requires SDL features supported from SDL 2.0.5+) #include #include -#define SDL_HAS_WARP_MOUSE_GLOBAL SDL_VERSION_ATLEAST(2,0,4) #define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4) #define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6) @@ -119,9 +118,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window) // Setup back-end capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) -#if SDL_HAS_WARP_MOUSE_GLOBAL io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) -#endif // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array. io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB; @@ -203,15 +200,12 @@ void ImGui_ImplSDL2_Shutdown() static void ImGui_ImplSDL2_UpdateMousePosAndButtons() { ImGuiIO& io = ImGui::GetIO(); - const ImVec2 mouse_pos_backup = io.MousePos; - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); // Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) - // (When multi-viewports are enabled, all imgui positions are same as OS positions.) -#if SDL_HAS_WARP_MOUSE_GLOBAL if (io.WantSetMousePos) - SDL_WarpMouseGlobal((int)mouse_pos_backup.x, (int)mouse_pos_backup.y); -#endif + SDL_WarpMouseInWindow(g_Window, (int)io.MousePos.x, (int)io.MousePos.y); + else + io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); int mx, my; Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);