static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_device, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; SDL_bool has_mime = SDL_FALSE; uint32_t dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; data_device->drag_serial = serial; if (id != NULL) { data_device->drag_offer = wl_data_offer_get_user_data(id); /* TODO: SDL Support more mime types */ has_mime = Wayland_data_offer_has_mime( data_device->drag_offer, FILE_MIME); /* If drag_mime is NULL this will decline the offer */ wl_data_offer_accept(id, serial, (has_mime == SDL_TRUE) ? FILE_MIME : NULL); /* SDL only supports "copy" style drag and drop */ if (has_mime == SDL_TRUE) { dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; } wl_data_offer_set_actions(data_device->drag_offer->offer, dnd_action, dnd_action); } }
gboolean gdk_wayland_selection_set_current_offer_actions (GdkDisplay *display, uint32_t action) { GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); struct wl_data_offer *offer; uint32_t all_actions = 0; offer = gdk_wayland_selection_get_offer (display, atoms[ATOM_DND]); if (!offer) return FALSE; if (action != 0) all_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK; if (display_wayland->data_device_manager_version >= WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION) wl_data_offer_set_actions (offer, all_actions, action); return TRUE; }