mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Backends: GLFW, SDL2, SDL3: include GLFW/SDL version number in io.BackendPlatformName.
# Conflicts: # backends/imgui_impl_sdl2.cpp # backends/imgui_impl_sdl3.cpp
This commit is contained in:
		| @@ -117,6 +117,7 @@ | |||||||
| #ifndef _WIN32 | #ifndef _WIN32 | ||||||
| #include <unistd.h>             // for usleep() | #include <unistd.h>             // for usleep() | ||||||
| #endif | #endif | ||||||
|  | #include <stdio.h>              // for snprintf() | ||||||
|  |  | ||||||
| #ifdef __EMSCRIPTEN__ | #ifdef __EMSCRIPTEN__ | ||||||
| #include <emscripten.h> | #include <emscripten.h> | ||||||
| @@ -157,6 +158,7 @@ struct ImGui_ImplGlfw_Data | |||||||
|     ImVec2                  LastValidMousePos; |     ImVec2                  LastValidMousePos; | ||||||
|     bool                    InstalledCallbacks; |     bool                    InstalledCallbacks; | ||||||
|     bool                    CallbacksChainForAllWindows; |     bool                    CallbacksChainForAllWindows; | ||||||
|  |     char                    BackendPlatformName[32]; | ||||||
| #ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3 | #ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3 | ||||||
|     const char*             CanvasSelector; |     const char*             CanvasSelector; | ||||||
| #endif | #endif | ||||||
| @@ -593,8 +595,9 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw | |||||||
|  |  | ||||||
|     // Setup backend capabilities flags |     // Setup backend capabilities flags | ||||||
|     ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)(); |     ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)(); | ||||||
|  |     snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_glfw (%d)", GLFW_VERSION_COMBINED); | ||||||
|     io.BackendPlatformUserData = (void*)bd; |     io.BackendPlatformUserData = (void*)bd; | ||||||
|     io.BackendPlatformName = "imgui_impl_glfw"; |     io.BackendPlatformName = bd->BackendPlatformName; | ||||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;         // We can honor GetMouseCursor() values (optional) |     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;         // We can honor GetMouseCursor() values (optional) | ||||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;          // We can honor io.WantSetMousePos requests (optional, rarely used) |     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;          // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -109,6 +109,7 @@ | |||||||
| // SDL | // SDL | ||||||
| #include <SDL.h> | #include <SDL.h> | ||||||
| #include <SDL_syswm.h> | #include <SDL_syswm.h> | ||||||
|  | #include <stdio.h>              // for snprintf() | ||||||
| #ifdef __APPLE__ | #ifdef __APPLE__ | ||||||
| #include <TargetConditionals.h> | #include <TargetConditionals.h> | ||||||
| #endif | #endif | ||||||
| @@ -135,6 +136,7 @@ struct ImGui_ImplSDL2_Data | |||||||
|     SDL_Renderer*           Renderer; |     SDL_Renderer*           Renderer; | ||||||
|     Uint64                  Time; |     Uint64                  Time; | ||||||
|     char*                   ClipboardTextData; |     char*                   ClipboardTextData; | ||||||
|  |     char                    BackendPlatformName[40]; | ||||||
|  |  | ||||||
|     // Mouse handling |     // Mouse handling | ||||||
|     Uint32                  MouseWindowID; |     Uint32                  MouseWindowID; | ||||||
| @@ -476,12 +478,20 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void | |||||||
|     IMGUI_CHECKVERSION(); |     IMGUI_CHECKVERSION(); | ||||||
|     IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!"); |     IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!"); | ||||||
|  |  | ||||||
|  |     // Obtain compiled and runtime versions | ||||||
|  |     SDL_version ver_compiled; | ||||||
|  |     SDL_version ver_runtime; | ||||||
|  |     SDL_VERSION(&ver_compiled); | ||||||
|  |     SDL_GetVersion(&ver_runtime); | ||||||
|  |  | ||||||
|     // Setup backend capabilities flags |     // Setup backend capabilities flags | ||||||
|     ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)(); |     ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)(); | ||||||
|  |     snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_sdl2 (%u.%u.%u, %u.%u.%u)", | ||||||
|  |         ver_compiled.major, ver_compiled.minor, ver_compiled.patch, ver_runtime.major, ver_runtime.minor, ver_runtime.patch); | ||||||
|     io.BackendPlatformUserData = (void*)bd; |     io.BackendPlatformUserData = (void*)bd; | ||||||
|     io.BackendPlatformName = "imgui_impl_sdl2"; |     io.BackendPlatformName = bd->BackendPlatformName; | ||||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;       // We can honor GetMouseCursor() values (optional) |     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;           // We can honor GetMouseCursor() values (optional) | ||||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;        // We can honor io.WantSetMousePos requests (optional, rarely used) |     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;            // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||||
|  |  | ||||||
|     bd->Window = window; |     bd->Window = window; | ||||||
|     bd->WindowID = SDL_GetWindowID(window); |     bd->WindowID = SDL_GetWindowID(window); | ||||||
|   | |||||||
| @@ -69,6 +69,7 @@ | |||||||
|  |  | ||||||
| // SDL | // SDL | ||||||
| #include <SDL3/SDL.h> | #include <SDL3/SDL.h> | ||||||
|  | #include <stdio.h>              // for snprintf() | ||||||
| #if defined(__APPLE__) | #if defined(__APPLE__) | ||||||
| #include <TargetConditionals.h> | #include <TargetConditionals.h> | ||||||
| #endif | #endif | ||||||
| @@ -101,6 +102,7 @@ struct ImGui_ImplSDL3_Data | |||||||
|     SDL_Renderer*           Renderer; |     SDL_Renderer*           Renderer; | ||||||
|     Uint64                  Time; |     Uint64                  Time; | ||||||
|     char*                   ClipboardTextData; |     char*                   ClipboardTextData; | ||||||
|  |     char                    BackendPlatformName[40]; | ||||||
|  |  | ||||||
|     // IME handling |     // IME handling | ||||||
|     SDL_Window*             ImeWindow; |     SDL_Window*             ImeWindow; | ||||||
| @@ -465,10 +467,14 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void | |||||||
|     IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!"); |     IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!"); | ||||||
|     IM_UNUSED(sdl_gl_context); // Unused in this branch |     IM_UNUSED(sdl_gl_context); // Unused in this branch | ||||||
|  |  | ||||||
|  |     const int ver_linked = SDL_GetVersion(); | ||||||
|  |  | ||||||
|     // Setup backend capabilities flags |     // Setup backend capabilities flags | ||||||
|     ImGui_ImplSDL3_Data* bd = IM_NEW(ImGui_ImplSDL3_Data)(); |     ImGui_ImplSDL3_Data* bd = IM_NEW(ImGui_ImplSDL3_Data)(); | ||||||
|  |     snprintf(bd->BackendPlatformName, sizeof(bd->BackendPlatformName), "imgui_impl_sdl3 (%u.%u.%u; %u.%u.%u)", | ||||||
|  |         SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION, SDL_VERSIONNUM_MAJOR(ver_linked), SDL_VERSIONNUM_MINOR(ver_linked), SDL_VERSIONNUM_MICRO(ver_linked)); | ||||||
|     io.BackendPlatformUserData = (void*)bd; |     io.BackendPlatformUserData = (void*)bd; | ||||||
|     io.BackendPlatformName = "imgui_impl_sdl3"; |     io.BackendPlatformName = bd->BackendPlatformName; | ||||||
|     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;           // We can honor GetMouseCursor() values (optional) |     io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;           // We can honor GetMouseCursor() values (optional) | ||||||
|     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;            // We can honor io.WantSetMousePos requests (optional, rarely used) |     io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;            // We can honor io.WantSetMousePos requests (optional, rarely used) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -107,6 +107,7 @@ Other changes: | |||||||
| - Backends: SDL2, SDL3: don't attempt to call SDL_CaptureMouse() on drivers where we don't | - Backends: SDL2, SDL3: don't attempt to call SDL_CaptureMouse() on drivers where we don't | ||||||
|   call SDL_GetGlobalMouseState(). This is specifically for Wayland but we currently use |   call SDL_GetGlobalMouseState(). This is specifically for Wayland but we currently use | ||||||
|   the same white-list as SDL_GetGlobalMouseState(). (#8561) [@vs49688] |   the same white-list as SDL_GetGlobalMouseState(). (#8561) [@vs49688] | ||||||
|  | - Backends: GLFW, SDL2, SDL3: include GLFW/SDL version number in io.BackendPlatformName. | ||||||
| - Backends: SDL3: Update for SDL3 api changes: revert SDL_GetClipboardText() | - Backends: SDL3: Update for SDL3 api changes: revert SDL_GetClipboardText() | ||||||
|   memory ownership change. (#8530, #7801) [@Green-Sky] |   memory ownership change. (#8530, #7801) [@Green-Sky] | ||||||
| - Backends: SDL3: honor ImGuiPlatformImeData->WantTextInput as an alternative | - Backends: SDL3: honor ImGuiPlatformImeData->WantTextInput as an alternative | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ocornut
					ocornut