comparison src/video/win32/SDL_win32window.c @ 1951:7177581dc9fa

Initial work on X11 window code in.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 27 Jul 2006 06:53:23 +0000
parents 83420da906a5
children 420716272158
comparison
equal deleted inserted replaced
1950:a344e42bce3b 1951:7177581dc9fa
29 /* This is included after SDL_win32video.h, which includes windows.h */ 29 /* This is included after SDL_win32video.h, which includes windows.h */
30 #include "SDL_syswm.h" 30 #include "SDL_syswm.h"
31 31
32 32
33 static int 33 static int
34 SetupWindowData(SDL_Window * window, HWND hwnd, BOOL created) 34 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
35 { 35 {
36 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
36 SDL_WindowData *data; 37 SDL_WindowData *data;
37 38
38 /* Allocate the window data */ 39 /* Allocate the window data */
39 data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); 40 data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
40 if (!data) { 41 if (!data) {
44 data->windowID = window->id; 45 data->windowID = window->id;
45 data->hwnd = hwnd; 46 data->hwnd = hwnd;
46 data->hdc = GetDC(hwnd); 47 data->hdc = GetDC(hwnd);
47 data->created = created; 48 data->created = created;
48 data->mouse_pressed = SDL_FALSE; 49 data->mouse_pressed = SDL_FALSE;
49 data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata; 50 data->videodata = videodata;
50 51
51 /* Associate the data with the window */ 52 /* Associate the data with the window */
52 if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { 53 if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
53 ReleaseDC(hwnd, data->hdc); 54 ReleaseDC(hwnd, data->hdc);
54 SDL_free(data); 55 SDL_free(data);
206 if (!hwnd) { 207 if (!hwnd) {
207 WIN_SetError("Couldn't create window"); 208 WIN_SetError("Couldn't create window");
208 return -1; 209 return -1;
209 } 210 }
210 211
211 if (SetupWindowData(window, hwnd, TRUE) < 0) { 212 if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
212 DestroyWindow(hwnd); 213 DestroyWindow(hwnd);
213 return -1; 214 return -1;
214 } 215 }
215 #ifdef SDL_VIDEO_OPENGL 216 #ifdef SDL_VIDEO_OPENGL
216 if (window->flags & SDL_WINDOW_OPENGL) { 217 if (window->flags & SDL_WINDOW_OPENGL) {
243 } 244 }
244 if (title) { 245 if (title) {
245 SDL_stack_free(title); 246 SDL_stack_free(title);
246 } 247 }
247 248
248 if (SetupWindowData(window, hwnd, FALSE) < 0) { 249 if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
249 return -1; 250 return -1;
250 } 251 }
251 return 0; 252 return 0;
252 } 253 }
253 254