mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Speculative fix for Win32 clipboard handler if SetClipboardText() fails + Minor fix for static analyzer + using :: prefix when calling in Win32 functions.
This commit is contained in:
parent
185b4dde87
commit
2a6fbb2197
40
imgui.cpp
40
imgui.cpp
@ -12694,7 +12694,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal separating line.
|
// Horizontal/vertical separating line
|
||||||
void ImGui::Separator()
|
void ImGui::Separator()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
@ -12702,9 +12702,8 @@ void ImGui::Separator()
|
|||||||
return;
|
return;
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
ImGuiSeparatorFlags flags = 0;
|
// Those flags should eventually be overridable by the user
|
||||||
if ((flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)) == 0)
|
ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
|
||||||
flags |= (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
|
|
||||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)))); // Check that only 1 option is selected
|
IM_ASSERT(ImIsPowerOfTwo((int)(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)))); // Check that only 1 option is selected
|
||||||
if (flags & ImGuiSeparatorFlags_Vertical)
|
if (flags & ImGuiSeparatorFlags_Vertical)
|
||||||
{
|
{
|
||||||
@ -13672,42 +13671,43 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|||||||
{
|
{
|
||||||
static ImVector<char> buf_local;
|
static ImVector<char> buf_local;
|
||||||
buf_local.clear();
|
buf_local.clear();
|
||||||
if (!OpenClipboard(NULL))
|
if (!::OpenClipboard(NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
HANDLE wbuf_handle = GetClipboardData(CF_UNICODETEXT);
|
HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT);
|
||||||
if (wbuf_handle == NULL)
|
if (wbuf_handle == NULL)
|
||||||
{
|
{
|
||||||
CloseClipboard();
|
::CloseClipboard();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle))
|
if (ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle))
|
||||||
{
|
{
|
||||||
int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1;
|
int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1;
|
||||||
buf_local.resize(buf_len);
|
buf_local.resize(buf_len);
|
||||||
ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL);
|
ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL);
|
||||||
}
|
}
|
||||||
GlobalUnlock(wbuf_handle);
|
::GlobalUnlock(wbuf_handle);
|
||||||
CloseClipboard();
|
::CloseClipboard();
|
||||||
return buf_local.Data;
|
return buf_local.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
||||||
{
|
{
|
||||||
if (!OpenClipboard(NULL))
|
if (!::OpenClipboard(NULL))
|
||||||
return;
|
return;
|
||||||
const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1;
|
const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1;
|
||||||
HGLOBAL wbuf_handle = GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
|
HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
|
||||||
if (wbuf_handle == NULL)
|
if (wbuf_handle == NULL)
|
||||||
{
|
{
|
||||||
CloseClipboard();
|
::CloseClipboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImWchar* wbuf_global = (ImWchar*)GlobalLock(wbuf_handle);
|
ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle);
|
||||||
ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL);
|
ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL);
|
||||||
GlobalUnlock(wbuf_handle);
|
::GlobalUnlock(wbuf_handle);
|
||||||
EmptyClipboard();
|
::EmptyClipboard();
|
||||||
SetClipboardData(CF_UNICODETEXT, wbuf_handle);
|
if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL)
|
||||||
CloseClipboard();
|
::GlobalFree(wbuf_handle);
|
||||||
|
::CloseClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -13744,13 +13744,13 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y)
|
|||||||
{
|
{
|
||||||
// Notify OS Input Method Editor of text input position
|
// Notify OS Input Method Editor of text input position
|
||||||
if (HWND hwnd = (HWND)GImGui->IO.ImeWindowHandle)
|
if (HWND hwnd = (HWND)GImGui->IO.ImeWindowHandle)
|
||||||
if (HIMC himc = ImmGetContext(hwnd))
|
if (HIMC himc = ::ImmGetContext(hwnd))
|
||||||
{
|
{
|
||||||
COMPOSITIONFORM cf;
|
COMPOSITIONFORM cf;
|
||||||
cf.ptCurrentPos.x = x;
|
cf.ptCurrentPos.x = x;
|
||||||
cf.ptCurrentPos.y = y;
|
cf.ptCurrentPos.y = y;
|
||||||
cf.dwStyle = CFS_FORCE_POSITION;
|
cf.dwStyle = CFS_FORCE_POSITION;
|
||||||
ImmSetCompositionWindow(himc, &cf);
|
::ImmSetCompositionWindow(himc, &cf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user