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)
display->windows = NULL;
}
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);
......
......@@ -36,7 +36,7 @@
#define REPEATED_KEYMASK (1<<30)
#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... */
#ifndef WM_XBUTTONDOWN
......@@ -53,7 +53,7 @@ static WPARAM
RemapVKEY(WPARAM wParam, LPARAM lParam)
{
int i;
BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF);
/* Windows remaps alphabetic keys based on current layout.
We try to provide USB scancodes, so undo this mapping.
......@@ -72,7 +72,7 @@ RemapVKEY(WPARAM wParam, LPARAM lParam)
/* Keypad keys are a little trickier, we always scan for them. */
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
if (scancode == keypad_scancodes[i]) {
wParam = VK_NUMPAD0+i;
wParam = VK_NUMPAD0 + i;
break;
}
}
......
......@@ -53,18 +53,21 @@ WIN_InitKeyboard(_THIS)
int i;
/* Make sure the alpha scancodes are correct. T isn't usually remapped */
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");
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");
for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
alpha_scancodes[i] = MapVirtualKey('A'+i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, alpha_scancodes[i]);
alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, alpha_scancodes[i]);
}
}
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) {
keypad_scancodes[i] = MapVirtualKey(VK_NUMPAD0+i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, keypad_scancodes[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)
/* Alphabetic keys are handled specially, since Windows remaps them */
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;
} else {
keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
......
......@@ -51,15 +51,14 @@ X11_DispatchEvent(_THIS)
}
data = NULL;
if (videodata &&
videodata->windowlist) {
for (i = 0; i < videodata->numwindows; ++i) {
if ((videodata->windowlist[i] != NULL) &&
(videodata->windowlist[i]->window == xevent.xany.window)) {
data = videodata->windowlist[i];
break;
if (videodata && videodata->windowlist) {
for (i = 0; i < videodata->numwindows; ++i) {
if ((videodata->windowlist[i] != NULL) &&
(videodata->windowlist[i]->window == xevent.xany.window)) {
data = videodata->windowlist[i];
break;
}
}
}
}
if (!data) {
return;
......
......@@ -281,19 +281,19 @@ int
X11_GL_Initialize(_THIS)
{
if (X11_GL_InitializeMemory(_this) < 0) {
return -1;
}
++_this->gl_data->initialized;
if (X11_GL_InitializeMemory(_this) < 0) {
return -1;
}
++_this->gl_data->initialized;
if (X11_GL_LoadLibrary(_this, NULL) < 0) {
return -1;
}
if (X11_GL_LoadLibrary(_this, NULL) < 0) {
return -1;
}
/* Initialize extensions */
X11_GL_InitExtensions(_this);
/* Initialize extensions */
X11_GL_InitExtensions(_this);
return 0;
return 0;
}
void
......@@ -523,6 +523,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context)
GLXContext glx_context = (GLXContext) context;
_this->gl_data->glXDestroyContext(display, glx_context);
XSync(display, False);
}
#endif /* SDL_VIDEO_OPENGL_GLX */
......
......@@ -101,6 +101,7 @@ X11_DeleteDevice(SDL_VideoDevice * device)
if (data->display) {
XCloseDisplay(data->display);
}
SDL_free(data->windowlist);
SDL_free(device->driverdata);
SDL_free(device);
......
......@@ -67,6 +67,7 @@ typedef struct SDL_VideoData
BOOL dpms_enabled;
int numwindows;
SDL_WindowData **windowlist;
int windowlistlength;
int mouse;
int keyboard;
Atom WM_DELETE_WINDOW;
......
......@@ -34,8 +34,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data;
int numwindows = videodata->numwindows;
int windowlistlength = videodata->windowlistlength;
SDL_WindowData **windowlist = videodata->windowlist;
int i;
int index;
/* Allocate the window data */
......@@ -59,30 +59,24 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
data->videodata = videodata;
/* 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) {
windowlist[index] = data;
if (numwindows < windowlistlength) {
windowlist[numwindows] = data;
videodata->numwindows++;
} else {
windowlist =
(SDL_WindowData **) SDL_realloc(windowlist,
(numwindows + 1) * sizeof(*windowlist));
if (!windowlist) {
SDL_OutOfMemory();
SDL_free(data);
return -1;
}
windowlist[numwindows++] = data;
videodata->numwindows = numwindows;
videodata->windowlist = windowlist;
windowlist =
(SDL_WindowData **) SDL_realloc(windowlist,
(numwindows +
1) * sizeof(*windowlist));
if (!windowlist) {
SDL_OutOfMemory();
SDL_free(data);
return -1;
}
windowlist[numwindows] = data;
videodata->numwindows++;
videodata->windowlistlength++;
videodata->windowlist = windowlist;
}
/* Fill in the SDL window with the window data */
......@@ -494,7 +488,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}
int
X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
Window w = (Window) data;
......@@ -665,13 +659,14 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
int i;
if (windowlist) {
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] &&
(windowlist[i]->windowID == window->id)) {
windowlist[i] = NULL;
break;
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] && (windowlist[i]->windowID == window->id)) {
windowlist[i] = windowlist[numwindows - 1];
windowlist[numwindows - 1] = NULL;
videodata->numwindows--;
break;
}
}
}
}
#ifdef SDL_VIDEO_OPENGL_GLX
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