Commit 17db454b authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #750

Since many different event structures include windowID it should be placed near
the beginning of the structure (preferably right after type) so it's position
is the same between different events.

This is to avoid code like this:
if (event.type == SDL_WINDOWEVENT)
    win = event.window.windowID;
else if ((SDL_EVENTMASK(event.type) & SDL_KEYEVENTMASK) != 0)
    win = event.key.windowID;
else if (event.type == SDL_TEXTINPUT)
    win = event.text.windowID;
else if (event.type == SDL_MOUSEMOTION)
    win = event.motion.windowID;
else if ((SDL_EVENTMASK(event.type) & (SDL_MOUBUTTONDOWNMASK |
SDL_MOUBUTTONUPMASK)) != 0)
    win = event.button.windowID;
else if (event.type == SDL_MOUSEWHEEL)
    win = event.wheel.windowID;
...

in favor of:
win = event.window.windowID;

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403650
parent 8aa58621
...@@ -128,10 +128,10 @@ typedef enum ...@@ -128,10 +128,10 @@ typedef enum
typedef struct SDL_WindowEvent typedef struct SDL_WindowEvent
{ {
Uint8 type; /**< SDL_WINDOWEVENT */ Uint8 type; /**< SDL_WINDOWEVENT */
SDL_WindowID windowID; /**< The associated window */
Uint8 event; /**< SDL_WindowEventID */ Uint8 event; /**< SDL_WindowEventID */
int data1; /**< event dependent data */ int data1; /**< event dependent data */
int data2; /**< event dependent data */ int data2; /**< event dependent data */
SDL_WindowID windowID; /**< The associated window */
} SDL_WindowEvent; } SDL_WindowEvent;
/** /**
...@@ -142,10 +142,10 @@ typedef struct SDL_WindowEvent ...@@ -142,10 +142,10 @@ typedef struct SDL_WindowEvent
typedef struct SDL_KeyboardEvent typedef struct SDL_KeyboardEvent
{ {
Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
Uint8 which; /**< The keyboard device index */ Uint8 which; /**< The keyboard device index */
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
SDL_keysym keysym; /**< The key that was pressed or released */ SDL_keysym keysym; /**< The key that was pressed or released */
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
} SDL_KeyboardEvent; } SDL_KeyboardEvent;
/** /**
...@@ -157,9 +157,9 @@ typedef struct SDL_KeyboardEvent ...@@ -157,9 +157,9 @@ typedef struct SDL_KeyboardEvent
typedef struct SDL_TextInputEvent typedef struct SDL_TextInputEvent
{ {
Uint8 type; /**< SDL_TEXTINPUT */ Uint8 type; /**< SDL_TEXTINPUT */
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
Uint8 which; /**< The keyboard device index */ Uint8 which; /**< The keyboard device index */
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
} SDL_TextInputEvent; } SDL_TextInputEvent;
/** /**
...@@ -170,6 +170,7 @@ typedef struct SDL_TextInputEvent ...@@ -170,6 +170,7 @@ typedef struct SDL_TextInputEvent
typedef struct SDL_MouseMotionEvent typedef struct SDL_MouseMotionEvent
{ {
Uint8 type; /**< SDL_MOUSEMOTION */ Uint8 type; /**< SDL_MOUSEMOTION */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
Uint8 which; /**< The mouse device index */ Uint8 which; /**< The mouse device index */
Uint8 state; /**< The current button state */ Uint8 state; /**< The current button state */
int x; /**< X coordinate, relative to window */ int x; /**< X coordinate, relative to window */
...@@ -183,7 +184,6 @@ typedef struct SDL_MouseMotionEvent ...@@ -183,7 +184,6 @@ typedef struct SDL_MouseMotionEvent
int cursor; /**< The cursor being used in the event */ int cursor; /**< The cursor being used in the event */
int xrel; /**< The relative motion in the X direction */ int xrel; /**< The relative motion in the X direction */
int yrel; /**< The relative motion in the Y direction */ int yrel; /**< The relative motion in the Y direction */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
} SDL_MouseMotionEvent; } SDL_MouseMotionEvent;
/** /**
...@@ -194,12 +194,12 @@ typedef struct SDL_MouseMotionEvent ...@@ -194,12 +194,12 @@ typedef struct SDL_MouseMotionEvent
typedef struct SDL_MouseButtonEvent typedef struct SDL_MouseButtonEvent
{ {
Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
Uint8 which; /**< The mouse device index */ Uint8 which; /**< The mouse device index */
Uint8 button; /**< The mouse button index */ Uint8 button; /**< The mouse button index */
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
int x; /**< X coordinate, relative to window */ int x; /**< X coordinate, relative to window */
int y; /**< Y coordinate, relative to window */ int y; /**< Y coordinate, relative to window */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
} SDL_MouseButtonEvent; } SDL_MouseButtonEvent;
/** /**
...@@ -210,10 +210,10 @@ typedef struct SDL_MouseButtonEvent ...@@ -210,10 +210,10 @@ typedef struct SDL_MouseButtonEvent
typedef struct SDL_MouseWheelEvent typedef struct SDL_MouseWheelEvent
{ {
Uint8 type; /**< SDL_MOUSEWHEEL */ Uint8 type; /**< SDL_MOUSEWHEEL */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
Uint8 which; /**< The mouse device index */ Uint8 which; /**< The mouse device index */
int x; /**< The amount scrolled horizontally */ int x; /**< The amount scrolled horizontally */
int y; /**< The amount scrolled vertically */ int y; /**< The amount scrolled vertically */
SDL_WindowID windowID; /**< The window with mouse focus, if any */
} SDL_MouseWheelEvent; } SDL_MouseWheelEvent;
/** /**
...@@ -292,10 +292,10 @@ typedef struct SDL_QuitEvent ...@@ -292,10 +292,10 @@ typedef struct SDL_QuitEvent
typedef struct SDL_UserEvent typedef struct SDL_UserEvent
{ {
Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */
SDL_WindowID windowID; /**< The associated window if any*/
int code; /**< User defined event code */ int code; /**< User defined event code */
void *data1; /**< User defined data pointer */ void *data1; /**< User defined data pointer */
void *data2; /**< User defined data pointer */ void *data2; /**< User defined data pointer */
SDL_WindowID windowID; /**< The associated window if any*/
} SDL_UserEvent; } SDL_UserEvent;
/** /**
...@@ -316,6 +316,7 @@ typedef struct SDL_SysWMEvent ...@@ -316,6 +316,7 @@ typedef struct SDL_SysWMEvent
typedef struct SDL_ProximityEvent typedef struct SDL_ProximityEvent
{ {
Uint8 type; Uint8 type;
SDL_WindowID windowID; /**< The associated window */
Uint8 which; Uint8 which;
int cursor; int cursor;
int x; int x;
......
...@@ -369,6 +369,8 @@ SDL_SendProximity(int id, int x, int y, int type) ...@@ -369,6 +369,8 @@ SDL_SendProximity(int id, int x, int y, int type)
event.proximity.y = y; event.proximity.y = y;
event.proximity.cursor = mouse->current_end; event.proximity.cursor = mouse->current_end;
event.proximity.type = type; event.proximity.type = type;
/* FIXME: is this right? */
event.proximity.windowID = mouse->focus;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
if (type == SDL_PROXIMITYIN) { if (type == SDL_PROXIMITYIN) {
mouse->proximity = SDL_TRUE; mouse->proximity = SDL_TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment