src/video/wincommon/SDL_syswm.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/video/wincommon/SDL_syswm.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/video/wincommon/SDL_syswm.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -43,20 +43,20 @@
     1.4  
     1.5  #ifdef _WIN32_WCE
     1.6  
     1.7 -BOOL (WINAPI * CoreCatchInput) (int flag) = NULL;
     1.8 +BOOL(WINAPI * CoreCatchInput) (int flag) = NULL;
     1.9  int input_catched = 0;
    1.10  HINSTANCE coredll = NULL;
    1.11  
    1.12  // the same API call that gx.dll does to catch the input
    1.13  void
    1.14 -LoadInputCatchFunc ()
    1.15 +LoadInputCatchFunc()
    1.16  {
    1.17 -    coredll = SDL_LoadObject ("coredll.dll");
    1.18 +    coredll = SDL_LoadObject("coredll.dll");
    1.19      if (coredll) {
    1.20          CoreCatchInput =
    1.21 -            (int (WINAPI *) (int)) GetProcAddress (coredll,
    1.22 -                                                   (const unsigned short *)
    1.23 -                                                   1453);
    1.24 +            (int (WINAPI *) (int)) GetProcAddress(coredll,
    1.25 +                                                  (const unsigned short *)
    1.26 +                                                  1453);
    1.27      }
    1.28  }
    1.29  
    1.30 @@ -70,7 +70,7 @@
    1.31     then inverted and passed to Win32.
    1.32  */
    1.33  void
    1.34 -WIN_SetWMIcon (_THIS, SDL_Surface * icon, Uint8 * mask)
    1.35 +WIN_SetWMIcon(_THIS, SDL_Surface * icon, Uint8 * mask)
    1.36  {
    1.37  #ifdef DISABLE_ICON_SUPPORT
    1.38      return;
    1.39 @@ -120,15 +120,15 @@
    1.40      mask_pitch = ((icon->w + 7) / 8);
    1.41      icon_plen = icon->h * icon_pitch;
    1.42      icon_mlen = icon->h * mask_pitch;
    1.43 -    icon_len = sizeof (*icon_win32) + icon_plen + icon_mlen;
    1.44 -    icon_win32 = (struct Win32Icon *) SDL_stack_alloc (Uint8, icon_len);
    1.45 +    icon_len = sizeof(*icon_win32) + icon_plen + icon_mlen;
    1.46 +    icon_win32 = (struct Win32Icon *) SDL_stack_alloc(Uint8, icon_len);
    1.47      if (icon_win32 == NULL) {
    1.48          return;
    1.49      }
    1.50 -    SDL_memset (icon_win32, 0, icon_len);
    1.51 +    SDL_memset(icon_win32, 0, icon_len);
    1.52  
    1.53      /* Set the basic BMP parameters */
    1.54 -    icon_win32->biSize = sizeof (*icon_win32) - sizeof (icon_win32->biColors);
    1.55 +    icon_win32->biSize = sizeof(*icon_win32) - sizeof(icon_win32->biColors);
    1.56      icon_win32->biWidth = icon->w;
    1.57      icon_win32->biHeight = icon->h * 2;
    1.58      icon_win32->biPlanes = 1;
    1.59 @@ -136,26 +136,26 @@
    1.60      icon_win32->biSizeImage = icon_plen + icon_mlen;
    1.61  
    1.62      /* Allocate a standard 256 color icon surface */
    1.63 -    icon_256 = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h,
    1.64 -                                     icon_win32->biBitCount, 0, 0, 0, 0);
    1.65 +    icon_256 = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
    1.66 +                                    icon_win32->biBitCount, 0, 0, 0, 0);
    1.67      if (icon_256 == NULL) {
    1.68 -        SDL_stack_free (icon_win32);
    1.69 +        SDL_stack_free(icon_win32);
    1.70          return;
    1.71      }
    1.72      pal_256 = icon_256->format->palette;
    1.73      if (icon->format->palette &&
    1.74          (icon->format->BitsPerPixel == icon_256->format->BitsPerPixel)) {
    1.75          Uint8 black;
    1.76 -        SDL_memcpy (pal_256->colors, icon->format->palette->colors,
    1.77 -                    pal_256->ncolors * sizeof (SDL_Color));
    1.78 +        SDL_memcpy(pal_256->colors, icon->format->palette->colors,
    1.79 +                   pal_256->ncolors * sizeof(SDL_Color));
    1.80          /* Make sure that 0 is black! */
    1.81 -        black = SDL_FindColor (pal_256, 0x00, 0x00, 0x00);
    1.82 +        black = SDL_FindColor(pal_256, 0x00, 0x00, 0x00);
    1.83          pal_256->colors[black] = pal_256->colors[0];
    1.84          pal_256->colors[0].r = 0x00;
    1.85          pal_256->colors[0].g = 0x00;
    1.86          pal_256->colors[0].b = 0x00;
    1.87      } else {
    1.88 -        SDL_DitherColors (pal_256->colors, icon_256->format->BitsPerPixel);
    1.89 +        SDL_DitherColors(pal_256->colors, icon_256->format->BitsPerPixel);
    1.90      }
    1.91  
    1.92      /* Now copy color data to the icon BMP */
    1.93 @@ -173,23 +173,23 @@
    1.94      bounds.y = 0;
    1.95      bounds.w = icon->w;
    1.96      bounds.h = icon->h;
    1.97 -    if (SDL_LowerBlit (icon, &bounds, icon_256, &bounds) < 0) {
    1.98 -        SDL_stack_free (icon_win32);
    1.99 -        SDL_FreeSurface (icon_256);
   1.100 +    if (SDL_LowerBlit(icon, &bounds, icon_256, &bounds) < 0) {
   1.101 +        SDL_stack_free(icon_win32);
   1.102 +        SDL_FreeSurface(icon_256);
   1.103          return;
   1.104      }
   1.105  
   1.106      /* Copy pixels upside-down to icon BMP, masked with the icon mask */
   1.107 -    if (SDL_MUSTLOCK (icon_256) || (icon_256->pitch != icon_pitch)) {
   1.108 -        SDL_stack_free (icon_win32);
   1.109 -        SDL_FreeSurface (icon_256);
   1.110 -        SDL_SetError ("Warning: Unexpected icon_256 characteristics");
   1.111 +    if (SDL_MUSTLOCK(icon_256) || (icon_256->pitch != icon_pitch)) {
   1.112 +        SDL_stack_free(icon_win32);
   1.113 +        SDL_FreeSurface(icon_256);
   1.114 +        SDL_SetError("Warning: Unexpected icon_256 characteristics");
   1.115          return;
   1.116      }
   1.117      pdata = (Uint8 *) icon_256->pixels;
   1.118      mdata = mask;
   1.119      pwin32 =
   1.120 -        (Uint8 *) icon_win32 + sizeof (*icon_win32) + icon_plen - icon_pitch;
   1.121 +        (Uint8 *) icon_win32 + sizeof(*icon_win32) + icon_plen - icon_pitch;
   1.122      skip = icon_pitch - icon->w;
   1.123      for (row = 0; row < icon->h; ++row) {
   1.124          for (col = 0; col < icon->w; ++col) {
   1.125 @@ -207,12 +207,12 @@
   1.126          pwin32 += skip;
   1.127          pwin32 -= 2 * icon_pitch;
   1.128      }
   1.129 -    SDL_FreeSurface (icon_256);
   1.130 +    SDL_FreeSurface(icon_256);
   1.131  
   1.132      /* Copy mask inverted and upside-down to icon BMP */
   1.133      mdata = mask;
   1.134      mwin32 = (Uint8 *) icon_win32
   1.135 -        + sizeof (*icon_win32) + icon_plen + icon_mlen - mask_pitch;
   1.136 +        + sizeof(*icon_win32) + icon_plen + icon_mlen - mask_pitch;
   1.137      for (row = 0; row < icon->h; ++row) {
   1.138          for (col = 0; col < mask_pitch; ++col) {
   1.139              *mwin32++ = ~*mdata++;
   1.140 @@ -221,68 +221,68 @@
   1.141      }
   1.142  
   1.143      /* Finally, create the icon handle and set the window icon */
   1.144 -    screen_icn = CreateIconFromResourceEx ((Uint8 *) icon_win32, icon_len,
   1.145 -                                           TRUE, 0x00030000, icon->w, icon->h,
   1.146 -                                           LR_DEFAULTCOLOR);
   1.147 +    screen_icn = CreateIconFromResourceEx((Uint8 *) icon_win32, icon_len,
   1.148 +                                          TRUE, 0x00030000, icon->w, icon->h,
   1.149 +                                          LR_DEFAULTCOLOR);
   1.150      if (screen_icn == NULL) {
   1.151 -        SDL_SetError ("Couldn't create Win32 icon handle");
   1.152 +        SDL_SetError("Couldn't create Win32 icon handle");
   1.153      } else {
   1.154 -        SetClassLongPtr (SDL_Window, GCLP_HICON, (LONG_PTR) screen_icn);
   1.155 +        SetClassLongPtr(SDL_Window, GCLP_HICON, (LONG_PTR) screen_icn);
   1.156      }
   1.157 -    SDL_stack_free (icon_win32);
   1.158 +    SDL_stack_free(icon_win32);
   1.159  #endif /* DISABLE_ICON_SUPPORT */
   1.160  }
   1.161  
   1.162  void
   1.163 -WIN_SetWMCaption (_THIS, const char *title, const char *icon)
   1.164 +WIN_SetWMCaption(_THIS, const char *title, const char *icon)
   1.165  {
   1.166  #ifdef _WIN32_WCE
   1.167      /* WinCE uses the UNICODE version */
   1.168 -    LPWSTR lpszW = SDL_iconv_utf8_ucs2 ((char *) title);
   1.169 -    SetWindowText (SDL_Window, lpszW);
   1.170 -    SDL_free (lpszW);
   1.171 +    LPWSTR lpszW = SDL_iconv_utf8_ucs2((char *) title);
   1.172 +    SetWindowText(SDL_Window, lpszW);
   1.173 +    SDL_free(lpszW);
   1.174  #else
   1.175 -    char *lpsz = SDL_iconv_utf8_latin1 ((char *) title);
   1.176 -    SetWindowText (SDL_Window, lpsz);
   1.177 -    SDL_free (lpsz);
   1.178 +    char *lpsz = SDL_iconv_utf8_latin1((char *) title);
   1.179 +    SetWindowText(SDL_Window, lpsz);
   1.180 +    SDL_free(lpsz);
   1.181  #endif
   1.182  }
   1.183  
   1.184  int
   1.185 -WIN_IconifyWindow (_THIS)
   1.186 +WIN_IconifyWindow(_THIS)
   1.187  {
   1.188 -    ShowWindow (SDL_Window, SW_MINIMIZE);
   1.189 +    ShowWindow(SDL_Window, SW_MINIMIZE);
   1.190      return (1);
   1.191  }
   1.192  
   1.193  SDL_GrabMode
   1.194 -WIN_GrabInput (_THIS, SDL_GrabMode mode)
   1.195 +WIN_GrabInput(_THIS, SDL_GrabMode mode)
   1.196  {
   1.197      if (mode == SDL_GRAB_OFF) {
   1.198 -        ClipCursor (NULL);
   1.199 +        ClipCursor(NULL);
   1.200          if (!(SDL_cursorstate & CURSOR_VISIBLE)) {
   1.201              /*      RJR: March 28, 2000
   1.202                 must be leaving relative mode, move mouse from
   1.203                 center of window to where it belongs ... */
   1.204              POINT pt;
   1.205              int x, y;
   1.206 -            SDL_GetMouseState (&x, &y);
   1.207 +            SDL_GetMouseState(&x, &y);
   1.208              pt.x = x;
   1.209              pt.y = y;
   1.210 -            ClientToScreen (SDL_Window, &pt);
   1.211 -            SetCursorPos (pt.x, pt.y);
   1.212 +            ClientToScreen(SDL_Window, &pt);
   1.213 +            SetCursorPos(pt.x, pt.y);
   1.214          }
   1.215  #ifdef _WIN32_WCE
   1.216          if (input_catched) {
   1.217              if (!CoreCatchInput)
   1.218 -                LoadInputCatchFunc ();
   1.219 +                LoadInputCatchFunc();
   1.220  
   1.221              if (CoreCatchInput)
   1.222 -                CoreCatchInput (0);
   1.223 +                CoreCatchInput(0);
   1.224          }
   1.225  #endif
   1.226      } else {
   1.227 -        ClipCursor (&SDL_bounds);
   1.228 +        ClipCursor(&SDL_bounds);
   1.229          if (!(SDL_cursorstate & CURSOR_VISIBLE)) {
   1.230              /*      RJR: March 28, 2000
   1.231                 must be entering relative mode, get ready by
   1.232 @@ -290,16 +290,16 @@
   1.233              POINT pt;
   1.234              pt.x = (SDL_VideoSurface->w / 2);
   1.235              pt.y = (SDL_VideoSurface->h / 2);
   1.236 -            ClientToScreen (SDL_Window, &pt);
   1.237 -            SetCursorPos (pt.x, pt.y);
   1.238 +            ClientToScreen(SDL_Window, &pt);
   1.239 +            SetCursorPos(pt.x, pt.y);
   1.240          }
   1.241  #ifdef _WIN32_WCE
   1.242          if (!input_catched) {
   1.243              if (!CoreCatchInput)
   1.244 -                LoadInputCatchFunc ();
   1.245 +                LoadInputCatchFunc();
   1.246  
   1.247              if (CoreCatchInput)
   1.248 -                CoreCatchInput (1);
   1.249 +                CoreCatchInput(1);
   1.250          }
   1.251  #endif
   1.252      }
   1.253 @@ -310,14 +310,13 @@
   1.254     Otherwise, in case of a version mismatch, it returns -1.
   1.255  */
   1.256  int
   1.257 -WIN_GetWMInfo (_THIS, SDL_SysWMinfo * info)
   1.258 +WIN_GetWMInfo(_THIS, SDL_SysWMinfo * info)
   1.259  {
   1.260      if (info->version.major <= SDL_MAJOR_VERSION) {
   1.261          info->window = SDL_Window;
   1.262 -        if (SDL_VERSIONNUM (info->version.major,
   1.263 -                            info->version.minor,
   1.264 -                            info->version.patch) >=
   1.265 -            SDL_VERSIONNUM (1, 2, 5)) {
   1.266 +        if (SDL_VERSIONNUM(info->version.major,
   1.267 +                           info->version.minor,
   1.268 +                           info->version.patch) >= SDL_VERSIONNUM(1, 2, 5)) {
   1.269  #if SDL_VIDEO_OPENGL
   1.270              info->hglrc = GL_hrc;
   1.271  #else
   1.272 @@ -326,8 +325,8 @@
   1.273          }
   1.274          return (1);
   1.275      } else {
   1.276 -        SDL_SetError ("Application not compiled with SDL %d.%d\n",
   1.277 -                      SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   1.278 +        SDL_SetError("Application not compiled with SDL %d.%d\n",
   1.279 +                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   1.280          return (-1);
   1.281      }
   1.282  }