Make CJK imes work better

This commit is contained in:
Soreepeong 2023-12-07 22:41:10 +09:00
parent 280a9d6b05
commit b6d88f798a
9 changed files with 1064 additions and 466 deletions

View file

@ -426,6 +426,26 @@ public static class ImGuiHelpers
/// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns>
public static unsafe bool IsNull(this ImFontAtlasPtr ptr) => ptr.NativePtr == null;
/// <summary>
/// Finds the corresponding ImGui viewport ID for the given window handle.
/// </summary>
/// <param name="hwnd">The window handle.</param>
/// <returns>The viewport ID, or -1 if not found.</returns>
internal static unsafe int FindViewportId(nint hwnd)
{
if (!IsImGuiInitialized)
return -1;
var viewports = new ImVectorWrapper<ImGuiViewportPtr>(&ImGui.GetPlatformIO().NativePtr->Viewports);
for (var i = 0; i < viewports.LengthUnsafe; i++)
{
if (viewports.DataUnsafe[i].PlatformHandle == hwnd)
return i;
}
return -1;
}
/// <summary>
/// Get data needed for each new frame.