-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Support SDL_EVENT_DROP_FILE and SDL_EVENT_DROP_TEXT in Windows #10415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
What is the impact of OleInititalize() on the application? Is it safe to call multiple times? Is there cleanup associated with it? For size_t probably the most portable approach is to cast to (Uint64) and use the SDL_PRIu64 formatting macro. Usually we don't bother if we know the values will always be small and just cast to int and use %d. |
f7d5b54 to
fad2340
Compare
I implemented that. Thank you.
I thought that you would have much more experience than I :-)
I am not sure I understand your proposal, for you seem to suggest that Would it be better to create some |
e46daa3 to
9e9f295
Compare
Fought with that. I would need to disable
I ended up with |
Good research! Does this mean that an application that calls
It sounds like WIN_VideoInit() should call WIN_CoInitialize(), which will by default initialize COINIT_APARTMENTTHREADED. It should then call OleInitialize(), and if that fails, enable the WM_DROPFILES fallback. Then WIN_VideoQuit() should call OleUninitialize() if OleInitialize() succeeded, and then call WIN_CoUninitialize() if WIN_CoInitialize() succeeded earlier. SDL requires that you pump events on the main thread (that initialized video), so this should work well, and you don't have to do any specific OLE initialization around the drag and drop code yourself. |
That is what I meant by unconditionally. A SDL 3 application under Windows would always connect to COM then connect to OLE, whether or not COM is required because of WASAPI or DirectInput or DirectSound or SensorManager, and whether or not OLE is required because of Drag and Drop - which is disabled by default, am I correct ? If you assume that, then I am fine with this proposal and I am willing to implement it. Otherwise I can offer two alternate proposals. They have a common part :
Two proposals for that hook location :
|
|
Just a logic change to Proposal 1. |
…_DROPFILES
Support SDL_EVENT_DROP_TEXT in Windows
src/video/windows/SDL_windowsvideo.c + .h
Connect to COM WIN_CoInitialize + OLE OleInitialize in WIN_VideoInit
Disconnect from COM WIN_CoUninitialize + OLE OleUninitialize in WIN_VideoQuit
src/video/windows/SDL_windowswindow.c + .h
Create / Destroy IDropTarget or use fallback WM_DROPFILES
depending on OleInitialize success in WIN_VideoInit
Handle text/uri-list, text/plain;charset=utf-8, CF_UNICODE_TEXT, CF_TEXT, CF_HDROP
Call terminating WIN_AcceptDragAndDrop from WIN_DestroyWindow ( CleanupVideoData )
9e9f295 to
04fd6d1
Compare
|
Merged, thanks! |
|
Two down, one to go : Wayland. This one has a tricky issue. |
The ABI lock is within weeks, but release is farther out. I assume Wayland won't require an ABI change? |
I honestly don't see why it would. To be fair, the Wayland Drag and Drop is working now, not requiring and ABI change. However, a section of that code is ugly. Thus a question : If it comes down to that, does a request for a new SDL Hint count as an ABI change ? |
No, it doesn't, as long as the default behavior matches how it has always worked. |
Remove
WM_DROPFILES( supports onlySDL_EVENT_DROP_FILE), useIDropTargetinstead ( providesSDL_EVENT_DROP_POSITION,SDL_EVENT_DROP_FILEandSDL_EVENT_DROP_TEXT).Description
src/video/windows/SDL_windowsevents.c, removeWM_DROPFILESsrc/video/windows/SDL_windowswindow.c + .h,Create
IDropTargetand issueSDL_SendDropPosition,Handle
text/uri-listforSDL_SendDropFile,text/plain;charset=utf-8andCF_UNICODE_TEXTandCF_TEXTforSDL_SendDropText,CF_HDROPforSDL_SendDropFile.To be reviewed
IDropTargetDrop OLE object requires a fullOleInitializeinWIN_AcceptDragAndDrop, asCoInitialize(Ex)are not enough and cause a Memory Management Overflow error. WhereasCoInitialize(Ex)have a centralized support in SDL,OleInitializehas not. What is the position of the SDL Development Team aboutOleInitialize?size_tvariables, using a cast to 64 bits and a%lldformat for 32 and 64 bits support. Should they use%zdinstead, like the test automation does, but which requires silencing the warnings-Wformatand-Wformat-extra-args?