Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Philipp Wiesemann 2012-09-30 05:56:09 PDT I attached a patch which tries to implement the dropfile support for Microsoft Windows. If applied SDL_DROPFILE events should be sent for single or multiple files which are dropped on window. The handling on Windows side is always activated (cursor will change and so on) because there is no connection between SDL_EventState() and the window setup. I assumed this additional overhead would be small and can be ignored.
This commit is contained in:
parent
8c71219642
commit
b6fe53e5ea
2 changed files with 33 additions and 1 deletions
|
@ -29,6 +29,10 @@
|
||||||
#include "../../events/SDL_events_c.h"
|
#include "../../events/SDL_events_c.h"
|
||||||
#include "../../events/SDL_touch_c.h"
|
#include "../../events/SDL_touch_c.h"
|
||||||
|
|
||||||
|
/* Dropfile support */
|
||||||
|
#include <shellapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*#define WMMSG_DEBUG*/
|
/*#define WMMSG_DEBUG*/
|
||||||
|
@ -619,6 +623,28 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_DROPFILES:
|
||||||
|
{
|
||||||
|
UINT i;
|
||||||
|
HDROP drop = (HDROP) wParam;
|
||||||
|
UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
UINT size = DragQueryFile(drop, i, NULL, 0) + 1;
|
||||||
|
LPTSTR buffer = SDL_stack_alloc(TCHAR, size);
|
||||||
|
if (buffer) {
|
||||||
|
if (DragQueryFile(drop, i, buffer, size)) {
|
||||||
|
char *file = WIN_StringToUTF8(buffer);
|
||||||
|
SDL_SendDropFile(file);
|
||||||
|
SDL_free(file);
|
||||||
|
}
|
||||||
|
SDL_stack_free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DragFinish(drop);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there's a window proc, assume it's going to handle messages */
|
/* If there's a window proc, assume it's going to handle messages */
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#include "SDL_windowsvideo.h"
|
#include "SDL_windowsvideo.h"
|
||||||
#include "SDL_windowswindow.h"
|
#include "SDL_windowswindow.h"
|
||||||
|
|
||||||
|
/* Dropfile support */
|
||||||
|
#include <shellapi.h>
|
||||||
|
|
||||||
/* This is included after SDL_windowsvideo.h, which includes windows.h */
|
/* This is included after SDL_windowsvideo.h, which includes windows.h */
|
||||||
#include "SDL_syswm.h"
|
#include "SDL_syswm.h"
|
||||||
|
|
||||||
|
@ -185,6 +188,9 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
||||||
videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
|
videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enable dropping files */
|
||||||
|
DragAcceptFiles(hwnd, TRUE);
|
||||||
|
|
||||||
/* All done! */
|
/* All done! */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue