Skip to content

Commit

Permalink
Update imgui_impl_win32.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakyevil committed Jan 28, 2025
1 parent 4230e98 commit 137f99e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions backends/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
ImGui_ImplWin32_UpdateKeyboardCodePage(io);

// Setup display size
RECT rect = { 0, 0, 0, 0 };
::GetClientRect(bd->hWnd, &rect);
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));

// Set platform dependent data in viewport
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
Expand Down Expand Up @@ -390,11 +395,6 @@ void ImGui_ImplWin32_NewFrame()
IM_ASSERT(bd != nullptr && "Context or backend not initialized? Did you call ImGui_ImplWin32_Init()?");
ImGuiIO& io = ImGui::GetIO();

// Setup display size (every frame to accommodate for window resizing)
RECT rect = { 0, 0, 0, 0 };
::GetClientRect(bd->hWnd, &rect);
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));

// Setup time step
INT64 current_time = 0;
::QueryPerformanceCounter((LARGE_INTEGER*)&current_time);
Expand Down Expand Up @@ -765,6 +765,10 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
bd->WantUpdateHasGamepad = true;
#endif
return 0;
case WM_SIZE:
io.DisplaySize.x = static_cast<float>(LOWORD(lParam));
io.DisplaySize.y = static_cast<float>(HIWORD(lParam));
return 0;
}
return 0;
}
Expand Down

0 comments on commit 137f99e

Please sign in to comment.