From 93855ae6ab9ee74181adc76e147668d51acf960e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 27 Jan 2015 23:04:22 +0100 Subject: [PATCH] Fixed name of path drop list. --- include/GLFW/glfw3.h | 2 +- src/cocoa_window.m | 10 +++++----- src/input.c | 4 ++-- src/win32_window.c | 10 +++++----- src/x11_window.c | 24 ++++++++++++------------ tests/events.c | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 921421c2..7e141ce0 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -988,7 +988,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int); * * @param[in] window The window that received the event. * @param[in] count The number of dropped files. - * @param[in] names The UTF-8 encoded path names of the dropped files. + * @param[in] paths The UTF-8 encoded file and/or directory path names. * * @sa glfwSetDropCallback * diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 63efde2c..da20e32f 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -592,17 +592,17 @@ static int translateKey(unsigned int key) if (count) { NSEnumerator* e = [files objectEnumerator]; - char** names = calloc(count, sizeof(char*)); + char** paths = calloc(count, sizeof(char*)); int i; for (i = 0; i < count; i++) - names[i] = strdup([[e nextObject] UTF8String]); + paths[i] = strdup([[e nextObject] UTF8String]); - _glfwInputDrop(window, count, (const char**) names); + _glfwInputDrop(window, count, (const char**) paths); for (i = 0; i < count; i++) - free(names[i]); - free(names); + free(paths[i]); + free(paths); } return YES; diff --git a/src/input.c b/src/input.c index 74a715c9..78a71693 100644 --- a/src/input.c +++ b/src/input.c @@ -216,10 +216,10 @@ void _glfwInputCursorEnter(_GLFWwindow* window, int entered) window->callbacks.cursorEnter((GLFWwindow*) window, entered); } -void _glfwInputDrop(_GLFWwindow* window, int count, const char** names) +void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths) { if (window->callbacks.drop) - window->callbacks.drop((GLFWwindow*) window, count, names); + window->callbacks.drop((GLFWwindow*) window, count, paths); } diff --git a/src/win32_window.c b/src/win32_window.c index 176ed596..7da90d78 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -584,7 +584,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, int i; const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0); - char** names = calloc(count, sizeof(char*)); + char** paths = calloc(count, sizeof(char*)); // Move the mouse to the position of the drop DragQueryPoint(hDrop, &pt); @@ -596,16 +596,16 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WCHAR* buffer = calloc(length + 1, sizeof(WCHAR)); DragQueryFileW(hDrop, i, buffer, length + 1); - names[i] = _glfwCreateUTF8FromWideString(buffer); + paths[i] = _glfwCreateUTF8FromWideString(buffer); free(buffer); } - _glfwInputDrop(window, count, (const char**) names); + _glfwInputDrop(window, count, (const char**) paths); for (i = 0; i < count; i++) - free(names[i]); - free(names); + free(paths[i]); + free(paths); DragFinish(hDrop); return 0; diff --git a/src/x11_window.c b/src/x11_window.c index af73fdbd..3f584cdf 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -188,7 +188,7 @@ static void changeWindowState(_GLFWwindow* window, Atom state, int action) static char** parseUriList(char* text, int* count) { const char* prefix = "file://"; - char** names = NULL; + char** paths = NULL; char* line; *count = 0; @@ -205,27 +205,27 @@ static char** parseUriList(char* text, int* count) (*count)++; - char* name = calloc(strlen(line) + 1, 1); - names = realloc(names, *count * sizeof(char*)); - names[*count - 1] = name; + char* path = calloc(strlen(line) + 1, 1); + paths = realloc(paths, *count * sizeof(char*)); + paths[*count - 1] = path; while (*line) { if (line[0] == '%' && line[1] && line[2]) { const char digits[3] = { line[1], line[2], '\0' }; - *name = strtol(digits, NULL, 16); + *path = strtol(digits, NULL, 16); line += 2; } else - *name = *line; + *path = *line; - name++; + path++; line++; } } - return names; + return paths; } // Create the X11 window (and its colormap) @@ -1217,13 +1217,13 @@ static void processEvent(XEvent *event) if (result) { int i, count; - char** names = parseUriList(data, &count); + char** paths = parseUriList(data, &count); - _glfwInputDrop(window, count, (const char**) names); + _glfwInputDrop(window, count, (const char**) paths); for (i = 0; i < count; i++) - free(names[i]); - free(names); + free(paths[i]); + free(paths); } XFree(data); diff --git a/tests/events.c b/tests/events.c index fda68164..f40576d4 100644 --- a/tests/events.c +++ b/tests/events.c @@ -398,7 +398,7 @@ static void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int m get_mods_name(mods)); } -static void drop_callback(GLFWwindow* window, int count, const char** names) +static void drop_callback(GLFWwindow* window, int count, const char** paths) { int i; Slot* slot = glfwGetWindowUserPointer(window); @@ -407,7 +407,7 @@ static void drop_callback(GLFWwindow* window, int count, const char** names) counter++, slot->number, glfwGetTime()); for (i = 0; i < count; i++) - printf(" %i: \"%s\"\n", i, names[i]); + printf(" %i: \"%s\"\n", i, paths[i]); } static void monitor_callback(GLFWmonitor* monitor, int event)