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); } }
void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface, wl_fixed_t x, wl_fixed_t y, wl_data_offer *id) { m_enterSerial = serial; m_dragWindow = QWaylandWindow::fromWlSurface(surface)->window(); m_dragPoint = QPoint(wl_fixed_to_int(x), wl_fixed_to_int(y)); QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag(); QMimeData *dragData; Qt::DropActions supportedActions; if (drag) { dragData = drag->mimeData(); supportedActions = drag->supportedActions(); } else { m_dragOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id))); if (m_dragOffer) { dragData = m_dragOffer->mimeData(); supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction; } } const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions); if (drag) { static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response); } else { if (response.isAccepted()) { wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData()); } else { wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0); } } }
void QWaylandDataDevice::data_device_selection(wl_data_offer *id) { if (id) m_selectionOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id))); else m_selectionOffer.reset(); QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Clipboard); }
static void data_device_handle_selection(void *data, struct wl_data_device *wl_data_device, struct wl_data_offer *id) { SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; if (id != NULL) { offer = wl_data_offer_get_user_data(id); } if (data_device->selection_offer != offer) { Wayland_data_offer_destroy(data_device->selection_offer); data_device->selection_offer = offer; } SDL_SendClipboardUpdate(); }