mirror of
https://github.com/encounter/SDL.git
synced 2025-12-21 02:39:10 +00:00
Some drag'and'drop improvements.
First: disable d'n'd events by default; most apps don't need these at all, and if an app doesn't explicitly handle these, each drop on the window will cause a memory leak if the events are enabled. This follows the guidelines we have for SDL_TEXTINPUT events already. Second: when events are enabled or disabled, signal the video layer, as it might be able to inform the OS, causing UI changes or optimizations (for example, dropping a file icon on a Cocoa app that isn't accepting drops will cause macOS to show a rejection animation instead of the drop operation just vanishing into the ether, X11 might show a different cursor when dragging onto an accepting window, etc). Third: fill in the drop event details in the test library and enable the events in testwm.c for making sure this all works as expected.
This commit is contained in:
@@ -164,6 +164,7 @@ WIN_CreateDevice(int devindex)
|
||||
device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
|
||||
device->OnWindowEnter = WIN_OnWindowEnter;
|
||||
device->SetWindowHitTest = WIN_SetWindowHitTest;
|
||||
device->AcceptDragAndDrop = WIN_AcceptDragAndDrop;
|
||||
|
||||
device->shape_driver.CreateShaper = Win32_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = Win32_SetWindowShape;
|
||||
|
||||
@@ -289,9 +289,6 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre
|
||||
videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
|
||||
}
|
||||
|
||||
/* Enable dropping files */
|
||||
DragAcceptFiles(hwnd, TRUE);
|
||||
|
||||
data->initializing = SDL_FALSE;
|
||||
|
||||
/* All done! */
|
||||
@@ -979,6 +976,13 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept)
|
||||
{
|
||||
const SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
DragAcceptFiles(data->hwnd, accept ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -78,6 +78,7 @@ extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
|
||||
extern void WIN_UpdateClipCursor(SDL_Window *window);
|
||||
extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||
extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
|
||||
|
||||
#endif /* SDL_windowswindow_h_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user