Skip to content

Commit 4779499

Browse files
expikrslouken
authored andcommitted
Split the redraw effect to own function
1 parent 6c172e5 commit 4779499

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

src/events/SDL_mouse.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,26 @@ SDL_Cursor *SDL_CreateSystemCursor(SDL_SystemCursor id)
15991599
return cursor;
16001600
}
16011601

1602+
void SDL_RedrawCursor(void)
1603+
{
1604+
SDL_Mouse *mouse = SDL_GetMouse();
1605+
SDL_Cursor *cursor;
1606+
1607+
if (mouse->focus) {
1608+
cursor = mouse->cur_cursor;
1609+
} else {
1610+
cursor = mouse->def_cursor;
1611+
}
1612+
1613+
if (mouse->focus && (!mouse->cursor_visible || (mouse->relative_mode && mouse->relative_mode_hide_cursor))) {
1614+
cursor = NULL;
1615+
}
1616+
1617+
if (mouse->ShowCursor) {
1618+
mouse->ShowCursor(cursor);
1619+
}
1620+
}
1621+
16021622
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
16031623
if this is desired for any reason. This is used when setting
16041624
the video mode and when the SDL window gains the mouse focus.
@@ -1629,19 +1649,7 @@ bool SDL_SetCursor(SDL_Cursor *cursor)
16291649
mouse->cur_cursor = cursor;
16301650
}
16311651

1632-
if (mouse->focus) {
1633-
cursor = mouse->cur_cursor;
1634-
} else {
1635-
cursor = mouse->def_cursor;
1636-
}
1637-
1638-
if (mouse->focus && (!mouse->cursor_visible || (mouse->relative_mode && mouse->relative_mode_hide_cursor))) {
1639-
cursor = NULL;
1640-
}
1641-
1642-
if (mouse->ShowCursor) {
1643-
mouse->ShowCursor(cursor);
1644-
}
1652+
SDL_RedrawCursor();
16451653

16461654
return true;
16471655
}

src/events/SDL_mouse_c.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ extern void SDL_SetMouseName(SDL_MouseID mouseID, const char *name);
175175
// Get the mouse state structure
176176
extern SDL_Mouse *SDL_GetMouse(void);
177177

178+
// Set the default mouse cursor
179+
extern void SDL_RedrawCursor(void);
180+
178181
// Set the default mouse cursor
179182
extern void SDL_SetDefaultCursor(SDL_Cursor *cursor);
180183

0 commit comments

Comments
 (0)