mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-18 17:11:23 +01:00
Backends: SDL2, SDL3: changed GetClipboardText() handler to return NULL on error aka clipboard contents is not text. (#9168)
Consistent with other backends.
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)
|
||||||
|
// 2026-01-15: Changed GetClipboardText() handler to return nullptr on error aka clipboard contents is not text. Consistent with other backends. (#9168)
|
||||||
// 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-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)
|
||||||
@@ -178,7 +179,10 @@ static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*)
|
|||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
bd->ClipboardTextData = SDL_GetClipboardText();
|
if (SDL_HasClipboardText())
|
||||||
|
bd->ClipboardTextData = SDL_GetClipboardText();
|
||||||
|
else
|
||||||
|
bd->ClipboardTextData = nullptr;
|
||||||
return bd->ClipboardTextData;
|
return bd->ClipboardTextData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
// 2026-01-15: Changed GetClipboardText() handler to return nullptr on error aka clipboard contents is not text. Consistent with other backends. (#9168)
|
||||||
// 2025-11-05: Fixed an issue with missing characters events when an already active text field changes viewports. (#9054)
|
// 2025-11-05: Fixed an issue with missing characters events when an already active text field changes viewports. (#9054)
|
||||||
// 2025-10-22: Fixed Platform_OpenInShellFn() return value (unused in core).
|
// 2025-10-22: Fixed Platform_OpenInShellFn() return value (unused in core).
|
||||||
// 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-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)
|
||||||
@@ -151,7 +152,10 @@ static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*)
|
|||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
bd->ClipboardTextData = SDL_GetClipboardText();
|
if (SDL_HasClipboardText())
|
||||||
|
bd->ClipboardTextData = SDL_GetClipboardText();
|
||||||
|
else
|
||||||
|
bd->ClipboardTextData = nullptr;
|
||||||
return bd->ClipboardTextData;
|
return bd->ClipboardTextData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,8 @@ Other Changes:
|
|||||||
forcefully disable either. (#9109, #9116)
|
forcefully disable either. (#9109, #9116)
|
||||||
- OpenGL3: Fixed embedded loader multiple init/shutdown cycles broken on some
|
- OpenGL3: Fixed embedded loader multiple init/shutdown cycles broken on some
|
||||||
platforms. (#8792, #9112)
|
platforms. (#8792, #9112)
|
||||||
|
- SDL2, SDL3: changed GetClipboardText() handler to return NULL on error aka
|
||||||
|
clipboard contents is not text. Consistent with other backends. (#9168)
|
||||||
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
|
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
|
||||||
(vs Metallib shaders requiring macOS 14+). Requires application calling
|
(vs Metallib shaders requiring macOS 14+). Requires application calling
|
||||||
SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL. (#9076) [@Niminem]
|
SDL_CreateGPUDevice() with SDL_GPU_SHADERFORMAT_MSL. (#9076) [@Niminem]
|
||||||
|
|||||||
@@ -5091,10 +5091,11 @@ void ImGui::DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A conformant backend should return NULL on failure (e.g. clipboard data is not text).
|
||||||
const char* ImGui::GetClipboardText()
|
const char* ImGui::GetClipboardText()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
return g.PlatformIO.Platform_GetClipboardTextFn ? g.PlatformIO.Platform_GetClipboardTextFn(&g) : "";
|
return g.PlatformIO.Platform_GetClipboardTextFn ? g.PlatformIO.Platform_GetClipboardTextFn(&g) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetClipboardText(const char* text)
|
void ImGui::SetClipboardText(const char* text)
|
||||||
|
|||||||
2
imgui.h
2
imgui.h
@@ -3956,7 +3956,7 @@ struct ImGuiPlatformIO
|
|||||||
|
|
||||||
// Optional: Access OS clipboard
|
// Optional: Access OS clipboard
|
||||||
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
||||||
const char* (*Platform_GetClipboardTextFn)(ImGuiContext* ctx);
|
const char* (*Platform_GetClipboardTextFn)(ImGuiContext* ctx); // Should return NULL on failure (e.g. clipboard data is not text).
|
||||||
void (*Platform_SetClipboardTextFn)(ImGuiContext* ctx, const char* text);
|
void (*Platform_SetClipboardTextFn)(ImGuiContext* ctx, const char* text);
|
||||||
void* Platform_ClipboardUserData;
|
void* Platform_ClipboardUserData;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user