mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-29 16:09:13 +00:00
Send drop complete events when the drop leaves the window on Cocoa, Wayland, and X11
This is already done on win32, however, other platforms were left in a state of limbo if a drop operation began, then never completed due to the drop leaving the window.
This commit is contained in:
parent
db4e2ccbac
commit
731853077a
5 changed files with 15 additions and 1 deletions
src/video
|
@ -88,6 +88,7 @@
|
|||
|
||||
// Handle drag-and-drop of files onto the SDL window.
|
||||
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender;
|
||||
- (void)draggingExited:(id<NSDraggingInfo>)sender;
|
||||
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender;
|
||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender;
|
||||
- (BOOL)wantsPeriodicDraggingUpdates;
|
||||
|
@ -174,6 +175,12 @@
|
|||
return NSDragOperationNone; // no idea what to do with this, reject it.
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
SDL_Window *sdlwindow = [self findSDLWindow];
|
||||
SDL_SendDropComplete(sdlwindow);
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
|
||||
{
|
||||
if (([sender draggingSourceOperationMask] & NSDragOperationGeneric) == NSDragOperationGeneric) {
|
||||
|
|
|
@ -2134,6 +2134,7 @@ static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_
|
|||
|
||||
if (data_device->drag_offer) {
|
||||
if (data_device->dnd_window) {
|
||||
SDL_SendDropComplete(data_device->dnd_window);
|
||||
SDL_LogTrace(SDL_LOG_CATEGORY_INPUT,
|
||||
". In wl_data_device_listener . data_device_handle_leave on data_offer 0x%08x from window %d for serial %d\n",
|
||||
WAYLAND_wl_proxy_get_id((struct wl_proxy *)data_device->drag_offer->offer),
|
||||
|
|
|
@ -1384,7 +1384,6 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||
// Have we been requested to quit (or another client message?)
|
||||
case ClientMessage:
|
||||
{
|
||||
|
||||
static int xdnd_version = 0;
|
||||
|
||||
if (xevent->xclient.message_type == videodata->atoms.XdndEnter) {
|
||||
|
@ -1409,6 +1408,11 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|||
// pick from list of three
|
||||
data->xdnd_req = X11_PickTargetFromAtoms(display, xevent->xclient.data.l[2], xevent->xclient.data.l[3], xevent->xclient.data.l[4]);
|
||||
}
|
||||
} else if (xevent->xclient.message_type == videodata->atoms.XdndLeave) {
|
||||
#ifdef DEBUG_XEVENTS
|
||||
SDL_Log("XID of source window : 0x%lx\n", xevent->xclient.data.l[0]);
|
||||
#endif
|
||||
SDL_SendDropComplete(data->window);
|
||||
} else if (xevent->xclient.message_type == videodata->atoms.XdndPosition) {
|
||||
|
||||
#ifdef DEBUG_XEVENTS
|
||||
|
|
|
@ -391,6 +391,7 @@ static bool X11_VideoInit(SDL_VideoDevice *_this)
|
|||
GET_ATOM(SDL_FORMATS);
|
||||
GET_ATOM(XdndAware);
|
||||
GET_ATOM(XdndEnter);
|
||||
GET_ATOM(XdndLeave);
|
||||
GET_ATOM(XdndPosition);
|
||||
GET_ATOM(XdndStatus);
|
||||
GET_ATOM(XdndTypeList);
|
||||
|
|
|
@ -103,6 +103,7 @@ struct SDL_VideoData
|
|||
Atom SDL_FORMATS;
|
||||
Atom XdndAware;
|
||||
Atom XdndEnter;
|
||||
Atom XdndLeave;
|
||||
Atom XdndPosition;
|
||||
Atom XdndStatus;
|
||||
Atom XdndTypeList;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue