MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / ImGui_ImplWin32_UpdateMouseData

Function ImGui_ImplWin32_UpdateMouseData

KBotExt/imgui/imgui_impl_win32.cpp:269–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269static void ImGui_ImplWin32_UpdateMouseData()
270{
271 ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
272 ImGuiIO& io = ImGui::GetIO();
273 IM_ASSERT(bd->hWnd != 0);
274
275 HWND focused_window = ::GetForegroundWindow();
276 const bool is_app_focused = (focused_window == bd->hWnd);
277 if (is_app_focused)
278 {
279 // (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
280 if (io.WantSetMousePos)
281 {
282 POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
283 if (::ClientToScreen(bd->hWnd, &pos))
284 ::SetCursorPos(pos.x, pos.y);
285 }
286
287 // (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
288 // This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE
289 if (!io.WantSetMousePos && bd->MouseTrackedArea == 0)
290 {
291 POINT pos;
292 if (::GetCursorPos(&pos) && ::ScreenToClient(bd->hWnd, &pos))
293 io.AddMousePosEvent((float)pos.x, (float)pos.y);
294 }
295 }
296}
297
298// Gamepad navigation mapping
299static void ImGui_ImplWin32_UpdateGamepads()

Callers 1

ImGui_ImplWin32_NewFrameFunction · 0.85

Calls 3

GetCursorPosFunction · 0.85
AddMousePosEventMethod · 0.80

Tested by

no test coverage detected