src/video/win32/SDL_win32window.c
changeset 1913 83420da906a5
parent 1895 c121d94672cb
child 1951 7177581dc9fa
equal deleted inserted replaced
1912:8d384b647307 1913:83420da906a5
    41         SDL_OutOfMemory();
    41         SDL_OutOfMemory();
    42         return -1;
    42         return -1;
    43     }
    43     }
    44     data->windowID = window->id;
    44     data->windowID = window->id;
    45     data->hwnd = hwnd;
    45     data->hwnd = hwnd;
       
    46     data->hdc = GetDC(hwnd);
    46     data->created = created;
    47     data->created = created;
    47     data->mouse_pressed = SDL_FALSE;
    48     data->mouse_pressed = SDL_FALSE;
    48     data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
    49     data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
    49 
    50 
    50     /* Associate the data with the window */
    51     /* Associate the data with the window */
    51     if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
    52     if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
       
    53         ReleaseDC(hwnd, data->hdc);
    52         SDL_free(data);
    54         SDL_free(data);
    53         WIN_SetError("SetProp() failed");
    55         WIN_SetError("SetProp() failed");
    54         return -1;
    56         return -1;
    55     }
    57     }
    56 
    58 
   131 {
   133 {
   132     HWND hwnd;
   134     HWND hwnd;
   133     LPTSTR title = NULL;
   135     LPTSTR title = NULL;
   134     HWND top;
   136     HWND top;
   135     RECT rect;
   137     RECT rect;
   136     DWORD style = 0;
   138     DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
   137     int x, y;
   139     int x, y;
   138     int w, h;
   140     int w, h;
   139 
   141 
   140     if (window->title) {
   142     if (window->title) {
   141         title = WIN_UTF8ToString(window->title);
   143         title = WIN_UTF8ToString(window->title);
   208 
   210 
   209     if (SetupWindowData(window, hwnd, TRUE) < 0) {
   211     if (SetupWindowData(window, hwnd, TRUE) < 0) {
   210         DestroyWindow(hwnd);
   212         DestroyWindow(hwnd);
   211         return -1;
   213         return -1;
   212     }
   214     }
       
   215 #ifdef SDL_VIDEO_OPENGL
       
   216     if (window->flags & SDL_WINDOW_OPENGL) {
       
   217         if (WIN_GL_SetupWindow(_this, window) < 0) {
       
   218             WIN_DestroyWindow(_this, window);
       
   219             return -1;
       
   220         }
       
   221     }
       
   222 #endif
   213     return 0;
   223     return 0;
   214 }
   224 }
   215 
   225 
   216 int
   226 int
   217 WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   227 WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   406 WIN_DestroyWindow(_THIS, SDL_Window * window)
   416 WIN_DestroyWindow(_THIS, SDL_Window * window)
   407 {
   417 {
   408     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   418     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   409 
   419 
   410     if (data) {
   420     if (data) {
       
   421 #ifdef SDL_VIDEO_OPENGL
       
   422         if (window->flags & SDL_WINDOW_OPENGL) {
       
   423             WIN_GL_CleanupWindow(_this, window);
       
   424         }
       
   425 #endif
       
   426         ReleaseDC(data->hwnd, data->hdc);
   411         if (data->created) {
   427         if (data->created) {
   412             DestroyWindow(data->hwnd);
   428             DestroyWindow(data->hwnd);
   413         }
   429         }
   414         SDL_free(data);
   430         SDL_free(data);
   415     }
   431     }