Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11window.c @ 2324:3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
author | Bob Pendleton <bob@pendleton.com> |
---|---|
date | Fri, 07 Mar 2008 17:20:37 +0000 |
parents | 4ac07ae446d3 |
children | c7bcf84ba1b9 |
comparison
equal
deleted
inserted
replaced
2323:4ac07ae446d3 | 2324:3202e4826c57 |
---|---|
32 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) | 32 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) |
33 { | 33 { |
34 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; | 34 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
35 SDL_WindowData *data; | 35 SDL_WindowData *data; |
36 int numwindows = videodata->numwindows; | 36 int numwindows = videodata->numwindows; |
37 int windowlistlength = videodata->windowlistlength; | |
37 SDL_WindowData **windowlist = videodata->windowlist; | 38 SDL_WindowData **windowlist = videodata->windowlist; |
38 int i; | |
39 int index; | 39 int index; |
40 | 40 |
41 /* Allocate the window data */ | 41 /* Allocate the window data */ |
42 data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); | 42 data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); |
43 if (!data) { | 43 if (!data) { |
57 #endif | 57 #endif |
58 data->created = created; | 58 data->created = created; |
59 data->videodata = videodata; | 59 data->videodata = videodata; |
60 | 60 |
61 /* Associate the data with the window */ | 61 /* Associate the data with the window */ |
62 index = -1; | 62 |
63 if (windowlist) { | 63 if (numwindows < windowlistlength) { |
64 for (i = 0; i < numwindows; ++i) { | 64 windowlist[numwindows] = data; |
65 if (windowlist[i] == NULL) { | 65 videodata->numwindows++; |
66 index = i; | |
67 break; | |
68 } | |
69 } | |
70 } | |
71 | |
72 if (index >= 0) { | |
73 windowlist[index] = data; | |
74 } else { | 66 } else { |
75 windowlist = | 67 windowlist = |
76 (SDL_WindowData **) SDL_realloc(windowlist, | 68 (SDL_WindowData **) SDL_realloc(windowlist, |
77 (numwindows + 1) * sizeof(*windowlist)); | 69 (numwindows + |
78 if (!windowlist) { | 70 1) * sizeof(*windowlist)); |
79 SDL_OutOfMemory(); | 71 if (!windowlist) { |
80 SDL_free(data); | 72 SDL_OutOfMemory(); |
81 return -1; | 73 SDL_free(data); |
82 } | 74 return -1; |
83 windowlist[numwindows++] = data; | 75 } |
84 videodata->numwindows = numwindows; | 76 windowlist[numwindows] = data; |
85 videodata->windowlist = windowlist; | 77 videodata->numwindows++; |
78 videodata->windowlistlength++; | |
79 videodata->windowlist = windowlist; | |
86 } | 80 } |
87 | 81 |
88 /* Fill in the SDL window with the window data */ | 82 /* Fill in the SDL window with the window data */ |
89 { | 83 { |
90 XWindowAttributes attrib; | 84 XWindowAttributes attrib; |
492 } | 486 } |
493 return 0; | 487 return 0; |
494 } | 488 } |
495 | 489 |
496 int | 490 int |
497 X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) | 491 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) |
498 { | 492 { |
499 Window w = (Window) data; | 493 Window w = (Window) data; |
500 | 494 |
501 /* FIXME: Query the title from the existing window */ | 495 /* FIXME: Query the title from the existing window */ |
502 | 496 |
663 int numwindows = videodata->numwindows; | 657 int numwindows = videodata->numwindows; |
664 SDL_WindowData **windowlist = videodata->windowlist; | 658 SDL_WindowData **windowlist = videodata->windowlist; |
665 int i; | 659 int i; |
666 | 660 |
667 if (windowlist) { | 661 if (windowlist) { |
668 for (i = 0; i < numwindows; ++i) { | 662 for (i = 0; i < numwindows; ++i) { |
669 if (windowlist[i] && | 663 if (windowlist[i] && (windowlist[i]->windowID == window->id)) { |
670 (windowlist[i]->windowID == window->id)) { | 664 windowlist[i] = windowlist[numwindows - 1]; |
671 windowlist[i] = NULL; | 665 windowlist[numwindows - 1] = NULL; |
672 break; | 666 videodata->numwindows--; |
667 break; | |
668 } | |
673 } | 669 } |
674 } | |
675 } | 670 } |
676 #ifdef SDL_VIDEO_OPENGL_GLX | 671 #ifdef SDL_VIDEO_OPENGL_GLX |
677 if (window->flags & SDL_WINDOW_OPENGL) { | 672 if (window->flags & SDL_WINDOW_OPENGL) { |
678 X11_GL_Shutdown(_this); | 673 X11_GL_Shutdown(_this); |
679 } | 674 } |