Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
9959455a
Commit
9959455a
authored
Feb 28, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a cleaner way to set the default cursor.
Added a way to cycle through the default cursor in testcursor.c
parent
99de5726
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
13 deletions
+30
-13
SDL_mouse.c
src/events/SDL_mouse.c
+21
-8
SDL_mouse_c.h
src/events/SDL_mouse_c.h
+3
-0
SDL_cocoamouse.m
src/video/cocoa/SDL_cocoamouse.m
+1
-3
testcursor.c
test/testcursor.c
+5
-2
No files found.
src/events/SDL_mouse.c
View file @
9959455a
...
...
@@ -44,6 +44,17 @@ SDL_MouseInit(void)
return
(
0
);
}
void
SDL_SetDefaultCursor
(
SDL_Cursor
*
cursor
)
{
SDL_Mouse
*
mouse
=
SDL_GetMouse
();
mouse
->
def_cursor
=
cursor
;
if
(
!
mouse
->
cur_cursor
)
{
SDL_SetCursor
(
cursor
);
}
}
SDL_Mouse
*
SDL_GetMouse
(
void
)
{
...
...
@@ -397,15 +408,17 @@ SDL_SetCursor(SDL_Cursor * cursor)
/* Set the new cursor */
if
(
cursor
)
{
/* Make sure the cursor is still valid for this mouse */
SDL_Cursor
*
found
;
for
(
found
=
mouse
->
cursors
;
found
;
found
=
found
->
next
)
{
if
(
found
==
cursor
)
{
break
;
if
(
cursor
!=
mouse
->
def_cursor
)
{
SDL_Cursor
*
found
;
for
(
found
=
mouse
->
cursors
;
found
;
found
=
found
->
next
)
{
if
(
found
==
cursor
)
{
break
;
}
}
if
(
!
found
)
{
SDL_SetError
(
"Cursor not associated with the current mouse"
);
return
;
}
}
if
(
!
found
)
{
SDL_SetError
(
"Cursor not associated with the current mouse"
);
return
;
}
mouse
->
cur_cursor
=
cursor
;
}
else
{
...
...
src/events/SDL_mouse_c.h
View file @
9959455a
...
...
@@ -72,6 +72,9 @@ extern int SDL_MouseInit(void);
/* Get the mouse state structure */
SDL_Mouse
*
SDL_GetMouse
(
void
);
/* Set the default mouse cursor */
extern
void
SDL_SetDefaultCursor
(
SDL_Cursor
*
cursor
);
/* Set the mouse focus window */
extern
void
SDL_SetMouseFocus
(
SDL_Window
*
window
);
...
...
src/video/cocoa/SDL_cocoamouse.m
View file @
9959455a
...
...
@@ -120,15 +120,13 @@ void
Cocoa
_
InitMouse
(
_
THIS
)
{
SDL
_
Mouse
*
mouse
=
SDL
_
GetMouse
()
;
SDL
_
Cursor
*
cursor
;
mouse
->
CreateCursor
=
Cocoa
_
CreateCursor
;
mouse
->
ShowCursor
=
Cocoa
_
ShowCursor
;
mouse
->
WarpMouse
=
Cocoa
_
WarpMouse
;
mouse
->
FreeCursor
=
Cocoa
_
FreeCursor
;
cursor
=
Cocoa
_
CreateDefaultCursor
()
;
mouse
->
cursors
=
mouse
->
cur
_
cursor
=
cursor
;
SDL
_
SetDefaultCursor
(
Cocoa
_
CreateDefaultCursor
())
;
}
static
int
...
...
test/testcursor.c
View file @
9959455a
...
...
@@ -147,7 +147,7 @@ main(int argc, char *argv[])
{
SDL_Surface
*
screen
;
SDL_bool
quit
=
SDL_FALSE
,
first_time
=
SDL_TRUE
;
SDL_Cursor
*
cursor
[
3
];
SDL_Cursor
*
cursor
[
4
];
int
current
;
/* Load the SDL library */
...
...
@@ -189,6 +189,7 @@ main(int argc, char *argv[])
SDL_Quit
();
return
(
1
);
}
cursor
[
3
]
=
SDL_GetCursor
();
current
=
0
;
SDL_SetCursor
(
cursor
[
current
]);
...
...
@@ -198,7 +199,7 @@ main(int argc, char *argv[])
while
(
SDL_PollEvent
(
&
event
))
{
switch
(
event
.
type
)
{
case
SDL_MOUSEBUTTONDOWN
:
current
=
(
current
+
1
)
%
3
;
current
=
(
current
+
1
)
%
SDL_arraysize
(
cursor
)
;
SDL_SetCursor
(
cursor
[
current
]);
break
;
case
SDL_KEYDOWN
:
...
...
@@ -222,3 +223,5 @@ main(int argc, char *argv[])
SDL_Quit
();
return
(
0
);
}
/* vi: set ts=4 sw=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment