[ThreadPoolTask]
| 248 | |
| 249 | // [ThreadPoolTask] |
| 250 | bool Run() override |
| 251 | { |
| 252 | bool dragWindow = DraggingWindow; |
| 253 | |
| 254 | if (EventQueue == nullptr) |
| 255 | { |
| 256 | if (WrappedDataDevice != nullptr) |
| 257 | wl_proxy_wrapper_destroy(WrappedDataDevice); |
| 258 | if (WrappedDataDeviceManager != nullptr) |
| 259 | wl_proxy_wrapper_destroy(WrappedDataDeviceManager); |
| 260 | if (DataDevice != nullptr) |
| 261 | wl_data_device_destroy(DataDevice); |
| 262 | |
| 263 | // This seems to throw bogus warnings about wl_data_source still being attached to the queue |
| 264 | if (EventQueue != nullptr) |
| 265 | wl_event_queue_destroy(EventQueue); |
| 266 | EventQueue = wl_display_create_queue(WaylandDisplay); |
| 267 | |
| 268 | WrappedDataDeviceManager = static_cast<wl_data_device_manager*>(wl_proxy_create_wrapper(DataDeviceManager)); |
| 269 | wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(WrappedDataDeviceManager), EventQueue); |
| 270 | |
| 271 | DataDevice = wl_data_device_manager_get_data_device(WrappedDataDeviceManager, Seat); |
| 272 | wl_data_device_add_listener(DataDevice, &DataDeviceListener, nullptr); |
| 273 | wl_display_roundtrip(WaylandDisplay); |
| 274 | wl_data_device_set_user_data(DataDevice, dragWindow ? DragSourceWindow : Window); |
| 275 | |
| 276 | WrappedDataDevice = static_cast<wl_data_device*>(wl_proxy_create_wrapper(DataDevice)); |
| 277 | wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(WrappedDataDevice), EventQueue); |
| 278 | } |
| 279 | |
| 280 | // Offer data for consumption, the data source is destroyed elsewhere |
| 281 | wl_data_source* dataSource = wl_data_device_manager_create_data_source(WrappedDataDeviceManager); |
| 282 | wl_data_source* wrappedDataSource = (wl_data_source*)wl_proxy_create_wrapper(dataSource); |
| 283 | wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(wrappedDataSource), EventQueue); |
| 284 | if (dragWindow) |
| 285 | { |
| 286 | wl_data_source_offer(dataSource, "flaxengine/window"); |
| 287 | wl_data_source_offer(dataSource, "text/plain;charset=utf-8"); // TODO: needs support for custom mime-types in SDL |
| 288 | wl_data_source_set_actions(dataSource, WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE); |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | wl_data_source_offer(dataSource, "text/plain"); |
| 293 | wl_data_source_offer(dataSource, "text/plain;charset=utf-8"); |
| 294 | wl_data_source_set_actions(dataSource, WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY); |
| 295 | } |
| 296 | LinuxDropTextData textData; |
| 297 | textData.Text = *DraggingData; |
| 298 | wl_data_source_add_listener(dataSource, &DataSourceListener, &textData); |
| 299 | |
| 300 | // Begin dragging operation |
| 301 | auto draggedWindow = Window->GetSDLWindow(); |
| 302 | auto dragStartWindow = DragSourceWindow != nullptr ? DragSourceWindow->GetSDLWindow() : draggedWindow; |
| 303 | wl_surface* originSurface = static_cast<wl_surface*>(SDL_GetPointerProperty(SDL_GetWindowProperties(dragStartWindow), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr)); |
| 304 | wl_surface* iconSurface = nullptr; |
| 305 | wl_data_device_start_drag(WrappedDataDevice, dataSource, originSurface, iconSurface, DragSerial); |
| 306 | |
| 307 | Platform::AtomicStore(&StartFlag, 1); |
nothing calls this directly
no test coverage detected