29 #include "../video/SDL_sysvideo.h"
82 printf(
"Resetting mouse\n");
97 if (mouse->
focus == window) {
107 if (mouse->
focus && !window) {
118 mouse->
focus = window;
152 #ifdef SUPPORT_DRAG_OUTSIDE_WINDOW
153 if (!inWindow && !buttonstate) {
157 if (window == mouse->
focus) {
159 printf(
"Mouse left window, synthesizing move & focus lost event\n");
167 if (window != mouse->
focus) {
169 printf(
"Mouse entered window, synthesizing focus gain & move event\n");
180 if (window && !relative) {
197 int x_max = 0, y_max = 0;
211 if (!xrel && !yrel) {
213 printf(
"Mouse event didn't change state - dropped!\n");
232 if (mouse->
x > x_max) {
239 if (mouse->
y > y_max) {
260 event.motion.windowID = mouse->
focus ? mouse->
focus->
id : 0;
261 event.motion.which = mouseID;
263 event.motion.x = mouse->
x;
264 event.motion.y = mouse->
y;
265 event.motion.xrel = xrel;
266 event.motion.yrel = yrel;
314 event.button.windowID = mouse->
focus ? mouse->
focus->
id : 0;
315 event.button.which = mouseID;
316 event.button.state = state;
317 event.button.button = button;
318 event.button.x = mouse->
x;
319 event.button.y = mouse->
y;
350 event.wheel.windowID = mouse->
focus ? mouse->
focus->
id : 0;
351 event.wheel.which = mouseID;
416 if ( window ==
NULL )
417 window = mouse->
focus;
419 if ( window ==
NULL )
434 int original_x = mouse->
x, original_y = mouse->
y;
444 if (enabled && focusWindow) {
463 }
else if (mouse->
focus) {
487 int w,
int h,
int hot_x,
int hot_y)
493 Uint8 datab = 0, maskb = 0;
494 const Uint32 black = 0xFF000000;
495 const Uint32 white = 0xFFFFFFFF;
496 const Uint32 transparent = 0x00000000;
510 for (y = 0; y <
h; ++
y) {
512 for (x = 0; x <
w; ++
x) {
518 *pixel++ = (datab & 0x80) ? black : white;
520 *pixel++ = (datab & 0x80) ? black : transparent;
552 if ((hot_x < 0) || (hot_y < 0) ||
553 (hot_x >= surface->
w) || (hot_y >= surface->
h)) {
554 SDL_SetError(
"Cursor hot spot doesn't lie within cursor");
584 SDL_SetError(
"CreateSystemCursor is not currently supported");
611 for (found = mouse->
cursors; found; found = found->
next) {
612 if (found == cursor) {
617 SDL_SetError(
"Cursor not associated with the current mouse");
681 prev = curr, curr = curr->
next) {
682 if (curr == cursor) {
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface)
DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor)
Frees a cursor created with SDL_CreateCursor().
SDL_Mouse * SDL_GetMouse(void)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y)
Create a cursor, using the specified bitmap data and mask (in MSB format).
DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
GLfloat GLfloat GLfloat GLfloat h
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
static int SDL_PrivateSendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
Create a color cursor.
DECLSPEC int SDLCALL SDL_ShowCursor(int toggle)
Toggle whether or not the cursor is shown.
GLenum GLsizei const GLuint GLboolean enabled
DECLSPEC SDL_Window *SDLCALL SDL_GetMouseFocus(void)
Get the window which currently has mouse focus.
A collection of pixels used in software blitting.
DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window's client area.
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
void SDL_SetMouseFocus(SDL_Window *window)
DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y)
Retrieve the relative state of the mouse.
void(* MoveCursor)(SDL_Cursor *cursor)
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y)
Retrieve the current state of the mouse.
static SDL_Mouse SDL_mouse
void(* FreeCursor)(SDL_Cursor *cursor)
#define SDL_GetEventState(type)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void)
Return the default cursor.
int(* ShowCursor)(SDL_Cursor *cursor)
DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor)
Set the active cursor.
void SDL_ResetMouse(void)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor.
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
int(* SetRelativeMouseMode)(SDL_bool enabled)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
static SDL_bool SDL_UpdateMouseFocus(SDL_Window *window, int x, int y, Uint32 buttonstate)
DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled)
Set relative mouse mode.
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *src, Uint32 pixel_format, Uint32 flags)
#define SDL_assert(condition)
EGLSurface EGLint EGLint y
DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void)
Query whether relative mouse mode is enabled.
DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window *window, int x, int y)
Moves the mouse to the given position within the window.
uint8_t Uint8
An unsigned 8-bit integer type.
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, int x, int y)
DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type)
DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void)
Return the active cursor.
GLint GLint GLint GLint GLint w
DECLSPEC SDL_Window *SDLCALL SDL_GetKeyboardFocus(void)
Get the window which currently has keyboard focus.
DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id)
Create a system cursor.
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
#define SDL_Unsupported()
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
void(* WarpMouse)(SDL_Window *window, int x, int y)