@@ -173,6 +173,7 @@ struct WindowContext {
173
173
bool windowHasFocus;
174
174
bool mouseMoved;
175
175
bool mousePressed[3 ];
176
+ ImGuiMouseCursor lastCursor;
176
177
177
178
bool touchDown[3 ];
178
179
sf::Vector2i touchPos;
@@ -202,6 +203,7 @@ struct WindowContext {
202
203
mousePressed[i] = false ;
203
204
touchDown[i] = false ;
204
205
}
206
+ lastCursor = ImGuiMouseCursor_COUNT;
205
207
206
208
joystickId = getConnectedJoystickId ();
207
209
for (int i = 0 ; i < ImGuiNavInput_COUNT; ++i) {
@@ -432,22 +434,23 @@ void Update(sf::RenderWindow& window, sf::Time dt) {
432
434
433
435
void Update (sf::Window& window, sf::RenderTarget& target, sf::Time dt) {
434
436
SetCurrentWindow (window);
437
+ assert (s_currWindowCtx);
438
+
435
439
// Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
436
- updateMouseCursor (window);
440
+ ImGuiMouseCursor mouse_cursor =
441
+ ImGui::GetIO ().MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor ();
442
+ if (s_currWindowCtx->lastCursor != mouse_cursor) {
443
+ s_currWindowCtx->lastCursor = mouse_cursor;
444
+ updateMouseCursor (window);
445
+ }
437
446
438
- assert (s_currWindowCtx);
439
447
if (!s_currWindowCtx->mouseMoved ) {
440
448
if (sf::Touch::isDown (0 )) s_currWindowCtx->touchPos = sf::Touch::getPosition (0 , window);
441
449
442
450
Update (s_currWindowCtx->touchPos , static_cast <sf::Vector2f>(target.getSize ()), dt);
443
451
} else {
444
452
Update (sf::Mouse::getPosition (window), static_cast <sf::Vector2f>(target.getSize ()), dt);
445
453
}
446
-
447
- if (ImGui::GetIO ().MouseDrawCursor ) {
448
- // Hide OS mouse cursor if imgui is drawing it
449
- window.setMouseCursorVisible (false );
450
- }
451
454
}
452
455
453
456
void Update (const sf::Vector2i& mousePos, const sf::Vector2f& displaySize, sf::Time dt) {
0 commit comments