Mercurial > sdl-ios-xcode
diff include/SDL_events.h @ 3191:91b335df6fc8
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;
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 10 Jun 2009 14:00:21 +0000 |
parents | 0c85abc61e47 |
children | 00cace2d9080 |
line wrap: on
line diff
--- a/include/SDL_events.h Wed Jun 10 13:54:13 2009 +0000 +++ b/include/SDL_events.h Wed Jun 10 14:00:21 2009 +0000 @@ -128,10 +128,10 @@ typedef struct SDL_WindowEvent { Uint8 type; /**< SDL_WINDOWEVENT */ + SDL_WindowID windowID; /**< The associated window */ Uint8 event; /**< SDL_WindowEventID */ int data1; /**< event dependent data */ int data2; /**< event dependent data */ - SDL_WindowID windowID; /**< The associated window */ } SDL_WindowEvent; /** @@ -142,10 +142,10 @@ typedef struct SDL_KeyboardEvent { Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ Uint8 which; /**< The keyboard device index */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ SDL_keysym keysym; /**< The key that was pressed or released */ - SDL_WindowID windowID; /**< The window with keyboard focus, if any */ } SDL_KeyboardEvent; /** @@ -157,9 +157,9 @@ typedef struct SDL_TextInputEvent { Uint8 type; /**< SDL_TEXTINPUT */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ Uint8 which; /**< The keyboard device index */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ - SDL_WindowID windowID; /**< The window with keyboard focus, if any */ } SDL_TextInputEvent; /** @@ -170,6 +170,7 @@ typedef struct SDL_MouseMotionEvent { Uint8 type; /**< SDL_MOUSEMOTION */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ Uint8 which; /**< The mouse device index */ Uint8 state; /**< The current button state */ int x; /**< X coordinate, relative to window */ @@ -183,7 +184,6 @@ int cursor; /**< The cursor being used in the event */ int xrel; /**< The relative motion in the X direction */ int yrel; /**< The relative motion in the Y direction */ - SDL_WindowID windowID; /**< The window with mouse focus, if any */ } SDL_MouseMotionEvent; /** @@ -194,12 +194,12 @@ typedef struct SDL_MouseButtonEvent { Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ Uint8 which; /**< The mouse device index */ Uint8 button; /**< The mouse button index */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ int x; /**< X coordinate, relative to window */ int y; /**< Y coordinate, relative to window */ - SDL_WindowID windowID; /**< The window with mouse focus, if any */ } SDL_MouseButtonEvent; /** @@ -210,10 +210,10 @@ typedef struct SDL_MouseWheelEvent { Uint8 type; /**< SDL_MOUSEWHEEL */ + SDL_WindowID windowID; /**< The window with mouse focus, if any */ Uint8 which; /**< The mouse device index */ int x; /**< The amount scrolled horizontally */ int y; /**< The amount scrolled vertically */ - SDL_WindowID windowID; /**< The window with mouse focus, if any */ } SDL_MouseWheelEvent; /** @@ -292,10 +292,10 @@ typedef struct SDL_UserEvent { Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ + SDL_WindowID windowID; /**< The associated window if any*/ int code; /**< User defined event code */ void *data1; /**< User defined data pointer */ void *data2; /**< User defined data pointer */ - SDL_WindowID windowID; /**< The associated window if any*/ } SDL_UserEvent; /** @@ -316,6 +316,7 @@ typedef struct SDL_ProximityEvent { Uint8 type; + SDL_WindowID windowID; /**< The associated window */ Uint8 which; int cursor; int x;