mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Fixed name of path drop list.
This commit is contained in:
parent
ac8dba2a80
commit
93855ae6ab
@ -988,7 +988,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
|
|||||||
*
|
*
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] count The number of dropped files.
|
* @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
|
* @sa glfwSetDropCallback
|
||||||
*
|
*
|
||||||
|
@ -592,17 +592,17 @@ static int translateKey(unsigned int key)
|
|||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
NSEnumerator* e = [files objectEnumerator];
|
NSEnumerator* e = [files objectEnumerator];
|
||||||
char** names = calloc(count, sizeof(char*));
|
char** paths = calloc(count, sizeof(char*));
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < count; 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++)
|
for (i = 0; i < count; i++)
|
||||||
free(names[i]);
|
free(paths[i]);
|
||||||
free(names);
|
free(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -216,10 +216,10 @@ void _glfwInputCursorEnter(_GLFWwindow* window, int entered)
|
|||||||
window->callbacks.cursorEnter((GLFWwindow*) window, 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)
|
if (window->callbacks.drop)
|
||||||
window->callbacks.drop((GLFWwindow*) window, count, names);
|
window->callbacks.drop((GLFWwindow*) window, count, paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0);
|
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
|
// Move the mouse to the position of the drop
|
||||||
DragQueryPoint(hDrop, &pt);
|
DragQueryPoint(hDrop, &pt);
|
||||||
@ -596,16 +596,16 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
|
WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
|
||||||
|
|
||||||
DragQueryFileW(hDrop, i, buffer, length + 1);
|
DragQueryFileW(hDrop, i, buffer, length + 1);
|
||||||
names[i] = _glfwCreateUTF8FromWideString(buffer);
|
paths[i] = _glfwCreateUTF8FromWideString(buffer);
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputDrop(window, count, (const char**) names);
|
_glfwInputDrop(window, count, (const char**) paths);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
free(names[i]);
|
free(paths[i]);
|
||||||
free(names);
|
free(paths);
|
||||||
|
|
||||||
DragFinish(hDrop);
|
DragFinish(hDrop);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -188,7 +188,7 @@ static void changeWindowState(_GLFWwindow* window, Atom state, int action)
|
|||||||
static char** parseUriList(char* text, int* count)
|
static char** parseUriList(char* text, int* count)
|
||||||
{
|
{
|
||||||
const char* prefix = "file://";
|
const char* prefix = "file://";
|
||||||
char** names = NULL;
|
char** paths = NULL;
|
||||||
char* line;
|
char* line;
|
||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
@ -205,27 +205,27 @@ static char** parseUriList(char* text, int* count)
|
|||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
|
||||||
char* name = calloc(strlen(line) + 1, 1);
|
char* path = calloc(strlen(line) + 1, 1);
|
||||||
names = realloc(names, *count * sizeof(char*));
|
paths = realloc(paths, *count * sizeof(char*));
|
||||||
names[*count - 1] = name;
|
paths[*count - 1] = path;
|
||||||
|
|
||||||
while (*line)
|
while (*line)
|
||||||
{
|
{
|
||||||
if (line[0] == '%' && line[1] && line[2])
|
if (line[0] == '%' && line[1] && line[2])
|
||||||
{
|
{
|
||||||
const char digits[3] = { line[1], line[2], '\0' };
|
const char digits[3] = { line[1], line[2], '\0' };
|
||||||
*name = strtol(digits, NULL, 16);
|
*path = strtol(digits, NULL, 16);
|
||||||
line += 2;
|
line += 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*name = *line;
|
*path = *line;
|
||||||
|
|
||||||
name++;
|
path++;
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return names;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the X11 window (and its colormap)
|
// Create the X11 window (and its colormap)
|
||||||
@ -1217,13 +1217,13 @@ static void processEvent(XEvent *event)
|
|||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
int i, count;
|
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++)
|
for (i = 0; i < count; i++)
|
||||||
free(names[i]);
|
free(paths[i]);
|
||||||
free(names);
|
free(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(data);
|
XFree(data);
|
||||||
|
@ -398,7 +398,7 @@ static void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int m
|
|||||||
get_mods_name(mods));
|
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;
|
int i;
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
@ -407,7 +407,7 @@ static void drop_callback(GLFWwindow* window, int count, const char** names)
|
|||||||
counter++, slot->number, glfwGetTime());
|
counter++, slot->number, glfwGetTime());
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
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)
|
static void monitor_callback(GLFWmonitor* monitor, int event)
|
||||||
|
Loading…
Reference in New Issue
Block a user