Commit c19af725 authored by Bob Pendleton's avatar Bob Pendleton

more valgrind errors fixed. Plus I ran make indent which changed a few files.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402741
parent b315d537
...@@ -2190,6 +2190,11 @@ SDL_VideoQuit(void) ...@@ -2190,6 +2190,11 @@ SDL_VideoQuit(void)
display->windows = NULL; display->windows = NULL;
} }
display->num_windows = 0; display->num_windows = 0;
if (display->render_drivers) {
SDL_free(display->render_drivers);
display->render_drivers = NULL;
}
display->num_render_drivers = 0;
} }
_this->VideoQuit(_this); _this->VideoQuit(_this);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define REPEATED_KEYMASK (1<<30) #define REPEATED_KEYMASK (1<<30)
#define EXTENDED_KEYMASK (1<<24) #define EXTENDED_KEYMASK (1<<24)
#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
#ifndef WM_XBUTTONDOWN #ifndef WM_XBUTTONDOWN
...@@ -53,7 +53,7 @@ static WPARAM ...@@ -53,7 +53,7 @@ static WPARAM
RemapVKEY(WPARAM wParam, LPARAM lParam) RemapVKEY(WPARAM wParam, LPARAM lParam)
{ {
int i; int i;
BYTE scancode = (BYTE)((lParam >> 16) & 0xFF); BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF);
/* Windows remaps alphabetic keys based on current layout. /* Windows remaps alphabetic keys based on current layout.
We try to provide USB scancodes, so undo this mapping. We try to provide USB scancodes, so undo this mapping.
...@@ -72,7 +72,7 @@ RemapVKEY(WPARAM wParam, LPARAM lParam) ...@@ -72,7 +72,7 @@ RemapVKEY(WPARAM wParam, LPARAM lParam)
/* Keypad keys are a little trickier, we always scan for them. */ /* Keypad keys are a little trickier, we always scan for them. */
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
if (scancode == keypad_scancodes[i]) { if (scancode == keypad_scancodes[i]) {
wParam = VK_NUMPAD0+i; wParam = VK_NUMPAD0 + i;
break; break;
} }
} }
......
...@@ -53,18 +53,21 @@ WIN_InitKeyboard(_THIS) ...@@ -53,18 +53,21 @@ WIN_InitKeyboard(_THIS)
int i; int i;
/* Make sure the alpha scancodes are correct. T isn't usually remapped */ /* Make sure the alpha scancodes are correct. T isn't usually remapped */
if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T'-'A']) { if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
printf("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n"); printf
("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) { for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
alpha_scancodes[i] = MapVirtualKey('A'+i, MAPVK_VK_TO_VSC); alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, alpha_scancodes[i]); printf("%d = %d\n", i, alpha_scancodes[i]);
} }
} }
if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) { if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) {
printf("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n"); printf
("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) { for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
keypad_scancodes[i] = MapVirtualKey(VK_NUMPAD0+i, MAPVK_VK_TO_VSC); keypad_scancodes[i] =
printf("%d = %d\n", i, keypad_scancodes[i]); MapVirtualKey(VK_NUMPAD0 + i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, keypad_scancodes[i]);
} }
} }
...@@ -99,7 +102,7 @@ WIN_UpdateKeymap(int keyboard) ...@@ -99,7 +102,7 @@ WIN_UpdateKeymap(int keyboard)
/* Alphabetic keys are handled specially, since Windows remaps them */ /* Alphabetic keys are handled specially, since Windows remaps them */
if (i >= 'A' && i <= 'Z') { if (i >= 'A' && i <= 'Z') {
BYTE vsc = alpha_scancodes[i-'A']; BYTE vsc = alpha_scancodes[i - 'A'];
keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20; keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
} else { } else {
keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF); keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
......
...@@ -51,15 +51,14 @@ X11_DispatchEvent(_THIS) ...@@ -51,15 +51,14 @@ X11_DispatchEvent(_THIS)
} }
data = NULL; data = NULL;
if (videodata && if (videodata && videodata->windowlist) {
videodata->windowlist) { for (i = 0; i < videodata->numwindows; ++i) {
for (i = 0; i < videodata->numwindows; ++i) { if ((videodata->windowlist[i] != NULL) &&
if ((videodata->windowlist[i] != NULL) && (videodata->windowlist[i]->window == xevent.xany.window)) {
(videodata->windowlist[i]->window == xevent.xany.window)) { data = videodata->windowlist[i];
data = videodata->windowlist[i]; break;
break; }
} }
}
} }
if (!data) { if (!data) {
return; return;
......
...@@ -281,19 +281,19 @@ int ...@@ -281,19 +281,19 @@ int
X11_GL_Initialize(_THIS) X11_GL_Initialize(_THIS)
{ {
if (X11_GL_InitializeMemory(_this) < 0) { if (X11_GL_InitializeMemory(_this) < 0) {
return -1; return -1;
} }
++_this->gl_data->initialized; ++_this->gl_data->initialized;
if (X11_GL_LoadLibrary(_this, NULL) < 0) { if (X11_GL_LoadLibrary(_this, NULL) < 0) {
return -1; return -1;
} }
/* Initialize extensions */ /* Initialize extensions */
X11_GL_InitExtensions(_this); X11_GL_InitExtensions(_this);
return 0; return 0;
} }
void void
...@@ -523,6 +523,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context) ...@@ -523,6 +523,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context)
GLXContext glx_context = (GLXContext) context; GLXContext glx_context = (GLXContext) context;
_this->gl_data->glXDestroyContext(display, glx_context); _this->gl_data->glXDestroyContext(display, glx_context);
XSync(display, False);
} }
#endif /* SDL_VIDEO_OPENGL_GLX */ #endif /* SDL_VIDEO_OPENGL_GLX */
......
...@@ -101,6 +101,7 @@ X11_DeleteDevice(SDL_VideoDevice * device) ...@@ -101,6 +101,7 @@ X11_DeleteDevice(SDL_VideoDevice * device)
if (data->display) { if (data->display) {
XCloseDisplay(data->display); XCloseDisplay(data->display);
} }
SDL_free(data->windowlist);
SDL_free(device->driverdata); SDL_free(device->driverdata);
SDL_free(device); SDL_free(device);
......
...@@ -67,6 +67,7 @@ typedef struct SDL_VideoData ...@@ -67,6 +67,7 @@ typedef struct SDL_VideoData
BOOL dpms_enabled; BOOL dpms_enabled;
int numwindows; int numwindows;
SDL_WindowData **windowlist; SDL_WindowData **windowlist;
int windowlistlength;
int mouse; int mouse;
int keyboard; int keyboard;
Atom WM_DELETE_WINDOW; Atom WM_DELETE_WINDOW;
......
...@@ -34,8 +34,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) ...@@ -34,8 +34,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data; SDL_WindowData *data;
int numwindows = videodata->numwindows; int numwindows = videodata->numwindows;
int windowlistlength = videodata->windowlistlength;
SDL_WindowData **windowlist = videodata->windowlist; SDL_WindowData **windowlist = videodata->windowlist;
int i;
int index; int index;
/* Allocate the window data */ /* Allocate the window data */
...@@ -59,30 +59,24 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) ...@@ -59,30 +59,24 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
data->videodata = videodata; data->videodata = videodata;
/* Associate the data with the window */ /* Associate the data with the window */
index = -1;
if (windowlist) {
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] == NULL) {
index = i;
break;
}
}
}
if (index >= 0) { if (numwindows < windowlistlength) {
windowlist[index] = data; windowlist[numwindows] = data;
videodata->numwindows++;
} else { } else {
windowlist = windowlist =
(SDL_WindowData **) SDL_realloc(windowlist, (SDL_WindowData **) SDL_realloc(windowlist,
(numwindows + 1) * sizeof(*windowlist)); (numwindows +
if (!windowlist) { 1) * sizeof(*windowlist));
SDL_OutOfMemory(); if (!windowlist) {
SDL_free(data); SDL_OutOfMemory();
return -1; SDL_free(data);
} return -1;
windowlist[numwindows++] = data; }
videodata->numwindows = numwindows; windowlist[numwindows] = data;
videodata->windowlist = windowlist; videodata->numwindows++;
videodata->windowlistlength++;
videodata->windowlist = windowlist;
} }
/* Fill in the SDL window with the window data */ /* Fill in the SDL window with the window data */
...@@ -494,7 +488,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) ...@@ -494,7 +488,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
} }
int int
X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{ {
Window w = (Window) data; Window w = (Window) data;
...@@ -665,13 +659,14 @@ X11_DestroyWindow(_THIS, SDL_Window * window) ...@@ -665,13 +659,14 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
int i; int i;
if (windowlist) { if (windowlist) {
for (i = 0; i < numwindows; ++i) { for (i = 0; i < numwindows; ++i) {
if (windowlist[i] && if (windowlist[i] && (windowlist[i]->windowID == window->id)) {
(windowlist[i]->windowID == window->id)) { windowlist[i] = windowlist[numwindows - 1];
windowlist[i] = NULL; windowlist[numwindows - 1] = NULL;
break; videodata->numwindows--;
break;
}
} }
}
} }
#ifdef SDL_VIDEO_OPENGL_GLX #ifdef SDL_VIDEO_OPENGL_GLX
if (window->flags & SDL_WINDOW_OPENGL) { if (window->flags & SDL_WINDOW_OPENGL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment