Skip to content

Commit c4d5cc3

Browse files
expikrslouken
authored andcommitted
streamline boolean logic
1 parent 441e7e4 commit c4d5cc3

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/events/SDL_mouse.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ bool SDL_SetCursor(SDL_Cursor *cursor)
16071607
{
16081608
SDL_Mouse *mouse = SDL_GetMouse();
16091609

1610-
// Return immediately if setting the cursor to the currently set one (fixes #7151)
1610+
// already on this cursor, no further action required
16111611
if (cursor == mouse->cur_cursor) {
16121612
return true;
16131613
}
@@ -1627,23 +1627,20 @@ bool SDL_SetCursor(SDL_Cursor *cursor)
16271627
}
16281628
}
16291629
mouse->cur_cursor = cursor;
1630+
} else if (mouse->focus) {
1631+
cursor = mouse->cur_cursor;
16301632
} else {
1631-
if (mouse->focus) {
1632-
cursor = mouse->cur_cursor;
1633-
} else {
1634-
cursor = mouse->def_cursor;
1635-
}
1633+
cursor = mouse->def_cursor;
16361634
}
16371635

1638-
if (cursor && (!mouse->focus || (mouse->cursor_visible && (!mouse->relative_mode || !mouse->relative_mode_hide_cursor)))) {
1639-
if (mouse->ShowCursor) {
1640-
mouse->ShowCursor(cursor);
1641-
}
1642-
} else {
1643-
if (mouse->ShowCursor) {
1644-
mouse->ShowCursor(NULL);
1645-
}
1636+
if (mouse->focus && (!mouse->cursor_visible || (mouse->relative_mode && mouse->relative_mode_hide_cursor))) {
1637+
cursor = NULL;
1638+
}
1639+
1640+
if (mouse->ShowCursor) {
1641+
mouse->ShowCursor(cursor);
16461642
}
1643+
16471644
return true;
16481645
}
16491646

0 commit comments

Comments
 (0)