Proof of concept done - Win32 GDI implementation mostly complete. SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Thu, 06 Jul 2006 07:17:11 +0000
branchSDL-1.3
changeset 17246c63fc2bd986
parent 1723 4bdbb9b2bd0a
child 1725 98a3207ddde8
Proof of concept done - Win32 GDI implementation mostly complete.
configure.in
include/SDL_compat.h
include/SDL_events.h
include/SDL_keyboard.h
include/SDL_mouse.h
include/SDL_video.h
src/SDL_compat.c
src/events/SDL_events.c
src/events/SDL_events_c.h
src/events/SDL_keyboard.c
src/events/SDL_keyboard_c.h
src/events/SDL_mouse.c
src/events/SDL_mouse_c.h
src/events/SDL_windowevents.c
src/events/SDL_windowevents_c.h
src/video/SDL_surface.c
src/video/SDL_video.c
src/video/win32/SDL_dibrender.c
src/video/win32/SDL_dibrender.h
src/video/win32/SDL_vkeys.h
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32keyboard.c
src/video/win32/SDL_win32keyboard.h
src/video/win32/SDL_win32mouse.c
src/video/win32/SDL_win32mouse.h
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32video.h
src/video/win32/SDL_win32window.c
src/video/win32/SDL_win32window.h
src/video/win32/wmmsg.h
test/graywin.c
test/testsprite2.c
test/testwm.c
test/threadwin.c
     1.1 --- a/configure.in	Thu Jul 06 05:53:32 2006 +0000
     1.2 +++ b/configure.in	Thu Jul 06 07:17:11 2006 +0000
     1.3 @@ -2347,7 +2347,7 @@
     1.4              have_loadso=yes
     1.5          fi
     1.6          # Set up the system libraries we need
     1.7 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
     1.8 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm"
     1.9          # The Win32 platform requires special setup
    1.10          SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
    1.11          SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
     2.1 --- a/include/SDL_compat.h	Thu Jul 06 05:53:32 2006 +0000
     2.2 +++ b/include/SDL_compat.h	Thu Jul 06 07:17:11 2006 +0000
     2.3 @@ -57,6 +57,12 @@
     2.4  #define SDL_ACTIVEEVENT	SDL_EVENT_RESERVED1
     2.5  #define SDL_VIDEORESIZE	SDL_EVENT_RESERVED2
     2.6  #define SDL_VIDEOEXPOSE	SDL_EVENT_RESERVED3
     2.7 +#define SDL_ACTIVEEVENTMASK	SDL_EVENTMASK(SDL_ACTIVEEVENT)
     2.8 +#define SDL_VIDEORESIZEMASK SDL_EVENTMASK(SDL_VIDEORESIZE)
     2.9 +#define SDL_VIDEOEXPOSEMASK SDL_EVENTMASK(SDL_VIDEOEXPOSE)
    2.10 +
    2.11 +#define SDL_BUTTON_WHEELUP	4
    2.12 +#define SDL_BUTTON_WHEELDOWN	5
    2.13  
    2.14  typedef struct SDL_VideoInfo
    2.15  {
     3.1 --- a/include/SDL_events.h	Thu Jul 06 05:53:32 2006 +0000
     3.2 +++ b/include/SDL_events.h	Thu Jul 06 07:17:11 2006 +0000
     3.3 @@ -60,9 +60,11 @@
     3.4      SDL_WINDOWEVENT,            /**< Window state change */
     3.5      SDL_KEYDOWN,                /**< Keys pressed */
     3.6      SDL_KEYUP,                  /**< Keys released */
     3.7 +    SDL_TEXTINPUT,                              /**< Keyboard text input */
     3.8      SDL_MOUSEMOTION,            /**< Mouse moved */
     3.9      SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
    3.10      SDL_MOUSEBUTTONUP,          /**< Mouse button released */
    3.11 +    SDL_MOUSEWHEEL,                             /**< Mouse wheel motion */
    3.12      SDL_JOYAXISMOTION,          /**< Joystick axis motion */
    3.13      SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
    3.14      SDL_JOYHATMOTION,           /**< Joystick hat position change */
    3.15 @@ -93,9 +95,11 @@
    3.16      SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
    3.17      SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
    3.18      SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
    3.19 +    SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
    3.20      SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
    3.21      SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
    3.22      SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
    3.23 +    SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
    3.24      SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
    3.25          SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
    3.26      SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
    3.27 @@ -141,17 +145,17 @@
    3.28  } SDL_KeyboardEvent;
    3.29  
    3.30  /**
    3.31 - * \struct SDL_CharEvent
    3.32 + * \struct SDL_TextInputEvent
    3.33   *
    3.34 - * \brief Keyboard input event structure
    3.35 + * \brief Keyboard text input event structure
    3.36   */
    3.37 -typedef struct SDL_CharEvent
    3.38 +typedef struct SDL_TextInputEvent
    3.39  {
    3.40 -    Uint8 type;             /**< SDL_CHARINPUT (FIXME: NYI) */
    3.41 +    Uint8 type;             /**< SDL_TEXTINPUT */
    3.42      Uint8 which;            /**< The keyboard device index */
    3.43      char text[32];          /**< The input text */
    3.44      SDL_WindowID windowID;  /**< The window with keyboard focus, if any */
    3.45 -} SDL_CharEvent;
    3.46 +} SDL_TextInputEvent;
    3.47  
    3.48  /**
    3.49   * \struct SDL_MouseMotionEvent
    3.50 @@ -187,6 +191,19 @@
    3.51  } SDL_MouseButtonEvent;
    3.52  
    3.53  /**
    3.54 + * \struct SDL_MouseWheelEvent
    3.55 + *
    3.56 + * \brief Mouse wheel event structure
    3.57 + */
    3.58 +typedef struct SDL_MouseWheelEvent
    3.59 +{
    3.60 +    Uint8 type;             /**< SDL_MOUSEWHEEL */
    3.61 +    Uint8 which;            /**< The mouse device index */
    3.62 +    int motion;                                 /**< The direction and distance scrolled */
    3.63 +    SDL_WindowID windowID;  /**< The window with mouse focus, if any */
    3.64 +} SDL_MouseWheelEvent;
    3.65 +
    3.66 +/**
    3.67   * \struct SDL_JoyAxisEvent
    3.68   *
    3.69   * \brief Joystick axis motion event structure
    3.70 @@ -306,8 +323,10 @@
    3.71      Uint8 type;                     /**< Event type, shared with all events */
    3.72      SDL_WindowEvent window;         /**< Window event data */
    3.73      SDL_KeyboardEvent key;          /**< Keyboard event data */
    3.74 +    SDL_TextInputEvent text;                    /**< Text input event data */
    3.75      SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
    3.76      SDL_MouseButtonEvent button;    /**< Mouse button event data */
    3.77 +    SDL_MouseWheelEvent wheel;                  /**< Mouse wheel event data */
    3.78      SDL_JoyAxisEvent jaxis;         /**< Joystick axis event data */
    3.79      SDL_JoyBallEvent jball;         /**< Joystick ball event data */
    3.80      SDL_JoyHatEvent jhat;           /**< Joystick hat event data */
    3.81 @@ -353,6 +372,10 @@
    3.82                                             SDL_eventaction action,
    3.83                                             Uint32 mask);
    3.84  
    3.85 +/* Checks to see if certain event types are in the event queue.
    3.86 + */
    3.87 +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask);
    3.88 +
    3.89  /* Polls for currently pending events, and returns 1 if there are any pending
    3.90     events, or 0 if there are none available.  If 'event' is not NULL, the next
    3.91     event is removed from the queue and stored in that area.
     4.1 --- a/include/SDL_keyboard.h	Thu Jul 06 05:53:32 2006 +0000
     4.2 +++ b/include/SDL_keyboard.h	Thu Jul 06 07:17:11 2006 +0000
     4.3 @@ -52,7 +52,7 @@
     4.4      Uint8 padding[3];           /**< alignment padding */
     4.5      Uint16 sym;                 /**< SDL virtual keysym */
     4.6      Uint16 mod;                 /**< current key modifiers */
     4.7 -    Uint32 unicode;             /**< OBSOLETE, use SDL_CharEvent instead */
     4.8 +    Uint32 unicode;             /**< OBSOLETE, use SDL_TextInputEvent instead */
     4.9  } SDL_keysym;
    4.10  
    4.11  /* Function prototypes */
     5.1 --- a/include/SDL_mouse.h	Thu Jul 06 05:53:32 2006 +0000
     5.2 +++ b/include/SDL_mouse.h	Thu Jul 06 07:17:11 2006 +0000
     5.3 @@ -202,15 +202,11 @@
     5.4     Button 1:	Left mouse button
     5.5     Button 2:	Middle mouse button
     5.6     Button 3:	Right mouse button
     5.7 -   Button 4:	Mouse wheel up	 (may also be a real button)
     5.8 -   Button 5:	Mouse wheel down (may also be a real button)
     5.9   */
    5.10  #define SDL_BUTTON(X)		(1 << ((X)-1))
    5.11  #define SDL_BUTTON_LEFT		1
    5.12  #define SDL_BUTTON_MIDDLE	2
    5.13  #define SDL_BUTTON_RIGHT	3
    5.14 -#define SDL_BUTTON_WHEELUP	4
    5.15 -#define SDL_BUTTON_WHEELDOWN	5
    5.16  #define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
    5.17  #define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
    5.18  #define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
     6.1 --- a/include/SDL_video.h	Thu Jul 06 05:53:32 2006 +0000
     6.2 +++ b/include/SDL_video.h	Thu Jul 06 07:17:11 2006 +0000
     6.3 @@ -148,6 +148,7 @@
     6.4      SDL_WINDOWEVENT_NONE,               /**< Never used */
     6.5      SDL_WINDOWEVENT_SHOWN,              /**< Window has been shown */
     6.6      SDL_WINDOWEVENT_HIDDEN,             /**< Window has been hidden */
     6.7 +    SDL_WINDOWEVENT_EXPOSED,            /**< Window has been exposed and should be redrawn */
     6.8      SDL_WINDOWEVENT_MOVED,              /**< Window has been moved to data1,data2 */
     6.9      SDL_WINDOWEVENT_RESIZED,            /**< Window size changed to data1xdata2 */
    6.10      SDL_WINDOWEVENT_MINIMIZED,          /**< Window has been minimized */
    6.11 @@ -157,6 +158,7 @@
    6.12      SDL_WINDOWEVENT_LEAVE,              /**< The window has lost mouse focus */
    6.13      SDL_WINDOWEVENT_FOCUS_GAINED,       /**< The window has gained keyboard focus */
    6.14      SDL_WINDOWEVENT_FOCUS_LOST,         /**< The window has lost keyboard focus */
    6.15 +    SDL_WINDOWEVENT_CLOSE,                              /**< The window manager requests that the window be closed */
    6.16  } SDL_WindowEventID;
    6.17  
    6.18  /**
    6.19 @@ -1419,6 +1421,13 @@
    6.20   */
    6.21  extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
    6.22  
    6.23 +/*
    6.24 + * Calculate the intersection of two rectangles
    6.25 + */
    6.26 +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
    6.27 +                                                   const SDL_Rect * B,
    6.28 +                                                   SDL_Rect * intersection);
    6.29 +
    6.30  /* Ends C function definitions when using C++ */
    6.31  #ifdef __cplusplus
    6.32  /* *INDENT-OFF* */
     7.1 --- a/src/SDL_compat.c	Thu Jul 06 05:53:32 2006 +0000
     7.2 +++ b/src/SDL_compat.c	Thu Jul 06 07:17:11 2006 +0000
     7.3 @@ -164,6 +164,12 @@
     7.4      switch (event->type) {
     7.5      case SDL_WINDOWEVENT:
     7.6          switch (event->window.event) {
     7.7 +        case SDL_WINDOWEVENT_EXPOSED:
     7.8 +            if (!SDL_HasEvent(SDL_VIDEOEXPOSEMASK)) {
     7.9 +                fake.type = SDL_VIDEOEXPOSE;
    7.10 +                SDL_PushEvent(&fake);
    7.11 +            }
    7.12 +            break;
    7.13          case SDL_WINDOWEVENT_RESIZED:
    7.14              fake.type = SDL_VIDEORESIZE;
    7.15              fake.resize.w = event->window.data1;
    7.16 @@ -206,6 +212,10 @@
    7.17              fake.active.state = SDL_APPINPUTFOCUS;
    7.18              SDL_PushEvent(&fake);
    7.19              break;
    7.20 +        case SDL_WINDOWEVENT_CLOSE:
    7.21 +            fake.type = SDL_QUIT;
    7.22 +            SDL_PushEvent(&fake);
    7.23 +            break;
    7.24          }
    7.25      case SDL_KEYDOWN:
    7.26      case SDL_KEYUP:
    7.27 @@ -226,6 +236,38 @@
    7.28              }
    7.29              break;
    7.30          }
    7.31 +    case SDL_MOUSEWHEEL:
    7.32 +        {
    7.33 +            Uint8 button;
    7.34 +            int selected;
    7.35 +            int x, y;
    7.36 +
    7.37 +            selected = SDL_SelectMouse(event->wheel.which);
    7.38 +            SDL_GetMouseState(&x, &y);
    7.39 +            SDL_SelectMouse(selected);
    7.40 +
    7.41 +            if (event->wheel.motion > 0) {
    7.42 +                button = SDL_BUTTON_WHEELUP;
    7.43 +            } else {
    7.44 +                button = SDL_BUTTON_WHEELDOWN;
    7.45 +            }
    7.46 +
    7.47 +            fake.button.which = event->wheel.windowID;
    7.48 +            fake.button.button = button;
    7.49 +            fake.button.x = x;
    7.50 +            fake.button.y = y;
    7.51 +            fake.button.windowID = event->wheel.windowID;
    7.52 +
    7.53 +            fake.type = SDL_MOUSEBUTTONDOWN;
    7.54 +            fake.button.state = SDL_PRESSED;
    7.55 +            SDL_PushEvent(&fake);
    7.56 +
    7.57 +            fake.type = SDL_MOUSEBUTTONUP;
    7.58 +            fake.button.state = SDL_RELEASED;
    7.59 +            SDL_PushEvent(&fake);
    7.60 +            break;
    7.61 +        }
    7.62 +
    7.63      }
    7.64      if (orig_eventfilter) {
    7.65          return orig_eventfilter(orig_eventfilterparam, event);
    7.66 @@ -304,7 +346,9 @@
    7.67          window_flags |= SDL_WINDOW_BORDERLESS;
    7.68      }
    7.69      SDL_VideoWindow =
    7.70 -        SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags);
    7.71 +        SDL_CreateWindow(wm_title, SDL_WINDOWPOS_UNDEFINED,
    7.72 +                         SDL_WINDOWPOS_UNDEFINED, width, height,
    7.73 +                         window_flags);
    7.74      if (!SDL_VideoWindow) {
    7.75          return NULL;
    7.76      }
     8.1 --- a/src/events/SDL_events.c	Thu Jul 06 05:53:32 2006 +0000
     8.2 +++ b/src/events/SDL_events.c	Thu Jul 06 07:17:11 2006 +0000
     8.3 @@ -373,6 +373,12 @@
     8.4      return (used);
     8.5  }
     8.6  
     8.7 +SDL_bool
     8.8 +SDL_HasEvent(Uint32 mask)
     8.9 +{
    8.10 +    return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, mask) > 0);
    8.11 +}
    8.12 +
    8.13  /* Run the system dependent event loops */
    8.14  void
    8.15  SDL_PumpEvents(void)
    8.16 @@ -520,7 +526,7 @@
    8.17  /* This is a generic event handler.
    8.18   */
    8.19  int
    8.20 -SDL_PrivateSysWMEvent(SDL_SysWMmsg * message)
    8.21 +SDL_SendSysWMEvent(SDL_SysWMmsg * message)
    8.22  {
    8.23      int posted;
    8.24  
     9.1 --- a/src/events/SDL_events_c.h	Thu Jul 06 05:53:32 2006 +0000
     9.2 +++ b/src/events/SDL_events_c.h	Thu Jul 06 07:17:11 2006 +0000
     9.3 @@ -25,6 +25,7 @@
     9.4  #include "SDL_events.h"
     9.5  #include "SDL_mouse_c.h"
     9.6  #include "SDL_keyboard_c.h"
     9.7 +#include "SDL_windowevents_c.h"
     9.8  
     9.9  /* Start and stop the event processing loop */
    9.10  extern int SDL_StartEventLoop(Uint32 flags);
    9.11 @@ -35,6 +36,8 @@
    9.12  extern void SDL_Unlock_EventThread(void);
    9.13  extern Uint32 SDL_EventThreadID(void);
    9.14  
    9.15 +extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
    9.16 +
    9.17  extern int SDL_QuitInit(void);
    9.18  extern int SDL_SendQuit(void);
    9.19  extern void SDL_QuitQuit(void);
    10.1 --- a/src/events/SDL_keyboard.c	Thu Jul 06 05:53:32 2006 +0000
    10.2 +++ b/src/events/SDL_keyboard.c	Thu Jul 06 07:17:11 2006 +0000
    10.3 @@ -338,18 +338,15 @@
    10.4  SDL_ResetKeyboard(int index)
    10.5  {
    10.6      SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
    10.7 -    SDL_keysym keysym;
    10.8 -    Uint16 key;
    10.9 +    SDLKey key;
   10.10  
   10.11      if (!keyboard) {
   10.12          return;
   10.13      }
   10.14  
   10.15 -    SDL_memset(&keysym, 0, (sizeof keysym));
   10.16      for (key = SDLK_FIRST; key < SDLK_LAST; ++key) {
   10.17          if (keyboard->keystate[key] == SDL_PRESSED) {
   10.18 -            keysym.sym = key;
   10.19 -            SDL_SendKeyboardKey(index, 0, SDL_RELEASED, &keysym);
   10.20 +            SDL_SendKeyboardKey(index, SDL_RELEASED, 0, key);
   10.21          }
   10.22      }
   10.23      keyboard->repeat.timestamp = 0;
   10.24 @@ -463,9 +460,57 @@
   10.25      return keyname;
   10.26  }
   10.27  
   10.28 +void
   10.29 +SDL_SetKeyboardFocus(int index, SDL_WindowID windowID)
   10.30 +{
   10.31 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
   10.32 +    int i;
   10.33 +    SDL_bool focus;
   10.34 +
   10.35 +    if (!keyboard || (keyboard->focus == windowID)) {
   10.36 +        return;
   10.37 +    }
   10.38 +
   10.39 +    /* See if the current window has lost focus */
   10.40 +    if (keyboard->focus) {
   10.41 +        focus = SDL_FALSE;
   10.42 +        for (i = 0; i < SDL_num_keyboards; ++i) {
   10.43 +            SDL_Keyboard *check;
   10.44 +            if (i != index) {
   10.45 +                check = SDL_GetKeyboard(i);
   10.46 +                if (check && check->focus == keyboard->focus) {
   10.47 +                    focus = SDL_TRUE;
   10.48 +                    break;
   10.49 +                }
   10.50 +            }
   10.51 +        }
   10.52 +        if (!focus) {
   10.53 +            SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
   10.54 +        }
   10.55 +    }
   10.56 +
   10.57 +    keyboard->focus = windowID;
   10.58 +
   10.59 +    if (keyboard->focus) {
   10.60 +        focus = SDL_FALSE;
   10.61 +        for (i = 0; i < SDL_num_keyboards; ++i) {
   10.62 +            SDL_Keyboard *check;
   10.63 +            if (i != index) {
   10.64 +                check = SDL_GetKeyboard(i);
   10.65 +                if (check && check->focus == keyboard->focus) {
   10.66 +                    focus = SDL_TRUE;
   10.67 +                    break;
   10.68 +                }
   10.69 +            }
   10.70 +        }
   10.71 +        if (!focus) {
   10.72 +            SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
   10.73 +        }
   10.74 +    }
   10.75 +}
   10.76 +
   10.77  int
   10.78 -SDL_SendKeyboardKey(int index, SDL_WindowID windowID, Uint8 state,
   10.79 -                    SDL_keysym * keysym)
   10.80 +SDL_SendKeyboardKey(int index, Uint8 state, Uint8 scancode, SDLKey key)
   10.81  {
   10.82      SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
   10.83      int posted, repeatable;
   10.84 @@ -475,106 +520,91 @@
   10.85      if (!keyboard) {
   10.86          return 0;
   10.87      }
   10.88 -
   10.89 -    if (windowID) {
   10.90 -        keyboard->focus = windowID;
   10.91 -    }
   10.92  #if 0
   10.93 -    printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym),
   10.94 +    printf("The '%s' key has been %s\n", SDL_GetKeyName(key),
   10.95             state == SDL_PRESSED ? "pressed" : "released");
   10.96  #endif
   10.97 -    /* Set up the keysym */
   10.98 -    modstate = keyboard->modstate;
   10.99 -
  10.100      repeatable = 0;
  10.101 -
  10.102      if (state == SDL_PRESSED) {
  10.103 -        keysym->mod = modstate;
  10.104 -        switch (keysym->sym) {
  10.105 +        modstate = keyboard->modstate;
  10.106 +        switch (key) {
  10.107          case SDLK_UNKNOWN:
  10.108              break;
  10.109          case SDLK_NUMLOCK:
  10.110 -            modstate ^= KMOD_NUM;
  10.111 -            if (!(modstate & KMOD_NUM))
  10.112 -                state = SDL_RELEASED;
  10.113 -            keysym->mod = modstate;
  10.114 +            keyboard->modstate ^= KMOD_NUM;
  10.115              break;
  10.116          case SDLK_CAPSLOCK:
  10.117 -            modstate ^= KMOD_CAPS;
  10.118 -            if (!(modstate & KMOD_CAPS))
  10.119 -                state = SDL_RELEASED;
  10.120 -            keysym->mod = modstate;
  10.121 +            keyboard->modstate ^= KMOD_CAPS;
  10.122              break;
  10.123          case SDLK_LCTRL:
  10.124 -            modstate |= KMOD_LCTRL;
  10.125 +            keyboard->modstate |= KMOD_LCTRL;
  10.126              break;
  10.127          case SDLK_RCTRL:
  10.128 -            modstate |= KMOD_RCTRL;
  10.129 +            keyboard->modstate |= KMOD_RCTRL;
  10.130              break;
  10.131          case SDLK_LSHIFT:
  10.132 -            modstate |= KMOD_LSHIFT;
  10.133 +            keyboard->modstate |= KMOD_LSHIFT;
  10.134              break;
  10.135          case SDLK_RSHIFT:
  10.136 -            modstate |= KMOD_RSHIFT;
  10.137 +            keyboard->modstate |= KMOD_RSHIFT;
  10.138              break;
  10.139          case SDLK_LALT:
  10.140 -            modstate |= KMOD_LALT;
  10.141 +            keyboard->modstate |= KMOD_LALT;
  10.142              break;
  10.143          case SDLK_RALT:
  10.144 -            modstate |= KMOD_RALT;
  10.145 +            keyboard->modstate |= KMOD_RALT;
  10.146              break;
  10.147          case SDLK_LMETA:
  10.148 -            modstate |= KMOD_LMETA;
  10.149 +            keyboard->modstate |= KMOD_LMETA;
  10.150              break;
  10.151          case SDLK_RMETA:
  10.152 -            modstate |= KMOD_RMETA;
  10.153 +            keyboard->modstate |= KMOD_RMETA;
  10.154              break;
  10.155          case SDLK_MODE:
  10.156 -            modstate |= KMOD_MODE;
  10.157 +            keyboard->modstate |= KMOD_MODE;
  10.158              break;
  10.159          default:
  10.160              repeatable = 1;
  10.161              break;
  10.162          }
  10.163      } else {
  10.164 -        switch (keysym->sym) {
  10.165 +        switch (key) {
  10.166          case SDLK_UNKNOWN:
  10.167              break;
  10.168          case SDLK_NUMLOCK:
  10.169          case SDLK_CAPSLOCK:
  10.170 -            /* Only send keydown events */
  10.171 -            return (0);
  10.172 +            break;
  10.173          case SDLK_LCTRL:
  10.174 -            modstate &= ~KMOD_LCTRL;
  10.175 +            keyboard->modstate &= ~KMOD_LCTRL;
  10.176              break;
  10.177          case SDLK_RCTRL:
  10.178 -            modstate &= ~KMOD_RCTRL;
  10.179 +            keyboard->modstate &= ~KMOD_RCTRL;
  10.180              break;
  10.181          case SDLK_LSHIFT:
  10.182 -            modstate &= ~KMOD_LSHIFT;
  10.183 +            keyboard->modstate &= ~KMOD_LSHIFT;
  10.184              break;
  10.185          case SDLK_RSHIFT:
  10.186 -            modstate &= ~KMOD_RSHIFT;
  10.187 +            keyboard->modstate &= ~KMOD_RSHIFT;
  10.188              break;
  10.189          case SDLK_LALT:
  10.190 -            modstate &= ~KMOD_LALT;
  10.191 +            keyboard->modstate &= ~KMOD_LALT;
  10.192              break;
  10.193          case SDLK_RALT:
  10.194 -            modstate &= ~KMOD_RALT;
  10.195 +            keyboard->modstate &= ~KMOD_RALT;
  10.196              break;
  10.197          case SDLK_LMETA:
  10.198 -            modstate &= ~KMOD_LMETA;
  10.199 +            keyboard->modstate &= ~KMOD_LMETA;
  10.200              break;
  10.201          case SDLK_RMETA:
  10.202 -            modstate &= ~KMOD_RMETA;
  10.203 +            keyboard->modstate &= ~KMOD_RMETA;
  10.204              break;
  10.205          case SDLK_MODE:
  10.206 -            modstate &= ~KMOD_MODE;
  10.207 +            keyboard->modstate &= ~KMOD_MODE;
  10.208              break;
  10.209          default:
  10.210              break;
  10.211          }
  10.212 -        keysym->mod = modstate;
  10.213 +        modstate = keyboard->modstate;
  10.214      }
  10.215  
  10.216      /* Figure out what type of event this is */
  10.217 @@ -588,7 +618,7 @@
  10.218           * jk 991215 - Added
  10.219           */
  10.220          if (keyboard->repeat.timestamp &&
  10.221 -            keyboard->repeat.evt.key.keysym.sym == keysym->sym) {
  10.222 +            keyboard->repeat.evt.key.keysym.sym == key) {
  10.223              keyboard->repeat.timestamp = 0;
  10.224          }
  10.225          break;
  10.226 @@ -597,9 +627,9 @@
  10.227          return 0;
  10.228      }
  10.229  
  10.230 -    if (keysym->sym != SDLK_UNKNOWN) {
  10.231 +    if (key != SDLK_UNKNOWN) {
  10.232          /* Drop events that don't change state */
  10.233 -        if (keyboard->keystate[keysym->sym] == state) {
  10.234 +        if (keyboard->keystate[key] == state) {
  10.235  #if 0
  10.236              printf("Keyboard event didn't change state - dropped!\n");
  10.237  #endif
  10.238 @@ -607,8 +637,7 @@
  10.239          }
  10.240  
  10.241          /* Update internal keyboard state */
  10.242 -        keyboard->modstate = modstate;
  10.243 -        keyboard->keystate[keysym->sym] = state;
  10.244 +        keyboard->keystate[key] = state;
  10.245      }
  10.246  
  10.247      /* Post the event, if desired */
  10.248 @@ -618,7 +647,10 @@
  10.249          event.key.type = type;
  10.250          event.key.which = (Uint8) index;
  10.251          event.key.state = state;
  10.252 -        event.key.keysym = *keysym;
  10.253 +        event.key.keysym.scancode = scancode;
  10.254 +        event.key.keysym.sym = (Uint16) key;
  10.255 +        event.key.keysym.mod = modstate;
  10.256 +        event.key.keysym.unicode = 0;
  10.257          event.key.windowID = keyboard->focus;
  10.258          /*
  10.259           * jk 991215 - Added
  10.260 @@ -640,6 +672,32 @@
  10.261      return (posted);
  10.262  }
  10.263  
  10.264 +int
  10.265 +SDL_SendKeyboardText(int index, const char *text)
  10.266 +{
  10.267 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
  10.268 +    int posted;
  10.269 +
  10.270 +    if (!keyboard) {
  10.271 +        return 0;
  10.272 +    }
  10.273 +
  10.274 +    /* Post the event, if desired */
  10.275 +    posted = 0;
  10.276 +    if (SDL_ProcessEvents[SDL_TEXTINPUT] == SDL_ENABLE) {
  10.277 +        SDL_Event event;
  10.278 +        event.text.type = SDL_TEXTINPUT;
  10.279 +        event.text.which = (Uint8) index;
  10.280 +        SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
  10.281 +        event.key.windowID = keyboard->focus;
  10.282 +        if ((SDL_EventOK == NULL) || SDL_EventOK(SDL_EventOKParam, &event)) {
  10.283 +            posted = 1;
  10.284 +            SDL_PushEvent(&event);
  10.285 +        }
  10.286 +    }
  10.287 +    return (posted);
  10.288 +}
  10.289 +
  10.290  /*
  10.291   * jk 991215 - Added
  10.292   */
    11.1 --- a/src/events/SDL_keyboard_c.h	Thu Jul 06 05:53:32 2006 +0000
    11.2 +++ b/src/events/SDL_keyboard_c.h	Thu Jul 06 07:17:11 2006 +0000
    11.3 @@ -75,9 +75,15 @@
    11.4  /* Clear the state of a keyboard at an index */
    11.5  extern void SDL_ResetKeyboard(int index);
    11.6  
    11.7 +/* Set the keyboard focus window */
    11.8 +extern void SDL_SetKeyboardFocus(int index, SDL_WindowID windowID);
    11.9 +
   11.10  /* Send a keyboard event for a keyboard at an index */
   11.11 -extern int SDL_SendKeyboardKey(int index, SDL_WindowID windowID, Uint8 state,
   11.12 -                               SDL_keysym * keysym);
   11.13 +extern int SDL_SendKeyboardKey(int index, Uint8 state, Uint8 scancode,
   11.14 +                               SDLKey key);
   11.15 +
   11.16 +/* Send keyboard text input for a keyboard at an index */
   11.17 +extern int SDL_SendKeyboardText(int index, const char *text);
   11.18  
   11.19  /* Used by the event loop to queue pending keyboard repeat events */
   11.20  extern void SDL_CheckKeyRepeat(void);
    12.1 --- a/src/events/SDL_mouse.c	Thu Jul 06 05:53:32 2006 +0000
    12.2 +++ b/src/events/SDL_mouse.c	Thu Jul 06 07:17:11 2006 +0000
    12.3 @@ -265,9 +265,57 @@
    12.4      return mouse->buttonstate;
    12.5  }
    12.6  
    12.7 +void
    12.8 +SDL_SetMouseFocus(int index, SDL_WindowID windowID)
    12.9 +{
   12.10 +    SDL_Mouse *mouse = SDL_GetMouse(index);
   12.11 +    int i;
   12.12 +    SDL_bool focus;
   12.13 +
   12.14 +    if (!mouse || (mouse->focus == windowID)) {
   12.15 +        return;
   12.16 +    }
   12.17 +
   12.18 +    /* See if the current window has lost focus */
   12.19 +    if (mouse->focus) {
   12.20 +        focus = SDL_FALSE;
   12.21 +        for (i = 0; i < SDL_num_mice; ++i) {
   12.22 +            SDL_Mouse *check;
   12.23 +            if (i != index) {
   12.24 +                check = SDL_GetMouse(i);
   12.25 +                if (check && check->focus == mouse->focus) {
   12.26 +                    focus = SDL_TRUE;
   12.27 +                    break;
   12.28 +                }
   12.29 +            }
   12.30 +        }
   12.31 +        if (!focus) {
   12.32 +            SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
   12.33 +        }
   12.34 +    }
   12.35 +
   12.36 +    mouse->focus = windowID;
   12.37 +
   12.38 +    if (mouse->focus) {
   12.39 +        focus = SDL_FALSE;
   12.40 +        for (i = 0; i < SDL_num_mice; ++i) {
   12.41 +            SDL_Mouse *check;
   12.42 +            if (i != index) {
   12.43 +                check = SDL_GetMouse(i);
   12.44 +                if (check && check->focus == mouse->focus) {
   12.45 +                    focus = SDL_TRUE;
   12.46 +                    break;
   12.47 +                }
   12.48 +            }
   12.49 +        }
   12.50 +        if (!focus) {
   12.51 +            SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
   12.52 +        }
   12.53 +    }
   12.54 +}
   12.55 +
   12.56  int
   12.57 -SDL_SendMouseMotion(int index, SDL_WindowID windowID, int relative, int x,
   12.58 -                    int y)
   12.59 +SDL_SendMouseMotion(int index, int relative, int x, int y)
   12.60  {
   12.61      SDL_Mouse *mouse = SDL_GetMouse(index);
   12.62      int posted;
   12.63 @@ -278,10 +326,6 @@
   12.64          return 0;
   12.65      }
   12.66  
   12.67 -    if (windowID) {
   12.68 -        mouse->focus = windowID;
   12.69 -    }
   12.70 -
   12.71      if (relative) {
   12.72          /* Push the cursor around */
   12.73          xrel = x;
   12.74 @@ -337,8 +381,7 @@
   12.75  }
   12.76  
   12.77  int
   12.78 -SDL_SendMouseButton(int index, SDL_WindowID windowID, Uint8 state,
   12.79 -                    Uint8 button)
   12.80 +SDL_SendMouseButton(int index, Uint8 state, Uint8 button)
   12.81  {
   12.82      SDL_Mouse *mouse = SDL_GetMouse(index);
   12.83      int posted;
   12.84 @@ -348,10 +391,6 @@
   12.85          return 0;
   12.86      }
   12.87  
   12.88 -    if (windowID) {
   12.89 -        mouse->focus = windowID;
   12.90 -    }
   12.91 -
   12.92      /* Figure out which event to perform */
   12.93      switch (state) {
   12.94      case SDL_PRESSED:
   12.95 @@ -395,6 +434,33 @@
   12.96      return posted;
   12.97  }
   12.98  
   12.99 +int
  12.100 +SDL_SendMouseWheel(int index, int motion)
  12.101 +{
  12.102 +    SDL_Mouse *mouse = SDL_GetMouse(index);
  12.103 +    int posted;
  12.104 +
  12.105 +    if (!mouse || !motion) {
  12.106 +        return 0;
  12.107 +    }
  12.108 +
  12.109 +    /* Post the event, if desired */
  12.110 +    posted = 0;
  12.111 +    if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) {
  12.112 +        SDL_Event event;
  12.113 +        event.type = SDL_MOUSEWHEEL;
  12.114 +        event.wheel.which = (Uint8) index;
  12.115 +        event.wheel.motion = motion;
  12.116 +        event.wheel.windowID = mouse->focus;
  12.117 +        if ((SDL_EventOK == NULL)
  12.118 +            || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
  12.119 +            posted = 1;
  12.120 +            SDL_PushEvent(&event);
  12.121 +        }
  12.122 +    }
  12.123 +    return posted;
  12.124 +}
  12.125 +
  12.126  void
  12.127  SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y)
  12.128  {
  12.129 @@ -407,7 +473,8 @@
  12.130      if (mouse->WarpMouse) {
  12.131          mouse->WarpMouse(mouse, windowID, x, y);
  12.132      } else {
  12.133 -        SDL_SendMouseMotion(SDL_current_mouse, windowID, 0, x, y);
  12.134 +        SDL_SetMouseFocus(SDL_current_mouse, windowID);
  12.135 +        SDL_SendMouseMotion(SDL_current_mouse, 0, x, y);
  12.136      }
  12.137  }
  12.138  
    13.1 --- a/src/events/SDL_mouse_c.h	Thu Jul 06 05:53:32 2006 +0000
    13.2 +++ b/src/events/SDL_mouse_c.h	Thu Jul 06 07:17:11 2006 +0000
    13.3 @@ -92,13 +92,17 @@
    13.4  /* Clear the button state of a mouse at an index */
    13.5  extern void SDL_ResetMouse(int index);
    13.6  
    13.7 +/* Set the mouse focus window */
    13.8 +extern void SDL_SetMouseFocus(int index, SDL_WindowID windowID);
    13.9 +
   13.10  /* Send a mouse motion event for a mouse at an index */
   13.11 -extern int SDL_SendMouseMotion(int index, SDL_WindowID windowID, int relative,
   13.12 -                               int x, int y);
   13.13 +extern int SDL_SendMouseMotion(int index, int relative, int x, int y);
   13.14  
   13.15  /* Send a mouse button event for a mouse at an index */
   13.16 -extern int SDL_SendMouseButton(int index, SDL_WindowID windowID, Uint8 state,
   13.17 -                               Uint8 button);
   13.18 +extern int SDL_SendMouseButton(int index, Uint8 state, Uint8 button);
   13.19 +
   13.20 +/* Send a mouse wheel event for a mouse at an index */
   13.21 +extern int SDL_SendMouseWheel(int index, int motion);
   13.22  
   13.23  /* Shutdown the mouse subsystem */
   13.24  extern void SDL_MouseQuit(void);
    14.1 --- a/src/events/SDL_windowevents.c	Thu Jul 06 05:53:32 2006 +0000
    14.2 +++ b/src/events/SDL_windowevents.c	Thu Jul 06 07:17:11 2006 +0000
    14.3 @@ -28,8 +28,8 @@
    14.4  #include "../video/SDL_sysvideo.h"
    14.5  
    14.6  int
    14.7 -SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
    14.8 -                       int data2)
    14.9 +SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
   14.10 +                    int data2)
   14.11  {
   14.12      int posted;
   14.13      SDL_Window *window;
   14.14 @@ -51,6 +51,16 @@
   14.15          }
   14.16          window->flags &= ~SDL_WINDOW_SHOWN;
   14.17          break;
   14.18 +    case SDL_WINDOWEVENT_MOVED:
   14.19 +        if (data1 == window->x && data2 == window->y) {
   14.20 +            return 0;
   14.21 +        }
   14.22 +        break;
   14.23 +    case SDL_WINDOWEVENT_RESIZED:
   14.24 +        if (data1 == window->w && data2 == window->h) {
   14.25 +            return 0;
   14.26 +        }
   14.27 +        break;
   14.28      case SDL_WINDOWEVENT_MINIMIZED:
   14.29          if (window->flags & SDL_WINDOW_MINIMIZED) {
   14.30              return 0;
    15.1 --- a/src/events/SDL_windowevents_c.h	Thu Jul 06 05:53:32 2006 +0000
    15.2 +++ b/src/events/SDL_windowevents_c.h	Thu Jul 06 07:17:11 2006 +0000
    15.3 @@ -27,8 +27,6 @@
    15.4  extern int SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent,
    15.5                                 int data1, int data2);
    15.6  
    15.7 -extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
    15.8 -
    15.9  #endif /* _SDL_windowevents_c_h */
   15.10  
   15.11  /* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/src/video/SDL_surface.c	Thu Jul 06 05:53:32 2006 +0000
    16.2 +++ b/src/video/SDL_surface.c	Thu Jul 06 07:17:11 2006 +0000
    16.3 @@ -418,7 +418,7 @@
    16.4   * A function to calculate the intersection of two rectangles:
    16.5   * return true if the rectangles intersect, false otherwise
    16.6   */
    16.7 -static __inline__ SDL_bool
    16.8 +SDL_bool
    16.9  SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B,
   16.10                    SDL_Rect * intersection)
   16.11  {
    17.1 --- a/src/video/SDL_video.c	Thu Jul 06 05:53:32 2006 +0000
    17.2 +++ b/src/video/SDL_video.c	Thu Jul 06 07:17:11 2006 +0000
    17.3 @@ -188,6 +188,11 @@
    17.4      }
    17.5  #endif
    17.6  
    17.7 +    /* Start the event loop */
    17.8 +    if (SDL_StartEventLoop(flags) < 0) {
    17.9 +        return -1;
   17.10 +    }
   17.11 +
   17.12      /* Check to make sure we don't overwrite '_this' */
   17.13      if (_this != NULL) {
   17.14          SDL_VideoQuit();
   17.15 @@ -277,12 +282,6 @@
   17.16          }
   17.17      }
   17.18  
   17.19 -    /* Start the event loop */
   17.20 -    if (SDL_StartEventLoop(flags) < 0) {
   17.21 -        SDL_VideoQuit();
   17.22 -        return -1;
   17.23 -    }
   17.24 -
   17.25      /* We're ready to go! */
   17.26      return 0;
   17.27  }
   17.28 @@ -1286,10 +1285,22 @@
   17.29      }
   17.30  
   17.31      /* Copy the palette if any */
   17.32 -    if (fmt->palette) {
   17.33 -        SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
   17.34 -                              fmt->palette->ncolors);
   17.35 -        SDL_SetSurfacePalette(&dst, fmt->palette);
   17.36 +    if (SDL_ISPIXELFORMAT_INDEXED(format)) {
   17.37 +        if (fmt->palette) {
   17.38 +            SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
   17.39 +                                  fmt->palette->ncolors);
   17.40 +            SDL_SetSurfacePalette(&dst, fmt->palette);
   17.41 +        } else {
   17.42 +            dst.format->palette =
   17.43 +                SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
   17.44 +            if (!dst.format->palette) {
   17.45 +                SDL_DestroyTexture(textureID);
   17.46 +                SDL_FreeFormat(dst.format);
   17.47 +                return 0;
   17.48 +            }
   17.49 +            SDL_DitherColors(dst.format->palette->colors,
   17.50 +                             SDL_BITSPERPIXEL(format));
   17.51 +        }
   17.52      }
   17.53  
   17.54      /* Make the texture transparent if the surface has colorkey */
   17.55 @@ -1557,7 +1568,8 @@
   17.56  SDL_RenderFill(const SDL_Rect * rect, Uint32 color)
   17.57  {
   17.58      SDL_Renderer *renderer;
   17.59 -    SDL_Rect full_rect;
   17.60 +    SDL_Window *window;
   17.61 +    SDL_Rect real_rect;
   17.62  
   17.63      if (!_this) {
   17.64          return -1;
   17.65 @@ -1568,14 +1580,17 @@
   17.66          return -1;
   17.67      }
   17.68  
   17.69 -    if (!rect) {
   17.70 -        SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   17.71 -        full_rect.x = 0;
   17.72 -        full_rect.y = 0;
   17.73 -        full_rect.w = window->w;
   17.74 -        full_rect.h = window->h;
   17.75 -        rect = &full_rect;
   17.76 +    window = SDL_GetWindowFromID(renderer->window);
   17.77 +    real_rect.x = 0;
   17.78 +    real_rect.y = 0;
   17.79 +    real_rect.w = window->w;
   17.80 +    real_rect.h = window->h;
   17.81 +    if (rect) {
   17.82 +        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
   17.83 +            return 0;
   17.84 +        }
   17.85      }
   17.86 +    rect = &real_rect;
   17.87  
   17.88      return renderer->RenderFill(renderer, rect, color);
   17.89  }
   17.90 @@ -1586,8 +1601,9 @@
   17.91  {
   17.92      SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   17.93      SDL_Renderer *renderer;
   17.94 -    SDL_Rect full_srcrect;
   17.95 -    SDL_Rect full_dstrect;
   17.96 +    SDL_Window *window;
   17.97 +    SDL_Rect real_srcrect;
   17.98 +    SDL_Rect real_dstrect;
   17.99  
  17.100      if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
  17.101          return -1;
  17.102 @@ -1598,20 +1614,21 @@
  17.103          return -1;
  17.104      }
  17.105  
  17.106 +    /* FIXME: implement clipping */
  17.107 +    window = SDL_GetWindowFromID(renderer->window);
  17.108 +    real_srcrect.x = 0;
  17.109 +    real_srcrect.y = 0;
  17.110 +    real_srcrect.w = texture->w;
  17.111 +    real_srcrect.h = texture->h;
  17.112 +    real_dstrect.x = 0;
  17.113 +    real_dstrect.y = 0;
  17.114 +    real_dstrect.w = window->w;
  17.115 +    real_dstrect.h = window->h;
  17.116      if (!srcrect) {
  17.117 -        full_srcrect.x = 0;
  17.118 -        full_srcrect.y = 0;
  17.119 -        full_srcrect.w = texture->w;
  17.120 -        full_srcrect.h = texture->h;
  17.121 -        srcrect = &full_srcrect;
  17.122 +        srcrect = &real_srcrect;
  17.123      }
  17.124      if (!dstrect) {
  17.125 -        SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  17.126 -        full_dstrect.x = 0;
  17.127 -        full_dstrect.y = 0;
  17.128 -        full_dstrect.w = window->w;
  17.129 -        full_dstrect.h = window->h;
  17.130 -        dstrect = &full_dstrect;
  17.131 +        dstrect = &real_dstrect;
  17.132      }
  17.133  
  17.134      return renderer->RenderCopy(renderer, texture, srcrect, dstrect,
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/video/win32/SDL_dibrender.c	Thu Jul 06 07:17:11 2006 +0000
    18.3 @@ -0,0 +1,711 @@
    18.4 +/*
    18.5 +    SDL - Simple DirectMedia Layer
    18.6 +    Copyright (C) 1997-2006 Sam Lantinga
    18.7 +
    18.8 +    This library is free software; you can redistribute it and/or
    18.9 +    modify it under the terms of the GNU Lesser General Public
   18.10 +    License as published by the Free Software Foundation; either
   18.11 +    version 2.1 of the License, or (at your option) any later version.
   18.12 +
   18.13 +    This library is distributed in the hope that it will be useful,
   18.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18.16 +    Lesser General Public License for more details.
   18.17 +
   18.18 +    You should have received a copy of the GNU Lesser General Public
   18.19 +    License along with this library; if not, write to the Free Software
   18.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   18.21 +
   18.22 +    Sam Lantinga
   18.23 +    slouken@libsdl.org
   18.24 +*/
   18.25 +#include "SDL_config.h"
   18.26 +
   18.27 +#include "SDL_win32video.h"
   18.28 +#include "../SDL_yuv_sw_c.h"
   18.29 +
   18.30 +/* GDI renderer implementation */
   18.31 +
   18.32 +static SDL_Renderer *SDL_DIB_CreateRenderer(SDL_Window * window,
   18.33 +                                            Uint32 flags);
   18.34 +static int SDL_DIB_CreateTexture(SDL_Renderer * renderer,
   18.35 +                                 SDL_Texture * texture);
   18.36 +static int SDL_DIB_QueryTexturePixels(SDL_Renderer * renderer,
   18.37 +                                      SDL_Texture * texture, void **pixels,
   18.38 +                                      int *pitch);
   18.39 +static int SDL_DIB_SetTexturePalette(SDL_Renderer * renderer,
   18.40 +                                     SDL_Texture * texture,
   18.41 +                                     const SDL_Color * colors, int firstcolor,
   18.42 +                                     int ncolors);
   18.43 +static int SDL_DIB_GetTexturePalette(SDL_Renderer * renderer,
   18.44 +                                     SDL_Texture * texture,
   18.45 +                                     SDL_Color * colors, int firstcolor,
   18.46 +                                     int ncolors);
   18.47 +static int SDL_DIB_UpdateTexture(SDL_Renderer * renderer,
   18.48 +                                 SDL_Texture * texture, const SDL_Rect * rect,
   18.49 +                                 const void *pixels, int pitch);
   18.50 +static int SDL_DIB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   18.51 +                               const SDL_Rect * rect, int markDirty,
   18.52 +                               void **pixels, int *pitch);
   18.53 +static void SDL_DIB_UnlockTexture(SDL_Renderer * renderer,
   18.54 +                                  SDL_Texture * texture);
   18.55 +static void SDL_DIB_DirtyTexture(SDL_Renderer * renderer,
   18.56 +                                 SDL_Texture * texture, int numrects,
   18.57 +                                 const SDL_Rect * rects);
   18.58 +static void SDL_DIB_SelectRenderTexture(SDL_Renderer * renderer,
   18.59 +                                        SDL_Texture * texture);
   18.60 +static int SDL_DIB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   18.61 +                              Uint32 color);
   18.62 +static int SDL_DIB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   18.63 +                              const SDL_Rect * srcrect,
   18.64 +                              const SDL_Rect * dstrect, int blendMode,
   18.65 +                              int scaleMode);
   18.66 +static int SDL_DIB_RenderReadPixels(SDL_Renderer * renderer,
   18.67 +                                    const SDL_Rect * rect, void *pixels,
   18.68 +                                    int pitch);
   18.69 +static int SDL_DIB_RenderWritePixels(SDL_Renderer * renderer,
   18.70 +                                     const SDL_Rect * rect,
   18.71 +                                     const void *pixels, int pitch);
   18.72 +static void SDL_DIB_RenderPresent(SDL_Renderer * renderer);
   18.73 +static void SDL_DIB_DestroyTexture(SDL_Renderer * renderer,
   18.74 +                                   SDL_Texture * texture);
   18.75 +static void SDL_DIB_DestroyRenderer(SDL_Renderer * renderer);
   18.76 +
   18.77 +
   18.78 +SDL_RenderDriver SDL_DIB_RenderDriver = {
   18.79 +    SDL_DIB_CreateRenderer,
   18.80 +    {
   18.81 +     "gdi",
   18.82 +     (SDL_Renderer_PresentDiscard |
   18.83 +      SDL_Renderer_PresentCopy | SDL_Renderer_RenderTarget),
   18.84 +     (SDL_TextureBlendMode_None |
   18.85 +      SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend),
   18.86 +     (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),
   18.87 +     11,
   18.88 +     {
   18.89 +      SDL_PixelFormat_Index8,
   18.90 +      SDL_PixelFormat_RGB555,
   18.91 +      SDL_PixelFormat_RGB565,
   18.92 +      SDL_PixelFormat_RGB888,
   18.93 +      SDL_PixelFormat_BGR888,
   18.94 +      SDL_PixelFormat_ARGB8888,
   18.95 +      SDL_PixelFormat_RGBA8888,
   18.96 +      SDL_PixelFormat_ABGR8888,
   18.97 +      SDL_PixelFormat_BGRA8888,
   18.98 +      SDL_PixelFormat_YUY2,
   18.99 +      SDL_PixelFormat_UYVY},
  18.100 +     0,
  18.101 +     0}
  18.102 +};
  18.103 +
  18.104 +typedef struct
  18.105 +{
  18.106 +    HWND hwnd;
  18.107 +    HDC window_hdc;
  18.108 +    HDC render_hdc;
  18.109 +    HDC memory_hdc;
  18.110 +    HDC current_hdc;
  18.111 +    LPBITMAPINFO bmi;
  18.112 +    HBITMAP window_bmp;
  18.113 +    void *window_pixels;
  18.114 +    int window_pitch;
  18.115 +} SDL_DIB_RenderData;
  18.116 +
  18.117 +typedef struct
  18.118 +{
  18.119 +    SDL_SW_YUVTexture *yuv;
  18.120 +    Uint32 format;
  18.121 +    HPALETTE hpal;
  18.122 +    HBITMAP hbm;
  18.123 +    void *pixels;
  18.124 +    int pitch;
  18.125 +} SDL_DIB_TextureData;
  18.126 +
  18.127 +static void
  18.128 +UpdateYUVTextureData(SDL_Texture * texture)
  18.129 +{
  18.130 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.131 +    SDL_Rect rect;
  18.132 +
  18.133 +    rect.x = 0;
  18.134 +    rect.y = 0;
  18.135 +    rect.w = texture->w;
  18.136 +    rect.h = texture->h;
  18.137 +    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
  18.138 +                        texture->h, data->pixels, data->pitch);
  18.139 +}
  18.140 +
  18.141 +SDL_Renderer *
  18.142 +SDL_DIB_CreateRenderer(SDL_Window * window, Uint32 flags)
  18.143 +{
  18.144 +    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
  18.145 +    SDL_Renderer *renderer;
  18.146 +    SDL_DIB_RenderData *data;
  18.147 +    int bmi_size;
  18.148 +    HBITMAP hbm;
  18.149 +
  18.150 +    renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
  18.151 +    if (!renderer) {
  18.152 +        SDL_OutOfMemory();
  18.153 +        return NULL;
  18.154 +    }
  18.155 +    SDL_zerop(renderer);
  18.156 +
  18.157 +    data = (SDL_DIB_RenderData *) SDL_malloc(sizeof(*data));
  18.158 +    if (!data) {
  18.159 +        SDL_DIB_DestroyRenderer(renderer);
  18.160 +        SDL_OutOfMemory();
  18.161 +        return NULL;
  18.162 +    }
  18.163 +    SDL_zerop(data);
  18.164 +
  18.165 +    data->hwnd = windowdata->hwnd;
  18.166 +    data->window_hdc = GetDC(data->hwnd);
  18.167 +    data->render_hdc = CreateCompatibleDC(data->window_hdc);
  18.168 +    data->memory_hdc = CreateCompatibleDC(data->window_hdc);
  18.169 +    data->current_hdc = data->window_hdc;
  18.170 +
  18.171 +    /* Fill in the compatible bitmap info */
  18.172 +    bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
  18.173 +    data->bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
  18.174 +    if (!data->bmi) {
  18.175 +        SDL_DIB_DestroyRenderer(renderer);
  18.176 +        SDL_OutOfMemory();
  18.177 +        return NULL;
  18.178 +    }
  18.179 +    SDL_memset(data->bmi, 0, bmi_size);
  18.180 +    data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  18.181 +
  18.182 +    hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1);
  18.183 +    GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
  18.184 +    GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
  18.185 +    DeleteObject(hbm);
  18.186 +
  18.187 +    renderer->CreateTexture = SDL_DIB_CreateTexture;
  18.188 +    renderer->QueryTexturePixels = SDL_DIB_QueryTexturePixels;
  18.189 +    renderer->SetTexturePalette = SDL_DIB_SetTexturePalette;
  18.190 +    renderer->GetTexturePalette = SDL_DIB_GetTexturePalette;
  18.191 +    renderer->UpdateTexture = SDL_DIB_UpdateTexture;
  18.192 +    renderer->LockTexture = SDL_DIB_LockTexture;
  18.193 +    renderer->UnlockTexture = SDL_DIB_UnlockTexture;
  18.194 +    renderer->DirtyTexture = SDL_DIB_DirtyTexture;
  18.195 +    renderer->SelectRenderTexture = SDL_DIB_SelectRenderTexture;
  18.196 +    renderer->RenderFill = SDL_DIB_RenderFill;
  18.197 +    renderer->RenderCopy = SDL_DIB_RenderCopy;
  18.198 +    renderer->RenderReadPixels = SDL_DIB_RenderReadPixels;
  18.199 +    renderer->RenderWritePixels = SDL_DIB_RenderWritePixels;
  18.200 +    renderer->RenderPresent = SDL_DIB_RenderPresent;
  18.201 +    renderer->DestroyTexture = SDL_DIB_DestroyTexture;
  18.202 +    renderer->DestroyRenderer = SDL_DIB_DestroyRenderer;
  18.203 +    renderer->info = SDL_DIB_RenderDriver.info;
  18.204 +    renderer->window = window->id;
  18.205 +    renderer->driverdata = data;
  18.206 +
  18.207 +    renderer->info.flags = SDL_Renderer_RenderTarget;
  18.208 +
  18.209 +    return renderer;
  18.210 +}
  18.211 +
  18.212 +static int
  18.213 +SDL_DIB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
  18.214 +{
  18.215 +    SDL_DIB_RenderData *renderdata =
  18.216 +        (SDL_DIB_RenderData *) renderer->driverdata;
  18.217 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  18.218 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  18.219 +    SDL_DIB_TextureData *data;
  18.220 +
  18.221 +    data = (SDL_DIB_TextureData *) SDL_malloc(sizeof(*data));
  18.222 +    if (!data) {
  18.223 +        SDL_OutOfMemory();
  18.224 +        return -1;
  18.225 +    }
  18.226 +    SDL_zerop(data);
  18.227 +
  18.228 +    texture->driverdata = data;
  18.229 +
  18.230 +    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
  18.231 +        if (texture->access == SDL_TextureAccess_Render) {
  18.232 +            SDL_SetError("Rendering to YUV format textures is not supported");
  18.233 +            return -1;
  18.234 +        }
  18.235 +        data->yuv = SDL_SW_CreateYUVTexture(texture);
  18.236 +        if (!data->yuv) {
  18.237 +            SDL_DIB_DestroyTexture(renderer, texture);
  18.238 +            return -1;
  18.239 +        }
  18.240 +        data->format = display->current_mode.format;
  18.241 +    } else {
  18.242 +        data->format = texture->format;
  18.243 +    }
  18.244 +    data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format));
  18.245 +
  18.246 +    if (data->yuv || texture->access == SDL_TextureAccess_Local
  18.247 +        || texture->format != SDL_GetCurrentDisplayMode()->format) {
  18.248 +        int bmi_size;
  18.249 +        LPBITMAPINFO bmi;
  18.250 +
  18.251 +        bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
  18.252 +        bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
  18.253 +        if (!bmi) {
  18.254 +            SDL_DIB_DestroyTexture(renderer, texture);
  18.255 +            SDL_OutOfMemory();
  18.256 +            return -1;
  18.257 +        }
  18.258 +        SDL_memset(bmi, 0, bmi_size);
  18.259 +        bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  18.260 +        bmi->bmiHeader.biWidth = texture->w;
  18.261 +        bmi->bmiHeader.biHeight = -texture->h;  /* topdown bitmap */
  18.262 +        bmi->bmiHeader.biPlanes = 1;
  18.263 +        bmi->bmiHeader.biSizeImage = texture->h * data->pitch;
  18.264 +        bmi->bmiHeader.biXPelsPerMeter = 0;
  18.265 +        bmi->bmiHeader.biYPelsPerMeter = 0;
  18.266 +        bmi->bmiHeader.biClrUsed = 0;
  18.267 +        bmi->bmiHeader.biClrImportant = 0;
  18.268 +        bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(data->format) * 8;
  18.269 +        if (SDL_ISPIXELFORMAT_INDEXED(data->format)) {
  18.270 +            int i, ncolors;
  18.271 +            LOGPALETTE *palette;
  18.272 +
  18.273 +            bmi->bmiHeader.biCompression = BI_RGB;
  18.274 +            ncolors = (1 << SDL_BITSPERPIXEL(data->format));
  18.275 +            palette =
  18.276 +                (LOGPALETTE *) SDL_malloc(sizeof(*palette) +
  18.277 +                                          ncolors * sizeof(PALETTEENTRY));
  18.278 +            if (!palette) {
  18.279 +                SDL_free(bmi);
  18.280 +                SDL_DIB_DestroyTexture(renderer, texture);
  18.281 +                SDL_OutOfMemory();
  18.282 +                return -1;
  18.283 +            }
  18.284 +            palette->palVersion = 0x300;
  18.285 +            palette->palNumEntries = ncolors;
  18.286 +            for (i = 0; i < ncolors; ++i) {
  18.287 +                palette->palPalEntry[i].peRed = 0xFF;
  18.288 +                palette->palPalEntry[i].peGreen = 0xFF;
  18.289 +                palette->palPalEntry[i].peBlue = 0xFF;
  18.290 +                palette->palPalEntry[i].peFlags = 0;
  18.291 +            }
  18.292 +            data->hpal = CreatePalette(palette);
  18.293 +            SDL_free(palette);
  18.294 +        } else {
  18.295 +            int bpp;
  18.296 +            Uint32 Rmask, Gmask, Bmask, Amask;
  18.297 +
  18.298 +            bmi->bmiHeader.biCompression = BI_BITFIELDS;
  18.299 +            SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask,
  18.300 +                                       &Bmask, &Amask);
  18.301 +            ((Uint32 *) bmi->bmiColors)[0] = Rmask;
  18.302 +            ((Uint32 *) bmi->bmiColors)[1] = Gmask;
  18.303 +            ((Uint32 *) bmi->bmiColors)[2] = Bmask;
  18.304 +            data->hpal = NULL;
  18.305 +        }
  18.306 +        data->hbm =
  18.307 +            CreateDIBSection(renderdata->memory_hdc, bmi, DIB_RGB_COLORS,
  18.308 +                             &data->pixels, NULL, 0);
  18.309 +    } else {
  18.310 +        data->hbm =
  18.311 +            CreateCompatibleBitmap(renderdata->window_hdc, texture->w,
  18.312 +                                   texture->h);
  18.313 +        data->pixels = NULL;
  18.314 +    }
  18.315 +    if (!data->hbm) {
  18.316 +        SDL_DIB_DestroyTexture(renderer, texture);
  18.317 +        WIN_SetError("Couldn't create bitmap");
  18.318 +        return -1;
  18.319 +    }
  18.320 +    return 0;
  18.321 +}
  18.322 +
  18.323 +static int
  18.324 +SDL_DIB_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
  18.325 +                           void **pixels, int *pitch)
  18.326 +{
  18.327 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.328 +
  18.329 +    if (data->yuv) {
  18.330 +        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
  18.331 +    } else {
  18.332 +        *pixels = data->pixels;
  18.333 +        *pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
  18.334 +        return 0;
  18.335 +    }
  18.336 +}
  18.337 +
  18.338 +static int
  18.339 +SDL_DIB_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
  18.340 +                          const SDL_Color * colors, int firstcolor,
  18.341 +                          int ncolors)
  18.342 +{
  18.343 +    SDL_DIB_RenderData *renderdata =
  18.344 +        (SDL_DIB_RenderData *) renderer->driverdata;
  18.345 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.346 +
  18.347 +    if (data->yuv) {
  18.348 +        SDL_SetError("YUV textures don't have a palette");
  18.349 +        return -1;
  18.350 +    } else {
  18.351 +        PALETTEENTRY entries[256];
  18.352 +        int i;
  18.353 +
  18.354 +        for (i = 0; i < ncolors; ++i) {
  18.355 +            entries[i].peRed = colors[i].r;
  18.356 +            entries[i].peGreen = colors[i].g;
  18.357 +            entries[i].peBlue = colors[i].b;
  18.358 +            entries[i].peFlags = 0;
  18.359 +        }
  18.360 +        if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
  18.361 +            WIN_SetError("SetPaletteEntries()");
  18.362 +            return -1;
  18.363 +        }
  18.364 +        return 0;
  18.365 +    }
  18.366 +}
  18.367 +
  18.368 +static int
  18.369 +SDL_DIB_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
  18.370 +                          SDL_Color * colors, int firstcolor, int ncolors)
  18.371 +{
  18.372 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.373 +
  18.374 +    if (data->yuv) {
  18.375 +        SDL_SetError("YUV textures don't have a palette");
  18.376 +        return -1;
  18.377 +    } else {
  18.378 +        PALETTEENTRY entries[256];
  18.379 +        int i;
  18.380 +
  18.381 +        if (!GetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
  18.382 +            WIN_SetError("GetPaletteEntries()");
  18.383 +            return -1;
  18.384 +        }
  18.385 +        for (i = 0; i < ncolors; ++i) {
  18.386 +            colors[i].r = entries[i].peRed;
  18.387 +            colors[i].g = entries[i].peGreen;
  18.388 +            colors[i].b = entries[i].peBlue;
  18.389 +        }
  18.390 +        return 0;
  18.391 +    }
  18.392 +}
  18.393 +
  18.394 +static int
  18.395 +SDL_DIB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
  18.396 +                      const SDL_Rect * rect, const void *pixels, int pitch)
  18.397 +{
  18.398 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.399 +
  18.400 +    if (data->yuv) {
  18.401 +        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
  18.402 +            return -1;
  18.403 +        }
  18.404 +        UpdateYUVTextureData(texture);
  18.405 +        return 0;
  18.406 +    } else {
  18.407 +        SDL_DIB_RenderData *renderdata =
  18.408 +            (SDL_DIB_RenderData *) renderer->driverdata;
  18.409 +
  18.410 +        if (data->pixels) {
  18.411 +            Uint8 *src, *dst;
  18.412 +            int row;
  18.413 +            size_t length;
  18.414 +
  18.415 +            src = (Uint8 *) pixels;
  18.416 +            dst =
  18.417 +                (Uint8 *) data->pixels + rect->y * data->pitch +
  18.418 +                rect->x * SDL_BYTESPERPIXEL(texture->format);
  18.419 +            length = rect->w * SDL_BYTESPERPIXEL(texture->format);
  18.420 +            for (row = 0; row < rect->h; ++row) {
  18.421 +                SDL_memcpy(dst, src, length);
  18.422 +                src += pitch;
  18.423 +                dst += data->pitch;
  18.424 +            }
  18.425 +        } else if (rect->w == texture->w && pitch == data->pitch) {
  18.426 +            if (!SetDIBits
  18.427 +                (renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels,
  18.428 +                 renderdata->bmi, DIB_RGB_COLORS)) {
  18.429 +                WIN_SetError("SetDIBits()");
  18.430 +                return -1;
  18.431 +            }
  18.432 +        } else {
  18.433 +            SDL_SetError
  18.434 +                ("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time");
  18.435 +            return -1;
  18.436 +        }
  18.437 +        return 0;
  18.438 +    }
  18.439 +}
  18.440 +
  18.441 +static int
  18.442 +SDL_DIB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
  18.443 +                    const SDL_Rect * rect, int markDirty, void **pixels,
  18.444 +                    int *pitch)
  18.445 +{
  18.446 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.447 +
  18.448 +    if (data->yuv) {
  18.449 +        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
  18.450 +                                     pitch);
  18.451 +    } else {
  18.452 +        GdiFlush();
  18.453 +        *pixels =
  18.454 +            (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
  18.455 +                      rect->x * SDL_BYTESPERPIXEL(texture->format));
  18.456 +        *pitch = data->pitch;
  18.457 +        return 0;
  18.458 +    }
  18.459 +}
  18.460 +
  18.461 +static void
  18.462 +SDL_DIB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
  18.463 +{
  18.464 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.465 +
  18.466 +    if (data->yuv) {
  18.467 +        SDL_SW_UnlockYUVTexture(data->yuv);
  18.468 +        UpdateYUVTextureData(texture);
  18.469 +    }
  18.470 +}
  18.471 +
  18.472 +static void
  18.473 +SDL_DIB_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
  18.474 +                     int numrects, const SDL_Rect * rects)
  18.475 +{
  18.476 +}
  18.477 +
  18.478 +static void
  18.479 +SDL_DIB_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
  18.480 +{
  18.481 +    SDL_DIB_RenderData *data = (SDL_DIB_RenderData *) renderer->driverdata;
  18.482 +
  18.483 +    if (texture) {
  18.484 +        SDL_DIB_TextureData *texturedata =
  18.485 +            (SDL_DIB_TextureData *) texture->driverdata;
  18.486 +        SelectObject(data->render_hdc, texturedata->hbm);
  18.487 +        if (texturedata->hpal) {
  18.488 +            SelectPalette(data->render_hdc, texturedata->hpal, TRUE);
  18.489 +            RealizePalette(data->render_hdc);
  18.490 +        }
  18.491 +        data->current_hdc = data->render_hdc;
  18.492 +    } else {
  18.493 +        data->current_hdc = data->current_hdc;
  18.494 +    }
  18.495 +}
  18.496 +
  18.497 +static int
  18.498 +SDL_DIB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
  18.499 +                   Uint32 color)
  18.500 +{
  18.501 +    SDL_DIB_RenderData *data = (SDL_DIB_RenderData *) renderer->driverdata;
  18.502 +    Uint8 r, g, b;
  18.503 +    RECT rc;
  18.504 +    static HBRUSH brush;
  18.505 +    int status;
  18.506 +
  18.507 +    r = (Uint8) ((color >> 16) & 0xFF);
  18.508 +    g = (Uint8) ((color >> 8) & 0xFF);
  18.509 +    b = (Uint8) (color & 0xFF);
  18.510 +
  18.511 +    rc.left = rect->x;
  18.512 +    rc.top = rect->y;
  18.513 +    rc.right = rect->x + rect->w + 1;
  18.514 +    rc.bottom = rect->y + rect->h + 1;
  18.515 +
  18.516 +    /* Should we cache the brushes? .. it looks like GDI does for us. :) */
  18.517 +    brush = CreateSolidBrush(RGB(r, g, b));
  18.518 +    SelectObject(data->current_hdc, brush);
  18.519 +    status = FillRect(data->current_hdc, &rc, brush);
  18.520 +    DeleteObject(brush);
  18.521 +
  18.522 +    if (!status) {
  18.523 +        WIN_SetError("FillRect()");
  18.524 +        return -1;
  18.525 +    }
  18.526 +    return 0;
  18.527 +}
  18.528 +
  18.529 +static int
  18.530 +SDL_DIB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  18.531 +                   const SDL_Rect * srcrect, const SDL_Rect * dstrect,
  18.532 +                   int blendMode, int scaleMode)
  18.533 +{
  18.534 +    SDL_DIB_RenderData *data = (SDL_DIB_RenderData *) renderer->driverdata;
  18.535 +    SDL_DIB_TextureData *texturedata =
  18.536 +        (SDL_DIB_TextureData *) texture->driverdata;
  18.537 +
  18.538 +    SelectObject(data->memory_hdc, texturedata->hbm);
  18.539 +    if (texturedata->hpal) {
  18.540 +        SelectPalette(data->memory_hdc, texturedata->hpal, TRUE);
  18.541 +        RealizePalette(data->memory_hdc);
  18.542 +    }
  18.543 +    if (blendMode & (SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend)) {
  18.544 +        static BLENDFUNCTION blendFunc = {
  18.545 +            AC_SRC_OVER,
  18.546 +            0,
  18.547 +            255,
  18.548 +            AC_SRC_ALPHA
  18.549 +        };
  18.550 +        /* FIXME: GDI uses premultiplied alpha! */
  18.551 +        if (!AlphaBlend
  18.552 +            (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
  18.553 +             dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, srcrect->w,
  18.554 +             srcrect->h, blendFunc)) {
  18.555 +            WIN_SetError("AlphaBlend()");
  18.556 +            return -1;
  18.557 +        }
  18.558 +    } else {
  18.559 +        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
  18.560 +            if (!BitBlt
  18.561 +                (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
  18.562 +                 srcrect->h, data->memory_hdc, srcrect->x, srcrect->y,
  18.563 +                 SRCCOPY)) {
  18.564 +                WIN_SetError("BitBlt()");
  18.565 +                return -1;
  18.566 +            }
  18.567 +        } else {
  18.568 +            if (!StretchBlt
  18.569 +                (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
  18.570 +                 srcrect->h, data->memory_hdc, srcrect->x, srcrect->y,
  18.571 +                 srcrect->w, srcrect->h, SRCCOPY)) {
  18.572 +                WIN_SetError("StretchBlt()");
  18.573 +                return -1;
  18.574 +            }
  18.575 +        }
  18.576 +    }
  18.577 +    return 0;
  18.578 +}
  18.579 +
  18.580 +static int
  18.581 +CreateWindowDIB(SDL_DIB_RenderData * data, SDL_Window * window)
  18.582 +{
  18.583 +    data->window_pitch = window->w * (data->bmi->bmiHeader.biBitCount / 8);
  18.584 +    data->bmi->bmiHeader.biWidth = window->w;
  18.585 +    data->bmi->bmiHeader.biHeight = -window->h;
  18.586 +    data->bmi->bmiHeader.biSizeImage =
  18.587 +        window->h * (data->bmi->bmiHeader.biBitCount / 8);
  18.588 +    data->window_bmp =
  18.589 +        CreateDIBSection(data->window_hdc, data->bmi, DIB_RGB_COLORS,
  18.590 +                         &data->window_pixels, NULL, 0);
  18.591 +    if (!data->window_bmp) {
  18.592 +        WIN_SetError("CreateDIBSection()");
  18.593 +        return -1;
  18.594 +    }
  18.595 +    return 0;
  18.596 +}
  18.597 +
  18.598 +static int
  18.599 +SDL_DIB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  18.600 +                         void *pixels, int pitch)
  18.601 +{
  18.602 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  18.603 +    SDL_DIB_RenderData *data = (SDL_DIB_RenderData *) renderer->driverdata;
  18.604 +
  18.605 +    if (!data->window_bmp) {
  18.606 +        if (CreateWindowDIB(data, window) < 0) {
  18.607 +            return -1;
  18.608 +        }
  18.609 +    }
  18.610 +
  18.611 +    SelectObject(data->memory_hdc, data->window_bmp);
  18.612 +    BitBlt(data->memory_hdc, rect->x, rect->y, rect->w, rect->h,
  18.613 +           data->window_hdc, rect->x, rect->y, SRCCOPY);
  18.614 +
  18.615 +    {
  18.616 +        int bpp = data->bmi->bmiHeader.biBitCount / 8;
  18.617 +        Uint8 *src =
  18.618 +            (Uint8 *) data->window_pixels + rect->y * data->window_pitch +
  18.619 +            rect->x * bpp;
  18.620 +        Uint8 *dst = (Uint8 *) pixels;
  18.621 +        int row;
  18.622 +
  18.623 +        for (row = 0; row < rect->h; ++row) {
  18.624 +            SDL_memcpy(dst, src, rect->w * bpp);
  18.625 +            src += data->window_pitch;
  18.626 +            dst += pitch;
  18.627 +        }
  18.628 +    }
  18.629 +
  18.630 +    return 0;
  18.631 +}
  18.632 +
  18.633 +static int
  18.634 +SDL_DIB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  18.635 +                          const void *pixels, int pitch)
  18.636 +{
  18.637 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  18.638 +    SDL_DIB_RenderData *data = (SDL_DIB_RenderData *) renderer->driverdata;
  18.639 +
  18.640 +    if (!data->window_bmp) {
  18.641 +        if (CreateWindowDIB(data, window) < 0) {
  18.642 +            return -1;
  18.643 +        }
  18.644 +    }
  18.645 +
  18.646 +    {
  18.647 +        int bpp = data->bmi->bmiHeader.biBitCount / 8;
  18.648 +        Uint8 *src = (Uint8 *) pixels;
  18.649 +        Uint8 *dst =
  18.650 +            (Uint8 *) data->window_pixels + rect->y * data->window_pitch +
  18.651 +            rect->x * bpp;
  18.652 +        int row;
  18.653 +
  18.654 +        for (row = 0; row < rect->h; ++row) {
  18.655 +            SDL_memcpy(dst, src, rect->w * bpp);
  18.656 +            src += pitch;
  18.657 +            dst += data->window_pitch;
  18.658 +        }
  18.659 +    }
  18.660 +
  18.661 +    SelectObject(data->memory_hdc, data->window_bmp);
  18.662 +    BitBlt(data->window_hdc, rect->x, rect->y, rect->w, rect->h,
  18.663 +           data->memory_hdc, rect->x, rect->y, SRCCOPY);
  18.664 +
  18.665 +    return 0;
  18.666 +}
  18.667 +
  18.668 +static void
  18.669 +SDL_DIB_RenderPresent(SDL_Renderer * renderer)
  18.670 +{
  18.671 +}
  18.672 +
  18.673 +static void
  18.674 +SDL_DIB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
  18.675 +{
  18.676 +    SDL_DIB_TextureData *data = (SDL_DIB_TextureData *) texture->driverdata;
  18.677 +
  18.678 +    if (!data) {
  18.679 +        return;
  18.680 +    }
  18.681 +    if (data->yuv) {
  18.682 +        SDL_SW_DestroyYUVTexture(data->yuv);
  18.683 +    }
  18.684 +    if (data->hpal) {
  18.685 +        DeleteObject(data->hpal);
  18.686 +    }
  18.687 +    if (data->hbm) {
  18.688 +        DeleteObject(data->hbm);
  18.689 +    }
  18.690 +    SDL_free(data);
  18.691 +    texture->driverdata = NULL;
  18.692 +}
  18.693 +
  18.694 +void
  18.695 +SDL_DIB_DestroyRenderer(SDL_Renderer * renderer)
  18.696 +{
  18.697 +    SDL_DIB_RenderData *data = (SDL_DIB_RenderData *) renderer->driverdata;
  18.698 +
  18.699 +    if (data) {
  18.700 +        ReleaseDC(data->hwnd, data->window_hdc);
  18.701 +        DeleteDC(data->render_hdc);
  18.702 +        DeleteDC(data->memory_hdc);
  18.703 +        if (data->bmi) {
  18.704 +            SDL_free(data->bmi);
  18.705 +        }
  18.706 +        if (data->window_bmp) {
  18.707 +            DeleteObject(data->window_bmp);
  18.708 +        }
  18.709 +        SDL_free(data);
  18.710 +    }
  18.711 +    SDL_free(renderer);
  18.712 +}
  18.713 +
  18.714 +/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/video/win32/SDL_dibrender.h	Thu Jul 06 07:17:11 2006 +0000
    19.3 @@ -0,0 +1,28 @@
    19.4 +/*
    19.5 +    SDL - Simple DirectMedia Layer
    19.6 +    Copyright (C) 1997-2006 Sam Lantinga
    19.7 +
    19.8 +    This library is free software; you can redistribute it and/or
    19.9 +    modify it under the terms of the GNU Lesser General Public
   19.10 +    License as published by the Free Software Foundation; either
   19.11 +    version 2.1 of the License, or (at your option) any later version.
   19.12 +
   19.13 +    This library is distributed in the hope that it will be useful,
   19.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.16 +    Lesser General Public License for more details.
   19.17 +
   19.18 +    You should have received a copy of the GNU Lesser General Public
   19.19 +    License along with this library; if not, write to the Free Software
   19.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   19.21 +
   19.22 +    Sam Lantinga
   19.23 +    slouken@libsdl.org
   19.24 +*/
   19.25 +#include "SDL_config.h"
   19.26 +
   19.27 +/* SDL surface based renderer implementation */
   19.28 +
   19.29 +extern SDL_RenderDriver SDL_DIB_RenderDriver;
   19.30 +
   19.31 +/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/win32/SDL_vkeys.h	Thu Jul 06 07:17:11 2006 +0000
    20.3 @@ -0,0 +1,76 @@
    20.4 +/*
    20.5 +    SDL - Simple DirectMedia Layer
    20.6 +    Copyright (C) 1997-2006 Sam Lantinga
    20.7 +
    20.8 +    This library is free software; you can redistribute it and/or
    20.9 +    modify it under the terms of the GNU Lesser General Public
   20.10 +    License as published by the Free Software Foundation; either
   20.11 +    version 2.1 of the License, or (at your option) any later version.
   20.12 +
   20.13 +    This library is distributed in the hope that it will be useful,
   20.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 +    Lesser General Public License for more details.
   20.17 +
   20.18 +    You should have received a copy of the GNU Lesser General Public
   20.19 +    License along with this library; if not, write to the Free Software
   20.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 +
   20.22 +    Sam Lantinga
   20.23 +    slouken@libsdl.org
   20.24 +*/
   20.25 +
   20.26 +#ifndef VK_0
   20.27 +#define VK_0	'0'
   20.28 +#define VK_1	'1'
   20.29 +#define VK_2	'2'
   20.30 +#define VK_3	'3'
   20.31 +#define VK_4	'4'
   20.32 +#define VK_5	'5'
   20.33 +#define VK_6	'6'
   20.34 +#define VK_7	'7'
   20.35 +#define VK_8	'8'
   20.36 +#define VK_9	'9'
   20.37 +#define VK_A	'A'
   20.38 +#define VK_B	'B'
   20.39 +#define VK_C	'C'
   20.40 +#define VK_D	'D'
   20.41 +#define VK_E	'E'
   20.42 +#define VK_F	'F'
   20.43 +#define VK_G	'G'
   20.44 +#define VK_H	'H'
   20.45 +#define VK_I	'I'
   20.46 +#define VK_J	'J'
   20.47 +#define VK_K	'K'
   20.48 +#define VK_L	'L'
   20.49 +#define VK_M	'M'
   20.50 +#define VK_N	'N'
   20.51 +#define VK_O	'O'
   20.52 +#define VK_P	'P'
   20.53 +#define VK_Q	'Q'
   20.54 +#define VK_R	'R'
   20.55 +#define VK_S	'S'
   20.56 +#define VK_T	'T'
   20.57 +#define VK_U	'U'
   20.58 +#define VK_V	'V'
   20.59 +#define VK_W	'W'
   20.60 +#define VK_X	'X'
   20.61 +#define VK_Y	'Y'
   20.62 +#define VK_Z	'Z'
   20.63 +#endif /* VK_0 */
   20.64 +
   20.65 +/* These keys haven't been defined, but were experimentally determined */
   20.66 +#define VK_SEMICOLON	0xBA
   20.67 +#define VK_EQUALS	0xBB
   20.68 +#define VK_COMMA	0xBC
   20.69 +#define VK_MINUS	0xBD
   20.70 +#define VK_PERIOD	0xBE
   20.71 +#define VK_SLASH	0xBF
   20.72 +#define VK_GRAVE	0xC0
   20.73 +#define VK_LBRACKET	0xDB
   20.74 +#define VK_BACKSLASH	0xDC
   20.75 +#define VK_RBRACKET	0xDD
   20.76 +#define VK_APOSTROPHE	0xDE
   20.77 +#define VK_BACKTICK	0xDF
   20.78 +#define VK_OEM_102	0xE2
   20.79 +/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/video/win32/SDL_win32events.c	Thu Jul 06 05:53:32 2006 +0000
    21.2 +++ b/src/video/win32/SDL_win32events.c	Thu Jul 06 07:17:11 2006 +0000
    21.3 @@ -22,8 +22,370 @@
    21.4  #include "SDL_config.h"
    21.5  
    21.6  #include "SDL_win32video.h"
    21.7 +#include "SDL_version.h"
    21.8 +#include "SDL_syswm.h"
    21.9 +#include "SDL_vkeys.h"
   21.10  #include "../../events/SDL_events_c.h"
   21.11  
   21.12 +/*#define WMMSG_DEBUG*/
   21.13 +#ifdef WMMSG_DEBUG
   21.14 +#include "wmmsg.h"
   21.15 +#endif
   21.16 +
   21.17 +/* Masks for processing the windows KEYDOWN and KEYUP messages */
   21.18 +#define REPEATED_KEYMASK	(1<<30)
   21.19 +#define EXTENDED_KEYMASK	(1<<24)
   21.20 +
   21.21 +
   21.22 +static SDLKey
   21.23 +TranslateKey(WPARAM vkey)
   21.24 +{
   21.25 +    SDLKey key;
   21.26 +
   21.27 +    /* FIXME: Assign vkey directly to key if in ASCII range */
   21.28 +    switch (vkey) {
   21.29 +    case VK_BACK:
   21.30 +        key = SDLK_BACKSPACE;
   21.31 +        break;
   21.32 +    case VK_TAB:
   21.33 +        key = SDLK_TAB;
   21.34 +        break;
   21.35 +    case VK_CLEAR:
   21.36 +        key = SDLK_CLEAR;
   21.37 +        break;
   21.38 +    case VK_RETURN:
   21.39 +        key = SDLK_RETURN;
   21.40 +        break;
   21.41 +    case VK_PAUSE:
   21.42 +        key = SDLK_PAUSE;
   21.43 +        break;
   21.44 +    case VK_ESCAPE:
   21.45 +        key = SDLK_ESCAPE;
   21.46 +        break;
   21.47 +    case VK_SPACE:
   21.48 +        key = SDLK_SPACE;
   21.49 +        break;
   21.50 +    case VK_APOSTROPHE:
   21.51 +        key = SDLK_QUOTE;
   21.52 +        break;
   21.53 +    case VK_COMMA:
   21.54 +        key = SDLK_COMMA;
   21.55 +        break;
   21.56 +    case VK_MINUS:
   21.57 +        key = SDLK_MINUS;
   21.58 +        break;
   21.59 +    case VK_PERIOD:
   21.60 +        key = SDLK_PERIOD;
   21.61 +        break;
   21.62 +    case VK_SLASH:
   21.63 +        key = SDLK_SLASH;
   21.64 +        break;
   21.65 +    case VK_0:
   21.66 +        key = SDLK_0;
   21.67 +        break;
   21.68 +    case VK_1:
   21.69 +        key = SDLK_1;
   21.70 +        break;
   21.71 +    case VK_2:
   21.72 +        key = SDLK_2;
   21.73 +        break;
   21.74 +    case VK_3:
   21.75 +        key = SDLK_3;
   21.76 +        break;
   21.77 +    case VK_4:
   21.78 +        key = SDLK_4;
   21.79 +        break;
   21.80 +    case VK_5:
   21.81 +        key = SDLK_5;
   21.82 +        break;
   21.83 +    case VK_6:
   21.84 +        key = SDLK_6;
   21.85 +        break;
   21.86 +    case VK_7:
   21.87 +        key = SDLK_7;
   21.88 +        break;
   21.89 +    case VK_8:
   21.90 +        key = SDLK_8;
   21.91 +        break;
   21.92 +    case VK_9:
   21.93 +        key = SDLK_9;
   21.94 +        break;
   21.95 +    case VK_SEMICOLON:
   21.96 +        key = SDLK_SEMICOLON;
   21.97 +        break;
   21.98 +    case VK_EQUALS:
   21.99 +        key = SDLK_EQUALS;
  21.100 +        break;
  21.101 +    case VK_LBRACKET:
  21.102 +        key = SDLK_LEFTBRACKET;
  21.103 +        break;
  21.104 +    case VK_BACKSLASH:
  21.105 +        key = SDLK_BACKSLASH;
  21.106 +        break;
  21.107 +    case VK_OEM_102:
  21.108 +        key = SDLK_LESS;
  21.109 +        break;
  21.110 +    case VK_RBRACKET:
  21.111 +        key = SDLK_RIGHTBRACKET;
  21.112 +        break;
  21.113 +    case VK_GRAVE:
  21.114 +        key = SDLK_BACKQUOTE;
  21.115 +        break;
  21.116 +    case VK_BACKTICK:
  21.117 +        key = SDLK_BACKQUOTE;
  21.118 +        break;
  21.119 +    case VK_A:
  21.120 +        key = SDLK_a;
  21.121 +        break;
  21.122 +    case VK_B:
  21.123 +        key = SDLK_b;
  21.124 +        break;
  21.125 +    case VK_C:
  21.126 +        key = SDLK_c;
  21.127 +        break;
  21.128 +    case VK_D:
  21.129 +        key = SDLK_d;
  21.130 +        break;
  21.131 +    case VK_E:
  21.132 +        key = SDLK_e;
  21.133 +        break;
  21.134 +    case VK_F:
  21.135 +        key = SDLK_f;
  21.136 +        break;
  21.137 +    case VK_G:
  21.138 +        key = SDLK_g;
  21.139 +        break;
  21.140 +    case VK_H:
  21.141 +        key = SDLK_h;
  21.142 +        break;
  21.143 +    case VK_I:
  21.144 +        key = SDLK_i;
  21.145 +        break;
  21.146 +    case VK_J:
  21.147 +        key = SDLK_j;
  21.148 +        break;
  21.149 +    case VK_K:
  21.150 +        key = SDLK_k;
  21.151 +        break;
  21.152 +    case VK_L:
  21.153 +        key = SDLK_l;
  21.154 +        break;
  21.155 +    case VK_M:
  21.156 +        key = SDLK_m;
  21.157 +        break;
  21.158 +    case VK_N:
  21.159 +        key = SDLK_n;
  21.160 +        break;
  21.161 +    case VK_O:
  21.162 +        key = SDLK_o;
  21.163 +        break;
  21.164 +    case VK_P:
  21.165 +        key = SDLK_p;
  21.166 +        break;
  21.167 +    case VK_Q:
  21.168 +        key = SDLK_q;
  21.169 +        break;
  21.170 +    case VK_R:
  21.171 +        key = SDLK_r;
  21.172 +        break;
  21.173 +    case VK_S:
  21.174 +        key = SDLK_s;
  21.175 +        break;
  21.176 +    case VK_T:
  21.177 +        key = SDLK_t;
  21.178 +        break;
  21.179 +    case VK_U:
  21.180 +        key = SDLK_u;
  21.181 +        break;
  21.182 +    case VK_V:
  21.183 +        key = SDLK_v;
  21.184 +        break;
  21.185 +    case VK_W:
  21.186 +        key = SDLK_w;
  21.187 +        break;
  21.188 +    case VK_X:
  21.189 +        key = SDLK_x;
  21.190 +        break;
  21.191 +    case VK_Y:
  21.192 +        key = SDLK_y;
  21.193 +        break;
  21.194 +    case VK_Z:
  21.195 +        key = SDLK_z;
  21.196 +        break;
  21.197 +    case VK_DELETE:
  21.198 +        key = SDLK_DELETE;
  21.199 +        break;
  21.200 +    case VK_NUMPAD0:
  21.201 +        key = SDLK_KP0;
  21.202 +        break;
  21.203 +    case VK_NUMPAD1:
  21.204 +        key = SDLK_KP1;
  21.205 +        break;
  21.206 +    case VK_NUMPAD2:
  21.207 +        key = SDLK_KP2;
  21.208 +        break;
  21.209 +    case VK_NUMPAD3:
  21.210 +        key = SDLK_KP3;
  21.211 +        break;
  21.212 +    case VK_NUMPAD4:
  21.213 +        key = SDLK_KP4;
  21.214 +        break;
  21.215 +    case VK_NUMPAD5:
  21.216 +        key = SDLK_KP5;
  21.217 +        break;
  21.218 +    case VK_NUMPAD6:
  21.219 +        key = SDLK_KP6;
  21.220 +        break;
  21.221 +    case VK_NUMPAD7:
  21.222 +        key = SDLK_KP7;
  21.223 +        break;
  21.224 +    case VK_NUMPAD8:
  21.225 +        key = SDLK_KP8;
  21.226 +        break;
  21.227 +    case VK_NUMPAD9:
  21.228 +        key = SDLK_KP9;
  21.229 +        break;
  21.230 +    case VK_DECIMAL:
  21.231 +        key = SDLK_KP_PERIOD;
  21.232 +        break;
  21.233 +    case VK_DIVIDE:
  21.234 +        key = SDLK_KP_DIVIDE;
  21.235 +        break;
  21.236 +    case VK_MULTIPLY:
  21.237 +        key = SDLK_KP_MULTIPLY;
  21.238 +        break;
  21.239 +    case VK_SUBTRACT:
  21.240 +        key = SDLK_KP_MINUS;
  21.241 +        break;
  21.242 +    case VK_ADD:
  21.243 +        key = SDLK_KP_PLUS;
  21.244 +        break;
  21.245 +    case VK_UP:
  21.246 +        key = SDLK_UP;
  21.247 +        break;
  21.248 +    case VK_DOWN:
  21.249 +        key = SDLK_DOWN;
  21.250 +        break;
  21.251 +    case VK_RIGHT:
  21.252 +        key = SDLK_RIGHT;
  21.253 +        break;
  21.254 +    case VK_LEFT:
  21.255 +        key = SDLK_LEFT;
  21.256 +        break;
  21.257 +    case VK_INSERT:
  21.258 +        key = SDLK_INSERT;
  21.259 +        break;
  21.260 +    case VK_HOME:
  21.261 +        key = SDLK_HOME;
  21.262 +        break;
  21.263 +    case VK_END:
  21.264 +        key = SDLK_END;
  21.265 +        break;
  21.266 +    case VK_PRIOR:
  21.267 +        key = SDLK_PAGEUP;
  21.268 +        break;
  21.269 +    case VK_NEXT:
  21.270 +        key = SDLK_PAGEDOWN;
  21.271 +        break;
  21.272 +    case VK_F1:
  21.273 +        key = SDLK_F1;
  21.274 +        break;
  21.275 +    case VK_F2:
  21.276 +        key = SDLK_F2;
  21.277 +        break;
  21.278 +    case VK_F3:
  21.279 +        key = SDLK_F3;
  21.280 +        break;
  21.281 +    case VK_F4:
  21.282 +        key = SDLK_F4;
  21.283 +        break;
  21.284 +    case VK_F5:
  21.285 +        key = SDLK_F5;
  21.286 +        break;
  21.287 +    case VK_F6:
  21.288 +        key = SDLK_F6;
  21.289 +        break;
  21.290 +    case VK_F7:
  21.291 +        key = SDLK_F7;
  21.292 +        break;
  21.293 +    case VK_F8:
  21.294 +        key = SDLK_F8;
  21.295 +        break;
  21.296 +    case VK_F9:
  21.297 +        key = SDLK_F9;
  21.298 +        break;
  21.299 +    case VK_F10:
  21.300 +        key = SDLK_F10;
  21.301 +        break;
  21.302 +    case VK_F11:
  21.303 +        key = SDLK_F11;
  21.304 +        break;
  21.305 +    case VK_F12:
  21.306 +        key = SDLK_F12;
  21.307 +        break;
  21.308 +    case VK_F13:
  21.309 +        key = SDLK_F13;
  21.310 +        break;
  21.311 +    case VK_F14:
  21.312 +        key = SDLK_F14;
  21.313 +        break;
  21.314 +    case VK_F15:
  21.315 +        key = SDLK_F15;
  21.316 +        break;
  21.317 +    case VK_NUMLOCK:
  21.318 +        key = SDLK_NUMLOCK;
  21.319 +        break;
  21.320 +    case VK_CAPITAL:
  21.321 +        key = SDLK_CAPSLOCK;
  21.322 +        break;
  21.323 +    case VK_SCROLL:
  21.324 +        key = SDLK_SCROLLOCK;
  21.325 +        break;
  21.326 +    case VK_RSHIFT:
  21.327 +        key = SDLK_RSHIFT;
  21.328 +        break;
  21.329 +    case VK_LSHIFT:
  21.330 +        key = SDLK_LSHIFT;
  21.331 +        break;
  21.332 +    case VK_RCONTROL:
  21.333 +        key = SDLK_RCTRL;
  21.334 +        break;
  21.335 +    case VK_LCONTROL:
  21.336 +        key = SDLK_LCTRL;
  21.337 +        break;
  21.338 +    case VK_RMENU:
  21.339 +        key = SDLK_RALT;
  21.340 +        break;
  21.341 +    case VK_LMENU:
  21.342 +        key = SDLK_LALT;
  21.343 +        break;
  21.344 +    case VK_RWIN:
  21.345 +        key = SDLK_RSUPER;
  21.346 +        break;
  21.347 +    case VK_LWIN:
  21.348 +        key = SDLK_LSUPER;
  21.349 +        break;
  21.350 +    case VK_HELP:
  21.351 +        key = SDLK_HELP;
  21.352 +        break;
  21.353 +    case VK_PRINT:
  21.354 +        key = SDLK_PRINT;
  21.355 +        break;
  21.356 +    case VK_SNAPSHOT:
  21.357 +        key = SDLK_PRINT;
  21.358 +        break;
  21.359 +    case VK_CANCEL:
  21.360 +        key = SDLK_BREAK;
  21.361 +        break;
  21.362 +    case VK_APPS:
  21.363 +        key = SDLK_MENU;
  21.364 +        break;
  21.365 +    default:
  21.366 +        key = SDLK_UNKNOWN;
  21.367 +        break;
  21.368 +    }
  21.369 +    return key;
  21.370 +}
  21.371  
  21.372  LRESULT CALLBACK
  21.373  WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  21.374 @@ -35,33 +397,60 @@
  21.375      if (!data) {
  21.376          return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
  21.377      }
  21.378 -#if 0
  21.379 +#ifdef WMMSG_DEBUG
  21.380 +    fprintf(stderr, "Received windows message:  ");
  21.381 +    if (msg > MAX_WMMSG) {
  21.382 +        fprintf(stderr, "%d", msg);
  21.383 +    } else {
  21.384 +        fprintf(stderr, "%s", wmtab[msg]);
  21.385 +    }
  21.386 +    fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam);
  21.387 +#endif
  21.388 +
  21.389 +    /* Send a SDL_SYSWMEVENT if the application wants them */
  21.390 +    if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
  21.391 +        SDL_SysWMmsg wmmsg;
  21.392 +
  21.393 +        SDL_VERSION(&wmmsg.version);
  21.394 +        wmmsg.hwnd = hwnd;
  21.395 +        wmmsg.msg = msg;
  21.396 +        wmmsg.wParam = wParam;
  21.397 +        wmmsg.lParam = lParam;
  21.398 +        SDL_SendSysWMEvent(&wmmsg);
  21.399 +    }
  21.400 +
  21.401      switch (msg) {
  21.402  
  21.403      case WM_ACTIVATE:
  21.404          {
  21.405 +            int index;
  21.406 +            SDL_Keyboard *keyboard;
  21.407              BOOL minimized;
  21.408  
  21.409              minimized = HIWORD(wParam);
  21.410 +            index = data->videodata->keyboard;
  21.411 +            keyboard = SDL_GetKeyboard(index);
  21.412              if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
  21.413 -                SDL_PrivateWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN,
  21.414 -                                       0, 0);
  21.415 -                SDL_PrivateWindowEvent(data->windowID,
  21.416 -                                       SDL_WINDOWEVENT_RESTORED, 0, 0);
  21.417 +                SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN,
  21.418 +                                    0, 0);
  21.419 +                SDL_SendWindowEvent(data->windowID,
  21.420 +                                    SDL_WINDOWEVENT_RESTORED, 0, 0);
  21.421                  if (IsZoomed(hwnd)) {
  21.422 -                    SDL_PrivateWindowEvent(data->windowID,
  21.423 -                                           SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
  21.424 +                    SDL_SendWindowEvent(data->windowID,
  21.425 +                                        SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
  21.426                  }
  21.427 -                SDL_PrivateWindowEvent(data->windowID,
  21.428 -                                       SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
  21.429 +                if (keyboard && keyboard->focus != data->windowID) {
  21.430 +                    SDL_SetKeyboardFocus(index, data->windowID);
  21.431 +                }
  21.432                  /* FIXME: Restore mode state (mode, gamma, grab) */
  21.433                  /* FIXME: Update keyboard state */
  21.434              } else {
  21.435 -                SDL_PrivateWindowEvent(data->windowID,
  21.436 -                                       SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
  21.437 +                if (keyboard && keyboard->focus == data->windowID) {
  21.438 +                    SDL_SetKeyboardFocus(index, 0);
  21.439 +                }
  21.440                  if (minimized) {
  21.441 -                    SDL_PrivateWindowEvent(data->windowID,
  21.442 -                                           SDL_WINDOWEVENT_MINIMIZED, 0, 0);
  21.443 +                    SDL_SendWindowEvent(data->windowID,
  21.444 +                                        SDL_WINDOWEVENT_MINIMIZED, 0, 0);
  21.445                  }
  21.446                  /* FIXME: Restore desktop state (mode, gamma, grab) */
  21.447              }
  21.448 @@ -73,11 +462,12 @@
  21.449          {
  21.450              int index;
  21.451              SDL_Mouse *mouse;
  21.452 +            int x, y;
  21.453  
  21.454 -            if (!
  21.455 -                (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_MOUSE_FOCUS))
  21.456 -            {
  21.457 -                /* mouse has entered the window */
  21.458 +            index = data->videodata->mouse;
  21.459 +            mouse = SDL_GetMouse(index);
  21.460 +
  21.461 +            if (mouse->focus != data->windowID) {
  21.462                  TRACKMOUSEEVENT tme;
  21.463  
  21.464                  tme.cbSize = sizeof(tme);
  21.465 @@ -85,41 +475,42 @@
  21.466                  tme.hwndTrack = hwnd;
  21.467                  TrackMouseEvent(&tme);
  21.468  
  21.469 -                SDL_PrivateWindowEvent(data->windowID, SDL_WINDOWEVENT_ENTER,
  21.470 -                                       0, 0);
  21.471 +                SDL_SetMouseFocus(index, data->windowID);
  21.472              }
  21.473  
  21.474 -            index = data->videodata->mouse;
  21.475 -            mouse = SDL_GetMouse(index);
  21.476 -            if (mouse) {
  21.477 -                int x, y;
  21.478 -                /* mouse has moved within the window */
  21.479 -                x = LOWORD(lParam);
  21.480 -                y = HIWORD(lParam);
  21.481 -                if (mouse->relative_mode) {
  21.482 -                    int w, h;
  21.483 -                    POINT center;
  21.484 -                    SDL_GetWindowSize(data->windowID, &w, &h);
  21.485 -                    center.x = (w / 2);
  21.486 -                    center.y = (h / 2);
  21.487 -                    x -= center.x;
  21.488 -                    y -= center.y;
  21.489 -                    if (x || y) {
  21.490 -                        ClientToScreen(SDL_Window, &center);
  21.491 -                        SetCursorPos(center.x, center.y);
  21.492 -                        SDL_SendMouseMotion(index, data->windowID, 1, x, y);
  21.493 -                    }
  21.494 -                } else {
  21.495 -                    SDL_SendMouseMotion(index, data->windowID, 0, x, y);
  21.496 +            /* mouse has moved within the window */
  21.497 +            x = LOWORD(lParam);
  21.498 +            y = HIWORD(lParam);
  21.499 +            if (mouse->relative_mode) {
  21.500 +                int w, h;
  21.501 +                POINT center;
  21.502 +                SDL_GetWindowSize(data->windowID, &w, &h);
  21.503 +                center.x = (w / 2);
  21.504 +                center.y = (h / 2);
  21.505 +                x -= center.x;
  21.506 +                y -= center.y;
  21.507 +                if (x || y) {
  21.508 +                    ClientToScreen(hwnd, &center);
  21.509 +                    SetCursorPos(center.x, center.y);
  21.510 +                    SDL_SendMouseMotion(index, 1, x, y);
  21.511                  }
  21.512 +            } else {
  21.513 +                SDL_SendMouseMotion(index, 0, x, y);
  21.514              }
  21.515          }
  21.516          return (0);
  21.517  
  21.518      case WM_MOUSELEAVE:
  21.519          {
  21.520 -            SDL_PrivateWindowEvent(data->windowID, SDL_WINDOWEVENT_LEAVE, 0,
  21.521 -                                   0);
  21.522 +            int index;
  21.523 +            SDL_Mouse *mouse;
  21.524 +
  21.525 +            index = data->videodata->mouse;
  21.526 +            mouse = SDL_GetMouse(index);
  21.527 +
  21.528 +            if (mouse->focus == data->windowID) {
  21.529 +                SDL_SetMouseFocus(index, 0);
  21.530 +            }
  21.531          }
  21.532          return (0);
  21.533  
  21.534 @@ -130,7 +521,8 @@
  21.535      case WM_RBUTTONDOWN:
  21.536      case WM_RBUTTONUP:
  21.537          {
  21.538 -            int x, y;
  21.539 +            int index;
  21.540 +            SDL_Mouse *mouse;
  21.541              Uint8 button, state;
  21.542  
  21.543              /* DJM:
  21.544 @@ -138,7 +530,10 @@
  21.545                 it acts like a normal windows "component"
  21.546                 (e.g. gains keyboard focus on a mouse click).
  21.547               */
  21.548 -            SetFocus(SDL_Window);
  21.549 +            SetFocus(hwnd);
  21.550 +
  21.551 +            index = data->videodata->mouse;
  21.552 +            mouse = SDL_GetMouse(index);
  21.553  
  21.554              /* Figure out which button to use */
  21.555              switch (msg) {
  21.556 @@ -172,85 +567,155 @@
  21.557              }
  21.558              if (state == SDL_PRESSED) {
  21.559                  /* Grab mouse so we get up events */
  21.560 -                if (++mouse_pressed > 0) {
  21.561 +                if (++data->mouse_pressed > 0) {
  21.562                      SetCapture(hwnd);
  21.563                  }
  21.564              } else {
  21.565                  /* Release mouse after all up events */
  21.566 -                if (--mouse_pressed <= 0) {
  21.567 +                if (--data->mouse_pressed <= 0) {
  21.568                      ReleaseCapture();
  21.569 -                    mouse_pressed = 0;
  21.570 +                    data->mouse_pressed = 0;
  21.571                  }
  21.572              }
  21.573 -            x = LOWORD(lParam);
  21.574 -            y = HIWORD(lParam);
  21.575 -#ifdef _WIN32_WCE
  21.576 -            if (SDL_VideoSurface)
  21.577 -                GapiTransform(this->hidden->userOrientation,
  21.578 -                              this->hidden->hiresFix, &x, &y);
  21.579 -#endif
  21.580 -            posted = SDL_PrivateMouseButton(state, button, x, y);
  21.581 +
  21.582 +            if (!mouse->relative_mode) {
  21.583 +                int x, y;
  21.584 +                x = LOWORD(lParam);
  21.585 +                y = HIWORD(lParam);
  21.586 +                SDL_SendMouseMotion(index, 0, x, y);
  21.587 +            }
  21.588 +            SDL_SendMouseButton(index, state, button);
  21.589          }
  21.590 -
  21.591          return (0);
  21.592  
  21.593 +    case WM_MOUSEWHEEL:
  21.594 +        {
  21.595 +            int index;
  21.596 +            int motion = (short) HIWORD(wParam);
  21.597  
  21.598 -#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
  21.599 -    case WM_MOUSEWHEEL:
  21.600 -        if (SDL_VideoSurface && !DINPUT_FULLSCREEN()) {
  21.601 -            int move = (short) HIWORD(wParam);
  21.602 -            if (move) {
  21.603 -                Uint8 button;
  21.604 -                if (move > 0)
  21.605 -                    button = SDL_BUTTON_WHEELUP;
  21.606 -                else
  21.607 -                    button = SDL_BUTTON_WHEELDOWN;
  21.608 -                posted = SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0);
  21.609 -                posted |= SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0);
  21.610 -            }
  21.611 +            index = data->videodata->mouse;
  21.612 +            SDL_SendMouseWheel(index, motion);
  21.613          }
  21.614          return (0);
  21.615 -#endif
  21.616  
  21.617 -#ifdef WM_GETMINMAXINFO
  21.618 -        /* This message is sent as a way for us to "check" the values
  21.619 -         * of a position change.  If we don't like it, we can adjust
  21.620 -         * the values before they are changed.
  21.621 -         */
  21.622 +    case WM_SYSKEYDOWN:
  21.623 +    case WM_KEYDOWN:
  21.624 +        {
  21.625 +            int index;
  21.626 +
  21.627 +            /* Ignore repeated keys */
  21.628 +            if (lParam & REPEATED_KEYMASK) {
  21.629 +                return (0);
  21.630 +            }
  21.631 +
  21.632 +            index = data->videodata->keyboard;
  21.633 +            switch (wParam) {
  21.634 +            case VK_CONTROL:
  21.635 +                if (lParam & EXTENDED_KEYMASK)
  21.636 +                    wParam = VK_RCONTROL;
  21.637 +                else
  21.638 +                    wParam = VK_LCONTROL;
  21.639 +                break;
  21.640 +            case VK_SHIFT:
  21.641 +                /* EXTENDED trick doesn't work here */
  21.642 +                {
  21.643 +                    Uint8 *state = SDL_GetKeyState(NULL);
  21.644 +                    if (state[SDLK_LSHIFT] == SDL_RELEASED
  21.645 +                        && (GetKeyState(VK_LSHIFT) & 0x8000)) {
  21.646 +                        wParam = VK_LSHIFT;
  21.647 +                    } else if (state[SDLK_RSHIFT] == SDL_RELEASED
  21.648 +                               && (GetKeyState(VK_RSHIFT) & 0x8000)) {
  21.649 +                        wParam = VK_RSHIFT;
  21.650 +                    } else {
  21.651 +                        /* Probably a key repeat */
  21.652 +                        return (0);
  21.653 +                    }
  21.654 +                }
  21.655 +                break;
  21.656 +            case VK_MENU:
  21.657 +                if (lParam & EXTENDED_KEYMASK)
  21.658 +                    wParam = VK_RMENU;
  21.659 +                else
  21.660 +                    wParam = VK_LMENU;
  21.661 +                break;
  21.662 +            }
  21.663 +            SDL_SendKeyboardKey(index, SDL_PRESSED, (Uint8) HIWORD(lParam),
  21.664 +                                TranslateKey(wParam));
  21.665 +        }
  21.666 +        return (0);
  21.667 +
  21.668 +    case WM_SYSKEYUP:
  21.669 +    case WM_KEYUP:
  21.670 +        {
  21.671 +            int index;
  21.672 +
  21.673 +            index = data->videodata->keyboard;
  21.674 +            switch (wParam) {
  21.675 +            case VK_CONTROL:
  21.676 +                if (lParam & EXTENDED_KEYMASK)
  21.677 +                    wParam = VK_RCONTROL;
  21.678 +                else
  21.679 +                    wParam = VK_LCONTROL;
  21.680 +                break;
  21.681 +            case VK_SHIFT:
  21.682 +                /* EXTENDED trick doesn't work here */
  21.683 +                {
  21.684 +                    Uint8 *state = SDL_GetKeyState(NULL);
  21.685 +                    if (state[SDLK_LSHIFT] == SDL_PRESSED
  21.686 +                        && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
  21.687 +                        wParam = VK_LSHIFT;
  21.688 +                    } else if (state[SDLK_RSHIFT] == SDL_PRESSED
  21.689 +                               && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
  21.690 +                        wParam = VK_RSHIFT;
  21.691 +                    } else {
  21.692 +                        /* Probably a key repeat */
  21.693 +                        return (0);
  21.694 +                    }
  21.695 +                }
  21.696 +                break;
  21.697 +            case VK_MENU:
  21.698 +                if (lParam & EXTENDED_KEYMASK)
  21.699 +                    wParam = VK_RMENU;
  21.700 +                else
  21.701 +                    wParam = VK_LMENU;
  21.702 +                break;
  21.703 +            }
  21.704 +            /* Windows only reports keyup for print screen */
  21.705 +            if (wParam == VK_SNAPSHOT
  21.706 +                && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED) {
  21.707 +                SDL_SendKeyboardKey(index, SDL_PRESSED,
  21.708 +                                    (Uint8) HIWORD(lParam),
  21.709 +                                    TranslateKey(wParam));
  21.710 +            }
  21.711 +            SDL_SendKeyboardKey(index, SDL_RELEASED, (Uint8) HIWORD(lParam),
  21.712 +                                TranslateKey(wParam));
  21.713 +        }
  21.714 +        return (0);
  21.715 +
  21.716      case WM_GETMINMAXINFO:
  21.717          {
  21.718              MINMAXINFO *info;
  21.719              RECT size;
  21.720              int x, y;
  21.721 +            int w, h;
  21.722              int style;
  21.723 -            int width;
  21.724 -            int height;
  21.725  
  21.726 -            /* We don't want to clobber an internal resize */
  21.727 -            if (SDL_resizing)
  21.728 -                return (0);
  21.729 -
  21.730 -            /* We allow resizing with the SDL_RESIZABLE flag */
  21.731 -            if (SDL_PublicSurface
  21.732 -                && (SDL_PublicSurface->flags & SDL_RESIZABLE)) {
  21.733 +            /* If we allow resizing, let the resize happen naturally */
  21.734 +            if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_RESIZABLE) {
  21.735                  return (0);
  21.736              }
  21.737  
  21.738              /* Get the current position of our window */
  21.739 -            GetWindowRect(SDL_Window, &size);
  21.740 +            GetWindowRect(hwnd, &size);
  21.741              x = size.left;
  21.742              y = size.top;
  21.743  
  21.744 -            /* Calculate current width and height of our window */
  21.745 +            /* Calculate current size of our window */
  21.746 +            SDL_GetWindowSize(data->windowID, &w, &h);
  21.747              size.top = 0;
  21.748              size.left = 0;
  21.749 -            if (SDL_PublicSurface != NULL) {
  21.750 -                size.bottom = SDL_PublicSurface->h;
  21.751 -                size.right = SDL_PublicSurface->w;
  21.752 -            } else {
  21.753 -                size.bottom = 0;
  21.754 -                size.right = 0;
  21.755 -            }
  21.756 +            size.bottom = h;
  21.757 +            size.right = w;
  21.758  
  21.759              /* DJM - according to the docs for GetMenu(), the
  21.760                 return value is undefined if hwnd is a child window.
  21.761 @@ -263,122 +728,111 @@
  21.762                               style & WS_CHILDWINDOW ? FALSE : GetMenu(hwnd) !=
  21.763                               NULL);
  21.764  
  21.765 -            width = size.right - size.left;
  21.766 -            height = size.bottom - size.top;
  21.767 +            w = size.right - size.left;
  21.768 +            h = size.bottom - size.top;
  21.769  
  21.770              /* Fix our size to the current size */
  21.771              info = (MINMAXINFO *) lParam;
  21.772 -            info->ptMaxSize.x = width;
  21.773 -            info->ptMaxSize.y = height;
  21.774 +            info->ptMaxSize.x = w;
  21.775 +            info->ptMaxSize.y = h;
  21.776              info->ptMaxPosition.x = x;
  21.777              info->ptMaxPosition.y = y;
  21.778 -            info->ptMinTrackSize.x = width;
  21.779 -            info->ptMinTrackSize.y = height;
  21.780 -            info->ptMaxTrackSize.x = width;
  21.781 -            info->ptMaxTrackSize.y = height;
  21.782 +            info->ptMinTrackSize.x = w;
  21.783 +            info->ptMinTrackSize.y = h;
  21.784 +            info->ptMaxTrackSize.x = w;
  21.785 +            info->ptMaxTrackSize.y = h;
  21.786          }
  21.787 -
  21.788          return (0);
  21.789 -#endif /* WM_GETMINMAXINFO */
  21.790  
  21.791      case WM_WINDOWPOSCHANGED:
  21.792          {
  21.793 -            SDL_VideoDevice *this = current_video;
  21.794 +            RECT rect;
  21.795 +            int x, y;
  21.796              int w, h;
  21.797  
  21.798 -            GetClientRect(SDL_Window, &SDL_bounds);
  21.799 -            ClientToScreen(SDL_Window, (LPPOINT) & SDL_bounds);
  21.800 -            ClientToScreen(SDL_Window, (LPPOINT) & SDL_bounds + 1);
  21.801 -            if (!SDL_resizing && !IsZoomed(SDL_Window) &&
  21.802 -                SDL_PublicSurface
  21.803 -                && !(SDL_PublicSurface->flags & SDL_FULLSCREEN)) {
  21.804 -                SDL_windowX = SDL_bounds.left;
  21.805 -                SDL_windowY = SDL_bounds.top;
  21.806 +            GetClientRect(hwnd, &rect);
  21.807 +            ClientToScreen(hwnd, (LPPOINT) & rect);
  21.808 +            ClientToScreen(hwnd, (LPPOINT) & rect + 1);
  21.809 +
  21.810 +            if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_INPUT_GRABBED) {
  21.811 +                ClipCursor(&rect);
  21.812              }
  21.813 -            w = SDL_bounds.right - SDL_bounds.left;
  21.814 -            h = SDL_bounds.bottom - SDL_bounds.top;
  21.815 -            if (this->input_grab != SDL_GRAB_OFF) {
  21.816 -                ClipCursor(&SDL_bounds);
  21.817 -            }
  21.818 -            if (SDL_PublicSurface
  21.819 -                && (SDL_PublicSurface->flags & SDL_RESIZABLE)) {
  21.820 -                SDL_PrivateResize(w, h);
  21.821 -            }
  21.822 +
  21.823 +            x = rect.left;
  21.824 +            y = rect.top;
  21.825 +            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, x, y);
  21.826 +
  21.827 +            w = rect.right - rect.left;
  21.828 +            h = rect.bottom - rect.top;
  21.829 +            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, w,
  21.830 +                                h);
  21.831          }
  21.832 -
  21.833          break;
  21.834  
  21.835 -        /* We need to set the cursor */
  21.836      case WM_SETCURSOR:
  21.837          {
  21.838 -            Uint16 hittest;
  21.839 +            /*
  21.840 +               Uint16 hittest;
  21.841  
  21.842 -            hittest = LOWORD(lParam);
  21.843 -            if (hittest == HTCLIENT) {
  21.844 -                SetCursor(SDL_hcursor);
  21.845 -                return (TRUE);
  21.846 -            }
  21.847 +               hittest = LOWORD(lParam);
  21.848 +               if (hittest == HTCLIENT) {
  21.849 +               SetCursor(SDL_hcursor);
  21.850 +               return (TRUE);
  21.851 +               }
  21.852 +             */
  21.853          }
  21.854 -
  21.855          break;
  21.856  
  21.857          /* We are about to get palette focus! */
  21.858      case WM_QUERYNEWPALETTE:
  21.859          {
  21.860 -            WIN_RealizePalette(current_video);
  21.861 -            return (TRUE);
  21.862 +            /*
  21.863 +               WIN_RealizePalette(current_video);
  21.864 +               return (TRUE);
  21.865 +             */
  21.866          }
  21.867 -
  21.868          break;
  21.869  
  21.870          /* Another application changed the palette */
  21.871      case WM_PALETTECHANGED:
  21.872          {
  21.873 -            WIN_PaletteChanged(current_video, (HWND) wParam);
  21.874 +            /*
  21.875 +               WIN_PaletteChanged(current_video, (HWND) wParam);
  21.876 +             */
  21.877          }
  21.878 -
  21.879          break;
  21.880  
  21.881          /* We were occluded, refresh our display */
  21.882      case WM_PAINT:
  21.883          {
  21.884 -            HDC hdc;
  21.885 -            PAINTSTRUCT ps;
  21.886 -
  21.887 -            hdc = BeginPaint(SDL_Window, &ps);
  21.888 -            if (current_video->screen &&
  21.889 -                !(current_video->screen->flags & SDL_INTERNALOPENGL)) {
  21.890 -                WIN_WinPAINT(current_video, hdc);
  21.891 +            RECT rect;
  21.892 +            if (GetUpdateRect(hwnd, &rect, FALSE)) {
  21.893 +                ValidateRect(hwnd, &rect);
  21.894 +                SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED,
  21.895 +                                    0, 0);
  21.896              }
  21.897 -            EndPaint(SDL_Window, &ps);
  21.898          }
  21.899 -
  21.900          return (0);
  21.901  
  21.902 -        /* DJM: Send an expose event in this case */
  21.903 -    case WM_ERASEBKGND:
  21.904 +    case WM_SYSCOMMAND:
  21.905          {
  21.906 -            posted = SDL_PrivateExpose();
  21.907 +            /* Don't start the screensaver or blank the monitor in fullscreen apps */
  21.908 +            if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
  21.909 +                (wParam & 0xFFF0) == SC_MONITORPOWER) {
  21.910 +                if (SDL_GetWindowFlags(data->windowID) &
  21.911 +                    SDL_WINDOW_FULLSCREEN) {
  21.912 +                    return (0);
  21.913 +                }
  21.914 +            }
  21.915          }
  21.916 -
  21.917 -        return (0);
  21.918 +        break;
  21.919  
  21.920      case WM_CLOSE:
  21.921          {
  21.922 -            if ((posted = SDL_PrivateQuit()))
  21.923 -                PostQuitMessage(0);
  21.924 +            SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0);
  21.925          }
  21.926 -
  21.927 -        return (0);
  21.928 -
  21.929 -    case WM_DESTROY:
  21.930 -        {
  21.931 -            PostQuitMessage(0);
  21.932 -        }
  21.933 -
  21.934          return (0);
  21.935      }
  21.936 -#endif
  21.937      return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam);
  21.938  }
  21.939  
    22.1 --- a/src/video/win32/SDL_win32keyboard.c	Thu Jul 06 05:53:32 2006 +0000
    22.2 +++ b/src/video/win32/SDL_win32keyboard.c	Thu Jul 06 07:17:11 2006 +0000
    22.3 @@ -35,4 +35,12 @@
    22.4      data->keyboard = SDL_AddKeyboard(&keyboard, -1);
    22.5  }
    22.6  
    22.7 +void
    22.8 +WIN_DelKeyboard(_THIS)
    22.9 +{
   22.10 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   22.11 +
   22.12 +    SDL_DelKeyboard(data->keyboard);
   22.13 +}
   22.14 +
   22.15  /* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/video/win32/SDL_win32keyboard.h	Thu Jul 06 05:53:32 2006 +0000
    23.2 +++ b/src/video/win32/SDL_win32keyboard.h	Thu Jul 06 07:17:11 2006 +0000
    23.3 @@ -25,6 +25,7 @@
    23.4  #define _SDL_win32keyboard_h
    23.5  
    23.6  extern void WIN_AddKeyboard(_THIS);
    23.7 +extern void WIN_DelKeyboard(_THIS);
    23.8  
    23.9  #endif /* _SDL_win32keyboard_h */
   23.10  
    24.1 --- a/src/video/win32/SDL_win32mouse.c	Thu Jul 06 05:53:32 2006 +0000
    24.2 +++ b/src/video/win32/SDL_win32mouse.c	Thu Jul 06 07:17:11 2006 +0000
    24.3 @@ -35,4 +35,12 @@
    24.4      data->mouse = SDL_AddMouse(&mouse, -1);
    24.5  }
    24.6  
    24.7 +void
    24.8 +WIN_DelMouse(_THIS)
    24.9 +{
   24.10 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   24.11 +
   24.12 +    SDL_DelMouse(data->mouse);
   24.13 +}
   24.14 +
   24.15  /* vi: set ts=4 sw=4 expandtab: */
    25.1 --- a/src/video/win32/SDL_win32mouse.h	Thu Jul 06 05:53:32 2006 +0000
    25.2 +++ b/src/video/win32/SDL_win32mouse.h	Thu Jul 06 07:17:11 2006 +0000
    25.3 @@ -25,6 +25,7 @@
    25.4  #define _SDL_win32mouse_h
    25.5  
    25.6  extern void WIN_AddMouse(_THIS);
    25.7 +extern void WIN_DelMouse(_THIS);
    25.8  
    25.9  #endif /* _SDL_win32mouse_h */
   25.10  
    26.1 --- a/src/video/win32/SDL_win32video.c	Thu Jul 06 05:53:32 2006 +0000
    26.2 +++ b/src/video/win32/SDL_win32video.c	Thu Jul 06 07:17:11 2006 +0000
    26.3 @@ -28,8 +28,7 @@
    26.4  #include "../SDL_pixels_c.h"
    26.5  
    26.6  #include "SDL_win32video.h"
    26.7 -#include "SDL_win32events.h"
    26.8 -#include "SDL_win32window.h"
    26.9 +#include "SDL_dibrender.h"
   26.10  
   26.11  /* Initialization/Query functions */
   26.12  static int WIN_VideoInit(_THIS);
   26.13 @@ -109,10 +108,51 @@
   26.14  int
   26.15  WIN_VideoInit(_THIS)
   26.16  {
   26.17 +    int bmi_size;
   26.18 +    LPBITMAPINFO bmi;
   26.19      SDL_DisplayMode mode;
   26.20  
   26.21 -    SDL_AddBasicVideoDisplay(NULL);
   26.22 -    //SDL_AddRenderDriver(0, &SDL_WIN_RenderDriver);
   26.23 +    /* Find out the desktop mode */
   26.24 +    mode.format = SDL_PixelFormat_Unknown;
   26.25 +    mode.w = GetSystemMetrics(SM_CXSCREEN);
   26.26 +    mode.h = GetSystemMetrics(SM_CYSCREEN);
   26.27 +    mode.refresh_rate = 0;
   26.28 +
   26.29 +    bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
   26.30 +    bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
   26.31 +    if (bmi) {
   26.32 +        HDC hdc;
   26.33 +        HBITMAP hbm;
   26.34 +
   26.35 +        SDL_memset(bmi, 0, bmi_size);
   26.36 +        bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
   26.37 +        hdc = GetDC(NULL);
   26.38 +        hbm = CreateCompatibleBitmap(hdc, 1, 1);
   26.39 +        GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
   26.40 +        GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
   26.41 +        DeleteObject(hbm);
   26.42 +        ReleaseDC(NULL, hdc);
   26.43 +        if (bmi->bmiHeader.biCompression == BI_BITFIELDS) {
   26.44 +            switch (*(Uint32 *) bmi->bmiColors) {
   26.45 +            case 0x00FF0000:
   26.46 +                mode.format = SDL_PixelFormat_RGB888;
   26.47 +                break;
   26.48 +            case 0x000000FF:
   26.49 +                mode.format = SDL_PixelFormat_BGR888;
   26.50 +                break;
   26.51 +            case 0xF800:
   26.52 +                mode.format = SDL_PixelFormat_RGB565;
   26.53 +                break;
   26.54 +            case 0x7C00:
   26.55 +                mode.format = SDL_PixelFormat_RGB555;
   26.56 +                break;
   26.57 +            }
   26.58 +        } else if (bmi->bmiHeader.biBitCount == 8) {
   26.59 +            mode.format = SDL_PixelFormat_Index8;
   26.60 +        }
   26.61 +    }
   26.62 +    SDL_AddBasicVideoDisplay(&mode);
   26.63 +    SDL_AddRenderDriver(0, &SDL_DIB_RenderDriver);
   26.64  
   26.65      SDL_zero(mode);
   26.66      SDL_AddDisplayMode(0, &mode);
   26.67 @@ -134,6 +174,8 @@
   26.68  void
   26.69  WIN_VideoQuit(_THIS)
   26.70  {
   26.71 +    WIN_DelKeyboard(_this);
   26.72 +    WIN_DelMouse(_this);
   26.73  }
   26.74  
   26.75  /* vim: set ts=4 sw=4 expandtab: */
    27.1 --- a/src/video/win32/SDL_win32video.h	Thu Jul 06 05:53:32 2006 +0000
    27.2 +++ b/src/video/win32/SDL_win32video.h	Thu Jul 06 07:17:11 2006 +0000
    27.3 @@ -28,6 +28,7 @@
    27.4  
    27.5  #define WIN32_LEAN_AND_MEAN
    27.6  #define UNICODE
    27.7 +#define WINVER  0x0410          // 0x0410 needed for AlphaBlend()
    27.8  #include <windows.h>
    27.9  
   27.10  #include "SDL_win32events.h"
    28.1 --- a/src/video/win32/SDL_win32window.c	Thu Jul 06 05:53:32 2006 +0000
    28.2 +++ b/src/video/win32/SDL_win32window.c	Thu Jul 06 07:17:11 2006 +0000
    28.3 @@ -43,6 +43,7 @@
    28.4      data->windowID = window->id;
    28.5      data->hwnd = hwnd;
    28.6      data->created = created;
    28.7 +    data->mouse_pressed = SDL_FALSE;
    28.8      data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
    28.9  
   28.10      /* Associate the data with the window */
   28.11 @@ -180,6 +181,8 @@
   28.12      hwnd = CreateWindow(SDL_Appname,
   28.13                          title ? title : TEXT(""),
   28.14                          style, x, y, w, h, NULL, NULL, SDL_Instance, NULL);
   28.15 +    WIN_PumpEvents(_this);
   28.16 +
   28.17      if (title) {
   28.18          SDL_free(title);
   28.19      }
    29.1 --- a/src/video/win32/SDL_win32window.h	Thu Jul 06 05:53:32 2006 +0000
    29.2 +++ b/src/video/win32/SDL_win32window.h	Thu Jul 06 07:17:11 2006 +0000
    29.3 @@ -33,6 +33,7 @@
    29.4      HWND hwnd;
    29.5      WNDPROC wndproc;
    29.6      BOOL created;
    29.7 +    int mouse_pressed;
    29.8      struct SDL_VideoData *videodata;
    29.9  } SDL_WindowData;
   29.10  
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/video/win32/wmmsg.h	Thu Jul 06 07:17:11 2006 +0000
    30.3 @@ -0,0 +1,1032 @@
    30.4 +
    30.5 +#define MAX_WMMSG	(sizeof(wmtab)/sizeof(wmtab[0]))
    30.6 +
    30.7 +char *wmtab[] = {
    30.8 +    "WM_NULL",
    30.9 +    "WM_CREATE",
   30.10 +    "WM_DESTROY",
   30.11 +    "WM_MOVE",
   30.12 +    "UNKNOWN (4)",
   30.13 +    "WM_SIZE",
   30.14 +    "WM_ACTIVATE",
   30.15 +    "WM_SETFOCUS",
   30.16 +    "WM_KILLFOCUS",
   30.17 +    "UNKNOWN (9)",
   30.18 +    "WM_ENABLE",
   30.19 +    "WM_SETREDRAW",
   30.20 +    "WM_SETTEXT",
   30.21 +    "WM_GETTEXT",
   30.22 +    "WM_GETTEXTLENGTH",
   30.23 +    "WM_PAINT",
   30.24 +    "WM_CLOSE",
   30.25 +    "WM_QUERYENDSESSION",
   30.26 +    "WM_QUIT",
   30.27 +    "WM_QUERYOPEN",
   30.28 +    "WM_ERASEBKGND",
   30.29 +    "WM_SYSCOLORCHANGE",
   30.30 +    "WM_ENDSESSION",
   30.31 +    "UNKNOWN (23)",
   30.32 +    "WM_SHOWWINDOW",
   30.33 +    "UNKNOWN (25)",
   30.34 +    "WM_SETTINGCHANGE",
   30.35 +    "WM_DEVMODECHANGE",
   30.36 +    "WM_ACTIVATEAPP",
   30.37 +    "WM_FONTCHANGE",
   30.38 +    "WM_TIMECHANGE",
   30.39 +    "WM_CANCELMODE",
   30.40 +    "WM_SETCURSOR",
   30.41 +    "WM_MOUSEACTIVATE",
   30.42 +    "WM_CHILDACTIVATE",
   30.43 +    "WM_QUEUESYNC",
   30.44 +    "WM_GETMINMAXINFO",
   30.45 +    "UNKNOWN (37)",
   30.46 +    "WM_PAINTICON",
   30.47 +    "WM_ICONERASEBKGND",
   30.48 +    "WM_NEXTDLGCTL",
   30.49 +    "UNKNOWN (41)",
   30.50 +    "WM_SPOOLERSTATUS",
   30.51 +    "WM_DRAWITEM",
   30.52 +    "WM_MEASUREITEM",
   30.53 +    "WM_DELETEITEM",
   30.54 +    "WM_VKEYTOITEM",
   30.55 +    "WM_CHARTOITEM",
   30.56 +    "WM_SETFONT",
   30.57 +    "WM_GETFONT",
   30.58 +    "WM_SETHOTKEY",
   30.59 +    "WM_GETHOTKEY",
   30.60 +    "UNKNOWN (52)",
   30.61 +    "UNKNOWN (53)",
   30.62 +    "UNKNOWN (54)",
   30.63 +    "WM_QUERYDRAGICON",
   30.64 +    "UNKNOWN (56)",
   30.65 +    "WM_COMPAREITEM",
   30.66 +    "UNKNOWN (58)",
   30.67 +    "UNKNOWN (59)",
   30.68 +    "UNKNOWN (60)",
   30.69 +    "WM_GETOBJECT",
   30.70 +    "UNKNOWN (62)",
   30.71 +    "UNKNOWN (63)",
   30.72 +    "UNKNOWN (64)",
   30.73 +    "WM_COMPACTING",
   30.74 +    "UNKNOWN (66)",
   30.75 +    "UNKNOWN (67)",
   30.76 +    "WM_COMMNOTIFY",
   30.77 +    "UNKNOWN (69)",
   30.78 +    "WM_WINDOWPOSCHANGING",
   30.79 +    "WM_WINDOWPOSCHANGED",
   30.80 +    "WM_POWER",
   30.81 +    "UNKNOWN (73)",
   30.82 +    "WM_COPYDATA",
   30.83 +    "WM_CANCELJOURNAL",
   30.84 +    "UNKNOWN (76)",
   30.85 +    "UNKNOWN (77)",
   30.86 +    "WM_NOTIFY",
   30.87 +    "UNKNOWN (79)",
   30.88 +    "WM_INPUTLANGCHANGEREQUEST",
   30.89 +    "WM_INPUTLANGCHANGE",
   30.90 +    "WM_TCARD",
   30.91 +    "WM_HELP",
   30.92 +    "WM_USERCHANGED",
   30.93 +    "WM_NOTIFYFORMAT",
   30.94 +    "UNKNOWN (86)",
   30.95 +    "UNKNOWN (87)",
   30.96 +    "UNKNOWN (88)",
   30.97 +    "UNKNOWN (89)",
   30.98 +    "UNKNOWN (90)",
   30.99 +    "UNKNOWN (91)",
  30.100 +    "UNKNOWN (92)",
  30.101 +    "UNKNOWN (93)",
  30.102 +    "UNKNOWN (94)",
  30.103 +    "UNKNOWN (95)",
  30.104 +    "UNKNOWN (96)",
  30.105 +    "UNKNOWN (97)",
  30.106 +    "UNKNOWN (98)",
  30.107 +    "UNKNOWN (99)",
  30.108 +    "UNKNOWN (100)",
  30.109 +    "UNKNOWN (101)",
  30.110 +    "UNKNOWN (102)",
  30.111 +    "UNKNOWN (103)",
  30.112 +    "UNKNOWN (104)",
  30.113 +    "UNKNOWN (105)",
  30.114 +    "UNKNOWN (106)",
  30.115 +    "UNKNOWN (107)",
  30.116 +    "UNKNOWN (108)",
  30.117 +    "UNKNOWN (109)",
  30.118 +    "UNKNOWN (110)",
  30.119 +    "UNKNOWN (111)",
  30.120 +    "UNKNOWN (112)",
  30.121 +    "UNKNOWN (113)",
  30.122 +    "UNKNOWN (114)",
  30.123 +    "UNKNOWN (115)",
  30.124 +    "UNKNOWN (116)",
  30.125 +    "UNKNOWN (117)",
  30.126 +    "UNKNOWN (118)",
  30.127 +    "UNKNOWN (119)",
  30.128 +    "UNKNOWN (120)",
  30.129 +    "UNKNOWN (121)",
  30.130 +    "UNKNOWN (122)",
  30.131 +    "WM_CONTEXTMENU",
  30.132 +    "WM_STYLECHANGING",
  30.133 +    "WM_STYLECHANGED",
  30.134 +    "WM_DISPLAYCHANGE",
  30.135 +    "WM_GETICON",
  30.136 +    "WM_SETICON",
  30.137 +    "WM_NCCREATE",
  30.138 +    "WM_NCDESTROY",
  30.139 +    "WM_NCCALCSIZE",
  30.140 +    "WM_NCHITTEST",
  30.141 +    "WM_NCPAINT",
  30.142 +    "WM_NCACTIVATE",
  30.143 +    "WM_GETDLGCODE",
  30.144 +    "WM_SYNCPAINT",
  30.145 +    "UNKNOWN (137)",
  30.146 +    "UNKNOWN (138)",
  30.147 +    "UNKNOWN (139)",
  30.148 +    "UNKNOWN (140)",
  30.149 +    "UNKNOWN (141)",
  30.150 +    "UNKNOWN (142)",
  30.151 +    "UNKNOWN (143)",
  30.152 +    "UNKNOWN (144)",
  30.153 +    "UNKNOWN (145)",
  30.154 +    "UNKNOWN (146)",
  30.155 +    "UNKNOWN (147)",
  30.156 +    "UNKNOWN (148)",
  30.157 +    "UNKNOWN (149)",
  30.158 +    "UNKNOWN (150)",
  30.159 +    "UNKNOWN (151)",
  30.160 +    "UNKNOWN (152)",
  30.161 +    "UNKNOWN (153)",
  30.162 +    "UNKNOWN (154)",
  30.163 +    "UNKNOWN (155)",
  30.164 +    "UNKNOWN (156)",
  30.165 +    "UNKNOWN (157)",
  30.166 +    "UNKNOWN (158)",
  30.167 +    "UNKNOWN (159)",
  30.168 +    "WM_NCMOUSEMOVE",
  30.169 +    "WM_NCLBUTTONDOWN",
  30.170 +    "WM_NCLBUTTONUP",
  30.171 +    "WM_NCLBUTTONDBLCLK",
  30.172 +    "WM_NCRBUTTONDOWN",
  30.173 +    "WM_NCRBUTTONUP",
  30.174 +    "WM_NCRBUTTONDBLCLK",
  30.175 +    "WM_NCMBUTTONDOWN",
  30.176 +    "WM_NCMBUTTONUP",
  30.177 +    "WM_NCMBUTTONDBLCLK",
  30.178 +    "UNKNOWN (170)",
  30.179 +    "UNKNOWN (171)",
  30.180 +    "UNKNOWN (172)",
  30.181 +    "UNKNOWN (173)",
  30.182 +    "UNKNOWN (174)",
  30.183 +    "UNKNOWN (175)",
  30.184 +    "UNKNOWN (176)",
  30.185 +    "UNKNOWN (177)",
  30.186 +    "UNKNOWN (178)",
  30.187 +    "UNKNOWN (179)",
  30.188 +    "UNKNOWN (180)",
  30.189 +    "UNKNOWN (181)",
  30.190 +    "UNKNOWN (182)",
  30.191 +    "UNKNOWN (183)",
  30.192 +    "UNKNOWN (184)",
  30.193 +    "UNKNOWN (185)",
  30.194 +    "UNKNOWN (186)",
  30.195 +    "UNKNOWN (187)",
  30.196 +    "UNKNOWN (188)",
  30.197 +    "UNKNOWN (189)",
  30.198 +    "UNKNOWN (190)",
  30.199 +    "UNKNOWN (191)",
  30.200 +    "UNKNOWN (192)",
  30.201 +    "UNKNOWN (193)",
  30.202 +    "UNKNOWN (194)",
  30.203 +    "UNKNOWN (195)",
  30.204 +    "UNKNOWN (196)",
  30.205 +    "UNKNOWN (197)",
  30.206 +    "UNKNOWN (198)",
  30.207 +    "UNKNOWN (199)",
  30.208 +    "UNKNOWN (200)",
  30.209 +    "UNKNOWN (201)",
  30.210 +    "UNKNOWN (202)",
  30.211 +    "UNKNOWN (203)",
  30.212 +    "UNKNOWN (204)",
  30.213 +    "UNKNOWN (205)",
  30.214 +    "UNKNOWN (206)",
  30.215 +    "UNKNOWN (207)",
  30.216 +    "UNKNOWN (208)",
  30.217 +    "UNKNOWN (209)",
  30.218 +    "UNKNOWN (210)",
  30.219 +    "UNKNOWN (211)",
  30.220 +    "UNKNOWN (212)",
  30.221 +    "UNKNOWN (213)",
  30.222 +    "UNKNOWN (214)",
  30.223 +    "UNKNOWN (215)",
  30.224 +    "UNKNOWN (216)",
  30.225 +    "UNKNOWN (217)",
  30.226 +    "UNKNOWN (218)",
  30.227 +    "UNKNOWN (219)",
  30.228 +    "UNKNOWN (220)",
  30.229 +    "UNKNOWN (221)",
  30.230 +    "UNKNOWN (222)",
  30.231 +    "UNKNOWN (223)",
  30.232 +    "UNKNOWN (224)",
  30.233 +    "UNKNOWN (225)",
  30.234 +    "UNKNOWN (226)",
  30.235 +    "UNKNOWN (227)",
  30.236 +    "UNKNOWN (228)",
  30.237 +    "UNKNOWN (229)",
  30.238 +    "UNKNOWN (230)",
  30.239 +    "UNKNOWN (231)",
  30.240 +    "UNKNOWN (232)",
  30.241 +    "UNKNOWN (233)",
  30.242 +    "UNKNOWN (234)",
  30.243 +    "UNKNOWN (235)",
  30.244 +    "UNKNOWN (236)",
  30.245 +    "UNKNOWN (237)",
  30.246 +    "UNKNOWN (238)",
  30.247 +    "UNKNOWN (239)",
  30.248 +    "UNKNOWN (240)",
  30.249 +    "UNKNOWN (241)",
  30.250 +    "UNKNOWN (242)",
  30.251 +    "UNKNOWN (243)",
  30.252 +    "UNKNOWN (244)",
  30.253 +    "UNKNOWN (245)",
  30.254 +    "UNKNOWN (246)",
  30.255 +    "UNKNOWN (247)",
  30.256 +    "UNKNOWN (248)",
  30.257 +    "UNKNOWN (249)",
  30.258 +    "UNKNOWN (250)",
  30.259 +    "UNKNOWN (251)",
  30.260 +    "UNKNOWN (252)",
  30.261 +    "UNKNOWN (253)",
  30.262 +    "UNKNOWN (254)",
  30.263 +    "UNKNOWN (255)",
  30.264 +    "WM_KEYDOWN",
  30.265 +    "WM_KEYUP",
  30.266 +    "WM_CHAR",
  30.267 +    "WM_DEADCHAR",
  30.268 +    "WM_SYSKEYDOWN",
  30.269 +    "WM_SYSKEYUP",
  30.270 +    "WM_SYSCHAR",
  30.271 +    "WM_SYSDEADCHAR",
  30.272 +    "WM_KEYLAST",
  30.273 +    "UNKNOWN (265)",
  30.274 +    "UNKNOWN (266)",
  30.275 +    "UNKNOWN (267)",
  30.276 +    "UNKNOWN (268)",
  30.277 +    "UNKNOWN (269)",
  30.278 +    "UNKNOWN (270)",
  30.279 +    "UNKNOWN (271)",
  30.280 +    "WM_INITDIALOG",
  30.281 +    "WM_COMMAND",
  30.282 +    "WM_SYSCOMMAND",
  30.283 +    "WM_TIMER",
  30.284 +    "WM_HSCROLL",
  30.285 +    "WM_VSCROLL",
  30.286 +    "WM_INITMENU",
  30.287 +    "WM_INITMENUPOPUP",
  30.288 +    "UNKNOWN (280)",
  30.289 +    "UNKNOWN (281)",
  30.290 +    "UNKNOWN (282)",
  30.291 +    "UNKNOWN (283)",
  30.292 +    "UNKNOWN (284)",
  30.293 +    "UNKNOWN (285)",
  30.294 +    "UNKNOWN (286)",
  30.295 +    "WM_MENUSELECT",
  30.296 +    "WM_MENUCHAR",
  30.297 +    "WM_ENTERIDLE",
  30.298 +    "WM_MENURBUTTONUP",
  30.299 +    "WM_MENUDRAG",
  30.300 +    "WM_MENUGETOBJECT",
  30.301 +    "WM_UNINITMENUPOPUP",
  30.302 +    "WM_MENUCOMMAND",
  30.303 +    "UNKNOWN (295)",
  30.304 +    "UNKNOWN (296)",
  30.305 +    "UNKNOWN (297)",
  30.306 +    "UNKNOWN (298)",
  30.307 +    "UNKNOWN (299)",
  30.308 +    "UNKNOWN (300)",
  30.309 +    "UNKNOWN (301)",
  30.310 +    "UNKNOWN (302)",
  30.311 +    "UNKNOWN (303)",
  30.312 +    "UNKNOWN (304)",
  30.313 +    "UNKNOWN (305)",
  30.314 +    "WM_CTLCOLORMSGBOX",
  30.315 +    "WM_CTLCOLOREDIT",
  30.316 +    "WM_CTLCOLORLISTBOX",
  30.317 +    "WM_CTLCOLORBTN",
  30.318 +    "WM_CTLCOLORDLG",
  30.319 +    "WM_CTLCOLORSCROLLBAR",
  30.320 +    "WM_CTLCOLORSTATIC",
  30.321 +    "UNKNOWN (313)",
  30.322 +    "UNKNOWN (314)",
  30.323 +    "UNKNOWN (315)",
  30.324 +    "UNKNOWN (316)",
  30.325 +    "UNKNOWN (317)",
  30.326 +    "UNKNOWN (318)",
  30.327 +    "UNKNOWN (319)",
  30.328 +    "UNKNOWN (320)",
  30.329 +    "UNKNOWN (321)",
  30.330 +    "UNKNOWN (322)",
  30.331 +    "UNKNOWN (323)",
  30.332 +    "UNKNOWN (324)",
  30.333 +    "UNKNOWN (325)",
  30.334 +    "UNKNOWN (326)",
  30.335 +    "UNKNOWN (327)",
  30.336 +    "UNKNOWN (328)",
  30.337 +    "UNKNOWN (329)",
  30.338 +    "UNKNOWN (330)",
  30.339 +    "UNKNOWN (331)",
  30.340 +    "UNKNOWN (332)",
  30.341 +    "UNKNOWN (333)",
  30.342 +    "UNKNOWN (334)",
  30.343 +    "UNKNOWN (335)",
  30.344 +    "UNKNOWN (336)",
  30.345 +    "UNKNOWN (337)",
  30.346 +    "UNKNOWN (338)",
  30.347 +    "UNKNOWN (339)",
  30.348 +    "UNKNOWN (340)",
  30.349 +    "UNKNOWN (341)",
  30.350 +    "UNKNOWN (342)",
  30.351 +    "UNKNOWN (343)",
  30.352 +    "UNKNOWN (344)",
  30.353 +    "UNKNOWN (345)",
  30.354 +    "UNKNOWN (346)",
  30.355 +    "UNKNOWN (347)",
  30.356 +    "UNKNOWN (348)",
  30.357 +    "UNKNOWN (349)",
  30.358 +    "UNKNOWN (350)",
  30.359 +    "UNKNOWN (351)",
  30.360 +    "UNKNOWN (352)",
  30.361 +    "UNKNOWN (353)",
  30.362 +    "UNKNOWN (354)",
  30.363 +    "UNKNOWN (355)",
  30.364 +    "UNKNOWN (356)",
  30.365 +    "UNKNOWN (357)",
  30.366 +    "UNKNOWN (358)",
  30.367 +    "UNKNOWN (359)",
  30.368 +    "UNKNOWN (360)",
  30.369 +    "UNKNOWN (361)",
  30.370 +    "UNKNOWN (362)",
  30.371 +    "UNKNOWN (363)",
  30.372 +    "UNKNOWN (364)",
  30.373 +    "UNKNOWN (365)",
  30.374 +    "UNKNOWN (366)",
  30.375 +    "UNKNOWN (367)",
  30.376 +    "UNKNOWN (368)",
  30.377 +    "UNKNOWN (369)",
  30.378 +    "UNKNOWN (370)",
  30.379 +    "UNKNOWN (371)",
  30.380 +    "UNKNOWN (372)",
  30.381 +    "UNKNOWN (373)",
  30.382 +    "UNKNOWN (374)",
  30.383 +    "UNKNOWN (375)",
  30.384 +    "UNKNOWN (376)",
  30.385 +    "UNKNOWN (377)",
  30.386 +    "UNKNOWN (378)",
  30.387 +    "UNKNOWN (379)",
  30.388 +    "UNKNOWN (380)",
  30.389 +    "UNKNOWN (381)",
  30.390 +    "UNKNOWN (382)",
  30.391 +    "UNKNOWN (383)",
  30.392 +    "UNKNOWN (384)",
  30.393 +    "UNKNOWN (385)",
  30.394 +    "UNKNOWN (386)",
  30.395 +    "UNKNOWN (387)",
  30.396 +    "UNKNOWN (388)",
  30.397 +    "UNKNOWN (389)",
  30.398 +    "UNKNOWN (390)",
  30.399 +    "UNKNOWN (391)",
  30.400 +    "UNKNOWN (392)",
  30.401 +    "UNKNOWN (393)",
  30.402 +    "UNKNOWN (394)",
  30.403 +    "UNKNOWN (395)",
  30.404 +    "UNKNOWN (396)",
  30.405 +    "UNKNOWN (397)",
  30.406 +    "UNKNOWN (398)",
  30.407 +    "UNKNOWN (399)",
  30.408 +    "UNKNOWN (400)",
  30.409 +    "UNKNOWN (401)",
  30.410 +    "UNKNOWN (402)",
  30.411 +    "UNKNOWN (403)",
  30.412 +    "UNKNOWN (404)",
  30.413 +    "UNKNOWN (405)",
  30.414 +    "UNKNOWN (406)",
  30.415 +    "UNKNOWN (407)",
  30.416 +    "UNKNOWN (408)",
  30.417 +    "UNKNOWN (409)",
  30.418 +    "UNKNOWN (410)",
  30.419 +    "UNKNOWN (411)",
  30.420 +    "UNKNOWN (412)",
  30.421 +    "UNKNOWN (413)",
  30.422 +    "UNKNOWN (414)",
  30.423 +    "UNKNOWN (415)",
  30.424 +    "UNKNOWN (416)",
  30.425 +    "UNKNOWN (417)",
  30.426 +    "UNKNOWN (418)",
  30.427 +    "UNKNOWN (419)",
  30.428 +    "UNKNOWN (420)",
  30.429 +    "UNKNOWN (421)",
  30.430 +    "UNKNOWN (422)",
  30.431 +    "UNKNOWN (423)",
  30.432 +    "UNKNOWN (424)",
  30.433 +    "UNKNOWN (425)",
  30.434 +    "UNKNOWN (426)",
  30.435 +    "UNKNOWN (427)",
  30.436 +    "UNKNOWN (428)",
  30.437 +    "UNKNOWN (429)",
  30.438 +    "UNKNOWN (430)",
  30.439 +    "UNKNOWN (431)",
  30.440 +    "UNKNOWN (432)",
  30.441 +    "UNKNOWN (433)",
  30.442 +    "UNKNOWN (434)",
  30.443 +    "UNKNOWN (435)",
  30.444 +    "UNKNOWN (436)",
  30.445 +    "UNKNOWN (437)",
  30.446 +    "UNKNOWN (438)",
  30.447 +    "UNKNOWN (439)",
  30.448 +    "UNKNOWN (440)",
  30.449 +    "UNKNOWN (441)",
  30.450 +    "UNKNOWN (442)",
  30.451 +    "UNKNOWN (443)",
  30.452 +    "UNKNOWN (444)",
  30.453 +    "UNKNOWN (445)",
  30.454 +    "UNKNOWN (446)",
  30.455 +    "UNKNOWN (447)",
  30.456 +    "UNKNOWN (448)",
  30.457 +    "UNKNOWN (449)",
  30.458 +    "UNKNOWN (450)",
  30.459 +    "UNKNOWN (451)",
  30.460 +    "UNKNOWN (452)",
  30.461 +    "UNKNOWN (453)",
  30.462 +    "UNKNOWN (454)",
  30.463 +    "UNKNOWN (455)",
  30.464 +    "UNKNOWN (456)",
  30.465 +    "UNKNOWN (457)",
  30.466 +    "UNKNOWN (458)",
  30.467 +    "UNKNOWN (459)",
  30.468 +    "UNKNOWN (460)",
  30.469 +    "UNKNOWN (461)",
  30.470 +    "UNKNOWN (462)",
  30.471 +    "UNKNOWN (463)",
  30.472 +    "UNKNOWN (464)",
  30.473 +    "UNKNOWN (465)",
  30.474 +    "UNKNOWN (466)",
  30.475 +    "UNKNOWN (467)",
  30.476 +    "UNKNOWN (468)",
  30.477 +    "UNKNOWN (469)",
  30.478 +    "UNKNOWN (470)",
  30.479 +    "UNKNOWN (471)",
  30.480 +    "UNKNOWN (472)",
  30.481 +    "UNKNOWN (473)",
  30.482 +    "UNKNOWN (474)",
  30.483 +    "UNKNOWN (475)",
  30.484 +    "UNKNOWN (476)",
  30.485 +    "UNKNOWN (477)",
  30.486 +    "UNKNOWN (478)",
  30.487 +    "UNKNOWN (479)",
  30.488 +    "UNKNOWN (480)",
  30.489 +    "UNKNOWN (481)",
  30.490 +    "UNKNOWN (482)",
  30.491 +    "UNKNOWN (483)",
  30.492 +    "UNKNOWN (484)",
  30.493 +    "UNKNOWN (485)",
  30.494 +    "UNKNOWN (486)",
  30.495 +    "UNKNOWN (487)",
  30.496 +    "UNKNOWN (488)",
  30.497 +    "UNKNOWN (489)",
  30.498 +    "UNKNOWN (490)",
  30.499 +    "UNKNOWN (491)",
  30.500 +    "UNKNOWN (492)",
  30.501 +    "UNKNOWN (493)",
  30.502 +    "UNKNOWN (494)",
  30.503 +    "UNKNOWN (495)",
  30.504 +    "UNKNOWN (496)",
  30.505 +    "UNKNOWN (497)",
  30.506 +    "UNKNOWN (498)",
  30.507 +    "UNKNOWN (499)",
  30.508 +    "UNKNOWN (500)",
  30.509 +    "UNKNOWN (501)",
  30.510 +    "UNKNOWN (502)",
  30.511 +    "UNKNOWN (503)",
  30.512 +    "UNKNOWN (504)",
  30.513 +    "UNKNOWN (505)",
  30.514 +    "UNKNOWN (506)",
  30.515 +    "UNKNOWN (507)",
  30.516 +    "UNKNOWN (508)",
  30.517 +    "UNKNOWN (509)",
  30.518 +    "UNKNOWN (510)",
  30.519 +    "UNKNOWN (511)",
  30.520 +    "WM_MOUSEMOVE",
  30.521 +    "WM_LBUTTONDOWN",
  30.522 +    "WM_LBUTTONUP",
  30.523 +    "WM_LBUTTONDBLCLK",
  30.524 +    "WM_RBUTTONDOWN",
  30.525 +    "WM_RBUTTONUP",
  30.526 +    "WM_RBUTTONDBLCLK",
  30.527 +    "WM_MBUTTONDOWN",
  30.528 +    "WM_MBUTTONUP",
  30.529 +    "WM_MOUSELAST",
  30.530 +    "WM_MOUSELAST",
  30.531 +    "UNKNOWN (523)",
  30.532 +    "UNKNOWN (524)",
  30.533 +    "UNKNOWN (525)",
  30.534 +    "UNKNOWN (526)",
  30.535 +    "UNKNOWN (527)",
  30.536 +    "WM_PARENTNOTIFY",
  30.537 +    "WM_ENTERMENULOOP",
  30.538 +    "WM_EXITMENULOOP",
  30.539 +    "WM_NEXTMENU",
  30.540 +    "WM_SIZING",
  30.541 +    "WM_CAPTURECHANGED",
  30.542 +    "WM_MOVING",
  30.543 +    "UNKNOWN (535)",
  30.544 +    "WM_POWERBROADCAST",
  30.545 +    "WM_DEVICECHANGE",
  30.546 +    "UNKNOWN (538)",
  30.547 +    "UNKNOWN (539)",
  30.548 +    "UNKNOWN (540)",
  30.549 +    "UNKNOWN (541)",
  30.550 +    "UNKNOWN (542)",
  30.551 +    "UNKNOWN (543)",
  30.552 +    "WM_MDICREATE",
  30.553 +    "WM_MDIDESTROY",
  30.554 +    "WM_MDIACTIVATE",
  30.555 +    "WM_MDIRESTORE",
  30.556 +    "WM_MDINEXT",
  30.557 +    "WM_MDIMAXIMIZE",
  30.558 +    "WM_MDITILE",
  30.559 +    "WM_MDICASCADE",
  30.560 +    "WM_MDIICONARRANGE",
  30.561 +    "WM_MDIGETACTIVE",
  30.562 +    "UNKNOWN (554)",
  30.563 +    "UNKNOWN (555)",
  30.564 +    "UNKNOWN (556)",
  30.565 +    "UNKNOWN (557)",
  30.566 +    "UNKNOWN (558)",
  30.567 +    "UNKNOWN (559)",
  30.568 +    "WM_MDISETMENU",
  30.569 +    "WM_ENTERSIZEMOVE",
  30.570 +    "WM_EXITSIZEMOVE",
  30.571 +    "WM_DROPFILES",
  30.572 +    "WM_MDIREFRESHMENU",
  30.573 +    "UNKNOWN (565)",
  30.574 +    "UNKNOWN (566)",
  30.575 +    "UNKNOWN (567)",
  30.576 +    "UNKNOWN (568)",
  30.577 +    "UNKNOWN (569)",
  30.578 +    "UNKNOWN (570)",
  30.579 +    "UNKNOWN (571)",
  30.580 +    "UNKNOWN (572)",
  30.581 +    "UNKNOWN (573)",
  30.582 +    "UNKNOWN (574)",
  30.583 +    "UNKNOWN (575)",
  30.584 +    "UNKNOWN (576)",
  30.585 +    "UNKNOWN (577)",
  30.586 +    "UNKNOWN (578)",
  30.587 +    "UNKNOWN (579)",
  30.588 +    "UNKNOWN (580)",
  30.589 +    "UNKNOWN (581)",
  30.590 +    "UNKNOWN (582)",
  30.591 +    "UNKNOWN (583)",
  30.592 +    "UNKNOWN (584)",
  30.593 +    "UNKNOWN (585)",
  30.594 +    "UNKNOWN (586)",
  30.595 +    "UNKNOWN (587)",
  30.596 +    "UNKNOWN (588)",
  30.597 +    "UNKNOWN (589)",
  30.598 +    "UNKNOWN (590)",
  30.599 +    "UNKNOWN (591)",
  30.600 +    "UNKNOWN (592)",
  30.601 +    "UNKNOWN (593)",
  30.602 +    "UNKNOWN (594)",
  30.603 +    "UNKNOWN (595)",
  30.604 +    "UNKNOWN (596)",
  30.605 +    "UNKNOWN (597)",
  30.606 +    "UNKNOWN (598)",
  30.607 +    "UNKNOWN (599)",
  30.608 +    "UNKNOWN (600)",
  30.609 +    "UNKNOWN (601)",
  30.610 +    "UNKNOWN (602)",
  30.611 +    "UNKNOWN (603)",
  30.612 +    "UNKNOWN (604)",
  30.613 +    "UNKNOWN (605)",
  30.614 +    "UNKNOWN (606)",
  30.615 +    "UNKNOWN (607)",
  30.616 +    "UNKNOWN (608)",
  30.617 +    "UNKNOWN (609)",
  30.618 +    "UNKNOWN (610)",
  30.619 +    "UNKNOWN (611)",
  30.620 +    "UNKNOWN (612)",
  30.621 +    "UNKNOWN (613)",
  30.622 +    "UNKNOWN (614)",
  30.623 +    "UNKNOWN (615)",
  30.624 +    "UNKNOWN (616)",
  30.625 +    "UNKNOWN (617)",
  30.626 +    "UNKNOWN (618)",
  30.627 +    "UNKNOWN (619)",
  30.628 +    "UNKNOWN (620)",
  30.629 +    "UNKNOWN (621)",
  30.630 +    "UNKNOWN (622)",
  30.631 +    "UNKNOWN (623)",
  30.632 +    "UNKNOWN (624)",
  30.633 +    "UNKNOWN (625)",
  30.634 +    "UNKNOWN (626)",
  30.635 +    "UNKNOWN (627)",
  30.636 +    "UNKNOWN (628)",
  30.637 +    "UNKNOWN (629)",
  30.638 +    "UNKNOWN (630)",
  30.639 +    "UNKNOWN (631)",
  30.640 +    "UNKNOWN (632)",
  30.641 +    "UNKNOWN (633)",
  30.642 +    "UNKNOWN (634)",
  30.643 +    "UNKNOWN (635)",
  30.644 +    "UNKNOWN (636)",
  30.645 +    "UNKNOWN (637)",
  30.646 +    "UNKNOWN (638)",
  30.647 +    "UNKNOWN (639)",
  30.648 +    "UNKNOWN (640)",
  30.649 +    "UNKNOWN (641)",
  30.650 +    "UNKNOWN (642)",
  30.651 +    "UNKNOWN (643)",
  30.652 +    "UNKNOWN (644)",
  30.653 +    "UNKNOWN (645)",
  30.654 +    "UNKNOWN (646)",
  30.655 +    "UNKNOWN (647)",
  30.656 +    "UNKNOWN (648)",
  30.657 +    "UNKNOWN (649)",
  30.658 +    "UNKNOWN (650)",
  30.659 +    "UNKNOWN (651)",
  30.660 +    "UNKNOWN (652)",
  30.661 +    "UNKNOWN (653)",
  30.662 +    "UNKNOWN (654)",
  30.663 +    "UNKNOWN (655)",
  30.664 +    "UNKNOWN (656)",
  30.665 +    "UNKNOWN (657)",
  30.666 +    "UNKNOWN (658)",
  30.667 +    "UNKNOWN (659)",
  30.668 +    "UNKNOWN (660)",
  30.669 +    "UNKNOWN (661)",
  30.670 +    "UNKNOWN (662)",
  30.671 +    "UNKNOWN (663)",
  30.672 +    "UNKNOWN (664)",
  30.673 +    "UNKNOWN (665)",
  30.674 +    "UNKNOWN (666)",
  30.675 +    "UNKNOWN (667)",
  30.676 +    "UNKNOWN (668)",
  30.677 +    "UNKNOWN (669)",
  30.678 +    "UNKNOWN (670)",
  30.679 +    "UNKNOWN (671)",
  30.680 +    "UNKNOWN (672)",
  30.681 +    "WM_MOUSEHOVER",
  30.682 +    "UNKNOWN (674)",
  30.683 +    "WM_MOUSELEAVE",
  30.684 +    "UNKNOWN (676)",
  30.685 +    "UNKNOWN (677)",
  30.686 +    "UNKNOWN (678)",
  30.687 +    "UNKNOWN (679)",
  30.688 +    "UNKNOWN (680)",
  30.689 +    "UNKNOWN (681)",
  30.690 +    "UNKNOWN (682)",
  30.691 +    "UNKNOWN (683)",
  30.692 +    "UNKNOWN (684)",
  30.693 +    "UNKNOWN (685)",
  30.694 +    "UNKNOWN (686)",
  30.695 +    "UNKNOWN (687)",
  30.696 +    "UNKNOWN (688)",
  30.697 +    "UNKNOWN (689)",
  30.698 +    "UNKNOWN (690)",
  30.699 +    "UNKNOWN (691)",
  30.700 +    "UNKNOWN (692)",
  30.701 +    "UNKNOWN (693)",
  30.702 +    "UNKNOWN (694)",
  30.703 +    "UNKNOWN (695)",
  30.704 +    "UNKNOWN (696)",
  30.705 +    "UNKNOWN (697)",
  30.706 +    "UNKNOWN (698)",
  30.707 +    "UNKNOWN (699)",
  30.708 +    "UNKNOWN (700)",
  30.709 +    "UNKNOWN (701)",
  30.710 +    "UNKNOWN (702)",
  30.711 +    "UNKNOWN (703)",
  30.712 +    "UNKNOWN (704)",
  30.713 +    "UNKNOWN (705)",
  30.714 +    "UNKNOWN (706)",
  30.715 +    "UNKNOWN (707)",
  30.716 +    "UNKNOWN (708)",
  30.717 +    "UNKNOWN (709)",
  30.718 +    "UNKNOWN (710)",
  30.719 +    "UNKNOWN (711)",
  30.720 +    "UNKNOWN (712)",
  30.721 +    "UNKNOWN (713)",
  30.722 +    "UNKNOWN (714)",
  30.723 +    "UNKNOWN (715)",
  30.724 +    "UNKNOWN (716)",
  30.725 +    "UNKNOWN (717)",
  30.726 +    "UNKNOWN (718)",
  30.727 +    "UNKNOWN (719)",
  30.728 +    "UNKNOWN (720)",
  30.729 +    "UNKNOWN (721)",
  30.730 +    "UNKNOWN (722)",
  30.731 +    "UNKNOWN (723)",
  30.732 +    "UNKNOWN (724)",
  30.733 +    "UNKNOWN (725)",
  30.734 +    "UNKNOWN (726)",
  30.735 +    "UNKNOWN (727)",
  30.736 +    "UNKNOWN (728)",
  30.737 +    "UNKNOWN (729)",
  30.738 +    "UNKNOWN (730)",
  30.739 +    "UNKNOWN (731)",
  30.740 +    "UNKNOWN (732)",
  30.741 +    "UNKNOWN (733)",
  30.742 +    "UNKNOWN (734)",
  30.743 +    "UNKNOWN (735)",
  30.744 +    "UNKNOWN (736)",
  30.745 +    "UNKNOWN (737)",
  30.746 +    "UNKNOWN (738)",
  30.747 +    "UNKNOWN (739)",
  30.748 +    "UNKNOWN (740)",
  30.749 +    "UNKNOWN (741)",
  30.750 +    "UNKNOWN (742)",
  30.751 +    "UNKNOWN (743)",
  30.752 +    "UNKNOWN (744)",
  30.753 +    "UNKNOWN (745)",
  30.754 +    "UNKNOWN (746)",
  30.755 +    "UNKNOWN (747)",
  30.756 +    "UNKNOWN (748)",
  30.757 +    "UNKNOWN (749)",
  30.758 +    "UNKNOWN (750)",
  30.759 +    "UNKNOWN (751)",
  30.760 +    "UNKNOWN (752)",
  30.761 +    "UNKNOWN (753)",
  30.762 +    "UNKNOWN (754)",
  30.763 +    "UNKNOWN (755)",
  30.764 +    "UNKNOWN (756)",
  30.765 +    "UNKNOWN (757)",
  30.766 +    "UNKNOWN (758)",
  30.767 +    "UNKNOWN (759)",
  30.768 +    "UNKNOWN (760)",
  30.769 +    "UNKNOWN (761)",
  30.770 +    "UNKNOWN (762)",
  30.771 +    "UNKNOWN (763)",
  30.772 +    "UNKNOWN (764)",
  30.773 +    "UNKNOWN (765)",
  30.774 +    "UNKNOWN (766)",
  30.775 +    "UNKNOWN (767)",
  30.776 +    "WM_CUT",
  30.777 +    "WM_COPY",
  30.778 +    "WM_PASTE",
  30.779 +    "WM_CLEAR",
  30.780 +    "WM_UNDO",
  30.781 +    "WM_RENDERFORMAT",
  30.782 +    "WM_RENDERALLFORMATS",
  30.783 +    "WM_DESTROYCLIPBOARD",
  30.784 +    "WM_DRAWCLIPBOARD",
  30.785 +    "WM_PAINTCLIPBOARD",
  30.786 +    "WM_VSCROLLCLIPBOARD",
  30.787 +    "WM_SIZECLIPBOARD",
  30.788 +    "WM_ASKCBFORMATNAME",
  30.789 +    "WM_CHANGECBCHAIN",
  30.790 +    "WM_HSCROLLCLIPBOARD",
  30.791 +    "WM_QUERYNEWPALETTE",
  30.792 +    "WM_PALETTEISCHANGING",
  30.793 +    "WM_PALETTECHANGED",
  30.794 +    "WM_HOTKEY",
  30.795 +    "UNKNOWN (787)",
  30.796 +    "UNKNOWN (788)",
  30.797 +    "UNKNOWN (789)",
  30.798 +    "UNKNOWN (790)",
  30.799 +    "WM_PRINT",
  30.800 +    "WM_PRINTCLIENT",
  30.801 +    "UNKNOWN (793)",
  30.802 +    "UNKNOWN (794)",
  30.803 +    "UNKNOWN (795)",
  30.804 +    "UNKNOWN (796)",
  30.805 +    "UNKNOWN (797)",
  30.806 +    "UNKNOWN (798)",
  30.807 +    "UNKNOWN (799)",
  30.808 +    "UNKNOWN (800)",
  30.809 +    "UNKNOWN (801)",
  30.810 +    "UNKNOWN (802)",
  30.811 +    "UNKNOWN (803)",
  30.812 +    "UNKNOWN (804)",
  30.813 +    "UNKNOWN (805)",
  30.814 +    "UNKNOWN (806)",
  30.815 +    "UNKNOWN (807)",
  30.816 +    "UNKNOWN (808)",
  30.817 +    "UNKNOWN (809)",
  30.818 +    "UNKNOWN (810)",
  30.819 +    "UNKNOWN (811)",
  30.820 +    "UNKNOWN (812)",
  30.821 +    "UNKNOWN (813)",
  30.822 +    "UNKNOWN (814)",
  30.823 +    "UNKNOWN (815)",
  30.824 +    "UNKNOWN (816)",
  30.825 +    "UNKNOWN (817)",
  30.826 +    "UNKNOWN (818)",
  30.827 +    "UNKNOWN (819)",
  30.828 +    "UNKNOWN (820)",
  30.829 +    "UNKNOWN (821)",
  30.830 +    "UNKNOWN (822)",
  30.831 +    "UNKNOWN (823)",
  30.832 +    "UNKNOWN (824)",
  30.833 +    "UNKNOWN (825)",
  30.834 +    "UNKNOWN (826)",
  30.835 +    "UNKNOWN (827)",
  30.836 +    "UNKNOWN (828)",
  30.837 +    "UNKNOWN (829)",
  30.838 +    "UNKNOWN (830)",
  30.839 +    "UNKNOWN (831)",
  30.840 +    "UNKNOWN (832)",
  30.841 +    "UNKNOWN (833)",
  30.842 +    "UNKNOWN (834)",
  30.843 +    "UNKNOWN (835)",
  30.844 +    "UNKNOWN (836)",
  30.845 +    "UNKNOWN (837)",
  30.846 +    "UNKNOWN (838)",
  30.847 +    "UNKNOWN (839)",
  30.848 +    "UNKNOWN (840)",
  30.849 +    "UNKNOWN (841)",
  30.850 +    "UNKNOWN (842)",
  30.851 +    "UNKNOWN (843)",
  30.852 +    "UNKNOWN (844)",
  30.853 +    "UNKNOWN (845)",
  30.854 +    "UNKNOWN (846)",
  30.855 +    "UNKNOWN (847)",
  30.856 +    "UNKNOWN (848)",
  30.857 +    "UNKNOWN (849)",
  30.858 +    "UNKNOWN (850)",
  30.859 +    "UNKNOWN (851)",
  30.860 +    "UNKNOWN (852)",
  30.861 +    "UNKNOWN (853)",
  30.862 +    "UNKNOWN (854)",
  30.863 +    "UNKNOWN (855)",
  30.864 +    "WM_HANDHELDFIRST",
  30.865 +    "UNKNOWN (857)",
  30.866 +    "UNKNOWN (858)",
  30.867 +    "UNKNOWN (859)",
  30.868 +    "UNKNOWN (860)",
  30.869 +    "UNKNOWN (861)",
  30.870 +    "UNKNOWN (862)",
  30.871 +    "WM_HANDHELDLAST",
  30.872 +    "WM_AFXFIRST",
  30.873 +    "UNKNOWN (865)",
  30.874 +    "UNKNOWN (866)",
  30.875 +    "UNKNOWN (867)",
  30.876 +    "UNKNOWN (868)",
  30.877 +    "UNKNOWN (869)",
  30.878 +    "UNKNOWN (870)",
  30.879 +    "UNKNOWN (871)",
  30.880 +    "UNKNOWN (872)",
  30.881 +    "UNKNOWN (873)",
  30.882 +    "UNKNOWN (874)",
  30.883 +    "UNKNOWN (875)",
  30.884 +    "UNKNOWN (876)",
  30.885 +    "UNKNOWN (877)",
  30.886 +    "UNKNOWN (878)",
  30.887 +    "UNKNOWN (879)",
  30.888 +    "UNKNOWN (880)",
  30.889 +    "UNKNOWN (881)",
  30.890 +    "UNKNOWN (882)",
  30.891 +    "UNKNOWN (883)",
  30.892 +    "UNKNOWN (884)",
  30.893 +    "UNKNOWN (885)",
  30.894 +    "UNKNOWN (886)",
  30.895 +    "UNKNOWN (887)",
  30.896 +    "UNKNOWN (888)",
  30.897 +    "UNKNOWN (889)",
  30.898 +    "UNKNOWN (890)",
  30.899 +    "UNKNOWN (891)",
  30.900 +    "UNKNOWN (892)",
  30.901 +    "UNKNOWN (893)",
  30.902 +    "UNKNOWN (894)",
  30.903 +    "WM_AFXLAST",
  30.904 +    "WM_PENWINFIRST",
  30.905 +    "UNKNOWN (897)",
  30.906 +    "UNKNOWN (898)",
  30.907 +    "UNKNOWN (899)",
  30.908 +    "UNKNOWN (900)",
  30.909 +    "UNKNOWN (901)",
  30.910 +    "UNKNOWN (902)",
  30.911 +    "UNKNOWN (903)",
  30.912 +    "UNKNOWN (904)",
  30.913 +    "UNKNOWN (905)",
  30.914 +    "UNKNOWN (906)",
  30.915 +    "UNKNOWN (907)",
  30.916 +    "UNKNOWN (908)",
  30.917 +    "UNKNOWN (909)",
  30.918 +    "UNKNOWN (910)",
  30.919 +    "WM_PENWINLAST",
  30.920 +    "UNKNOWN (912)",
  30.921 +    "UNKNOWN (913)",
  30.922 +    "UNKNOWN (914)",
  30.923 +    "UNKNOWN (915)",
  30.924 +    "UNKNOWN (916)",
  30.925 +    "UNKNOWN (917)",
  30.926 +    "UNKNOWN (918)",
  30.927 +    "UNKNOWN (919)",
  30.928 +    "UNKNOWN (920)",
  30.929 +    "UNKNOWN (921)",
  30.930 +    "UNKNOWN (922)",
  30.931 +    "UNKNOWN (923)",
  30.932 +    "UNKNOWN (924)",
  30.933 +    "UNKNOWN (925)",
  30.934 +    "UNKNOWN (926)",
  30.935 +    "UNKNOWN (927)",
  30.936 +    "UNKNOWN (928)",
  30.937 +    "UNKNOWN (929)",
  30.938 +    "UNKNOWN (930)",
  30.939 +    "UNKNOWN (931)",
  30.940 +    "UNKNOWN (932)",
  30.941 +    "UNKNOWN (933)",
  30.942 +    "UNKNOWN (934)",
  30.943 +    "UNKNOWN (935)",
  30.944 +    "UNKNOWN (936)",
  30.945 +    "UNKNOWN (937)",
  30.946 +    "UNKNOWN (938)",
  30.947 +    "UNKNOWN (939)",
  30.948 +    "UNKNOWN (940)",
  30.949 +    "UNKNOWN (941)",
  30.950 +    "UNKNOWN (942)",
  30.951 +    "UNKNOWN (943)",
  30.952 +    "UNKNOWN (944)",
  30.953 +    "UNKNOWN (945)",
  30.954 +    "UNKNOWN (946)",
  30.955 +    "UNKNOWN (947)",
  30.956 +    "UNKNOWN (948)",
  30.957 +    "UNKNOWN (949)",
  30.958 +    "UNKNOWN (950)",
  30.959 +    "UNKNOWN (951)",
  30.960 +    "UNKNOWN (952)",
  30.961 +    "UNKNOWN (953)",
  30.962 +    "UNKNOWN (954)",
  30.963 +    "UNKNOWN (955)",
  30.964 +    "UNKNOWN (956)",
  30.965 +    "UNKNOWN (957)",
  30.966 +    "UNKNOWN (958)",
  30.967 +    "UNKNOWN (959)",
  30.968 +    "UNKNOWN (960)",
  30.969 +    "UNKNOWN (961)",
  30.970 +    "UNKNOWN (962)",
  30.971 +    "UNKNOWN (963)",
  30.972 +    "UNKNOWN (964)",
  30.973 +    "UNKNOWN (965)",
  30.974 +    "UNKNOWN (966)",
  30.975 +    "UNKNOWN (967)",
  30.976 +    "UNKNOWN (968)",
  30.977 +    "UNKNOWN (969)",
  30.978 +    "UNKNOWN (970)",
  30.979 +    "UNKNOWN (971)",
  30.980 +    "UNKNOWN (972)",
  30.981 +    "UNKNOWN (973)",
  30.982 +    "UNKNOWN (974)",
  30.983 +    "UNKNOWN (975)",
  30.984 +    "UNKNOWN (976)",
  30.985 +    "UNKNOWN (977)",
  30.986 +    "UNKNOWN (978)",
  30.987 +    "UNKNOWN (979)",
  30.988 +    "UNKNOWN (980)",
  30.989 +    "UNKNOWN (981)",
  30.990 +    "UNKNOWN (982)",
  30.991 +    "UNKNOWN (983)",
  30.992 +    "UNKNOWN (984)",
  30.993 +    "UNKNOWN (985)",
  30.994 +    "UNKNOWN (986)",
  30.995 +    "UNKNOWN (987)",
  30.996 +    "UNKNOWN (988)",
  30.997 +    "UNKNOWN (989)",
  30.998 +    "UNKNOWN (990)",
  30.999 +    "UNKNOWN (991)",
 30.1000 +    "UNKNOWN (992)",
 30.1001 +    "UNKNOWN (993)",
 30.1002 +    "UNKNOWN (994)",
 30.1003 +    "UNKNOWN (995)",
 30.1004 +    "UNKNOWN (996)",
 30.1005 +    "UNKNOWN (997)",
 30.1006 +    "UNKNOWN (998)",
 30.1007 +    "UNKNOWN (999)",
 30.1008 +    "UNKNOWN (1000)",
 30.1009 +    "UNKNOWN (1001)",
 30.1010 +    "UNKNOWN (1002)",
 30.1011 +    "UNKNOWN (1003)",
 30.1012 +    "UNKNOWN (1004)",
 30.1013 +    "UNKNOWN (1005)",
 30.1014 +    "UNKNOWN (1006)",
 30.1015 +    "UNKNOWN (1007)",
 30.1016 +    "UNKNOWN (1008)",
 30.1017 +    "UNKNOWN (1009)",
 30.1018 +    "UNKNOWN (1010)",
 30.1019 +    "UNKNOWN (1011)",
 30.1020 +    "UNKNOWN (1012)",
 30.1021 +    "UNKNOWN (1013)",
 30.1022 +    "UNKNOWN (1014)",
 30.1023 +    "UNKNOWN (1015)",
 30.1024 +    "UNKNOWN (1016)",
 30.1025 +    "UNKNOWN (1017)",
 30.1026 +    "UNKNOWN (1018)",
 30.1027 +    "UNKNOWN (1019)",
 30.1028 +    "UNKNOWN (1020)",
 30.1029 +    "UNKNOWN (1021)",
 30.1030 +    "UNKNOWN (1022)",
 30.1031 +    "UNKNOWN (1023)",
 30.1032 +    "WM_USER"
 30.1033 +};
 30.1034 +
 30.1035 +/* vi: set ts=4 sw=4 expandtab: */
    31.1 --- a/test/graywin.c	Thu Jul 06 05:53:32 2006 +0000
    31.2 +++ b/test/graywin.c	Thu Jul 06 07:17:11 2006 +0000
    31.3 @@ -228,8 +228,11 @@
    31.4              DrawBackground(screen);
    31.5              break;
    31.6          case SDL_VIDEORESIZE:
    31.7 -            screen = CreateScreen(event.resize.w, event.resize.h,
    31.8 -                                  screen->format->BitsPerPixel, videoflags);
    31.9 +            printf("Screen resized to %dx%d\n", event.resize.w,
   31.10 +                   event.resize.h);
   31.11 +            screen =
   31.12 +                CreateScreen(event.resize.w, event.resize.h,
   31.13 +                             screen->format->BitsPerPixel, videoflags);
   31.14              if (screen == NULL) {
   31.15                  fprintf(stderr, "Couldn't resize video mode\n");
   31.16                  done = 1;
    32.1 --- a/test/testsprite2.c	Thu Jul 06 05:53:32 2006 +0000
    32.2 +++ b/test/testsprite2.c	Thu Jul 06 07:17:11 2006 +0000
    32.3 @@ -5,11 +5,12 @@
    32.4  
    32.5  #include "SDL.h"
    32.6  
    32.7 -#define NUM_WINDOWS 2
    32.8 +#define NUM_WINDOWS 4
    32.9  #define WINDOW_W    640
   32.10  #define WINDOW_H    480
   32.11  #define NUM_SPRITES	100
   32.12  #define MAX_SPEED 	1
   32.13 +#define BACKGROUND  0x00FFFFFF
   32.14  
   32.15  static int num_windows;
   32.16  static int num_sprites;
   32.17 @@ -85,8 +86,6 @@
   32.18  
   32.19      SDL_SelectRenderer(window);
   32.20  
   32.21 -    SDL_RenderFill(NULL, 0);
   32.22 -
   32.23      /* Query the sizes */
   32.24      SDL_GetWindowSize(window, &window_w, &window_h);
   32.25  
   32.26 @@ -94,6 +93,10 @@
   32.27      n = 0;
   32.28      for (i = 0; i < num_sprites; ++i) {
   32.29          position = &positions[i];
   32.30 +        SDL_RenderFill(position, BACKGROUND);
   32.31 +    }
   32.32 +    for (i = 0; i < num_sprites; ++i) {
   32.33 +        position = &positions[i];
   32.34          velocity = &velocities[i];
   32.35          position->x += velocity->x;
   32.36          if ((position->x < 0) || (position->x >= (window_w - sprite_w))) {
   32.37 @@ -168,7 +171,8 @@
   32.38  
   32.39          SDL_snprintf(title, sizeof(title), "testsprite %d", i + 1);
   32.40          windows[i] =
   32.41 -            SDL_CreateWindow(title, -1, -1, window_w, window_h,
   32.42 +            SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED,
   32.43 +                             SDL_WINDOWPOS_UNDEFINED, window_w, window_h,
   32.44                               SDL_WINDOW_SHOWN);
   32.45          if (!windows[i]) {
   32.46              fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
   32.47 @@ -179,6 +183,7 @@
   32.48              fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
   32.49              quit(2);
   32.50          }
   32.51 +        SDL_RenderFill(NULL, BACKGROUND);
   32.52      }
   32.53      if (LoadSprite("icon.bmp") < 0) {
   32.54          quit(2);
   32.55 @@ -214,6 +219,17 @@
   32.56          ++frames;
   32.57          while (SDL_PollEvent(&event)) {
   32.58              switch (event.type) {
   32.59 +            case SDL_WINDOWEVENT:
   32.60 +                switch (event.window.event) {
   32.61 +                case SDL_WINDOWEVENT_EXPOSED:
   32.62 +                    SDL_SelectRenderer(event.window.windowID);
   32.63 +                    SDL_RenderFill(NULL, BACKGROUND);
   32.64 +                    break;
   32.65 +                case SDL_WINDOWEVENT_CLOSE:
   32.66 +                    done = 1;
   32.67 +                    break;
   32.68 +                }
   32.69 +                break;
   32.70              case SDL_KEYDOWN:
   32.71                  /* Any keypress quits the app... */
   32.72              case SDL_QUIT:
    33.1 --- a/test/testwm.c	Thu Jul 06 05:53:32 2006 +0000
    33.2 +++ b/test/testwm.c	Thu Jul 06 07:17:11 2006 +0000
    33.3 @@ -176,7 +176,7 @@
    33.4  }
    33.5  
    33.6  int SDLCALL
    33.7 -FilterEvents(SDL_Event * event)
    33.8 +FilterEvents(void *userdata, SDL_Event * event)
    33.9  {
   33.10      static int reallyquit = 0;
   33.11  
   33.12 @@ -344,7 +344,7 @@
   33.13      }
   33.14  
   33.15      /* Set an event filter that discards everything but QUIT */
   33.16 -    SDL_SetEventFilter(FilterEvents);
   33.17 +    SDL_SetEventFilter(FilterEvents, NULL);
   33.18  
   33.19      /* Ignore key up events, they don't even get filtered */
   33.20      SDL_EventState(SDL_KEYUP, SDL_IGNORE);
    34.1 --- a/test/threadwin.c	Thu Jul 06 05:53:32 2006 +0000
    34.2 +++ b/test/threadwin.c	Thu Jul 06 07:17:11 2006 +0000
    34.3 @@ -80,7 +80,7 @@
    34.4  }
    34.5  
    34.6  int SDLCALL
    34.7 -FilterEvents(SDL_Event * event)
    34.8 +FilterEvents(void *userdata, SDL_Event * event)
    34.9  {
   34.10      static int reallyquit = 0;
   34.11  
   34.12 @@ -296,7 +296,7 @@
   34.13      SDL_EnableUNICODE(1);
   34.14  
   34.15      /* Set an event filter that discards everything but QUIT */
   34.16 -    SDL_SetEventFilter(FilterEvents);
   34.17 +    SDL_SetEventFilter(FilterEvents, NULL);
   34.18  
   34.19      /* Create the event handling threads */
   34.20      mouse_thread = SDL_CreateThread(HandleMouse, NULL);