~ubuntu-branches/ubuntu/karmic/libsdl1.2/karmic

« back to all changes in this revision

Viewing changes to src/video/wincommon/SDL_syswm.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2008-01-05 14:10:45 UTC
  • mto: (2.1.3 lenny)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080105141045-mjdg2rp09mamme4a
Tags: upstream-1.2.13
ImportĀ upstreamĀ versionĀ 1.2.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
        SetWindowText(SDL_Window, lpszW);
218
218
        SDL_free(lpszW);
219
219
#else
220
 
        /*
221
 
         * Try loading SetWindowTextW from kernel32.dll first, and if it exists,
222
 
         *  pass the UCS-2 string to it. If it doesn't, use
223
 
         *  WideCharToMultiByte(CP_ACP) and hope that the codepage can support the
224
 
         *  string data in question. This lets us keep binary compatibility with
225
 
         *  Win95/98/ME but still use saner Unicode on NT-based Windows.
226
 
         */
227
 
        static int tried_loading = 0;
228
 
        static PtrSetWindowTextW swtw = NULL;
229
220
        Uint16 *lpsz = SDL_iconv_utf8_ucs2(title);
230
 
        if (!tried_loading) {
231
 
                HMODULE dll = LoadLibrary("user32.dll");
232
 
                if (dll != NULL) {
233
 
                        swtw = (PtrSetWindowTextW) GetProcAddress(dll, "SetWindowTextW");
234
 
                        if (swtw == NULL) {
235
 
                                FreeLibrary(dll);
236
 
                        }
237
 
                }
238
 
                tried_loading = 1;
239
 
        }
240
 
 
241
 
        if (swtw != NULL) {
242
 
                swtw(SDL_Window, lpsz);
243
 
        } else {
244
 
                size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
245
 
                char *cvt = SDL_malloc(len + 1);
246
 
                WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
247
 
                SetWindowText(SDL_Window, cvt);
248
 
                SDL_free(cvt);
249
 
        }
 
221
        size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
 
222
        char *cvt = SDL_stack_alloc(char, len + 1);
 
223
        WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
 
224
        SetWindowText(SDL_Window, cvt);
 
225
        SDL_stack_free(cvt);
250
226
        SDL_free(lpsz);
251
227
#endif
252
228
}