#include "ui/ozone/platform/wayland/host/wayland_data_drag_controller.h"
#include <viewporter-client-protocol.h>
#include <bitset>
#include <cstdint>
#include <memory>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_non_backed.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event_constants.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/scoped_event_dispatcher.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/dump_util.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_cursor_position.h"
#include "ui/ozone/platform/wayland/host/wayland_data_device_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_data_offer.h"
#include "ui/ozone/platform/wayland/host/wayland_data_source.h"
#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_exchange_data_provider.h"
#include "ui/ozone/platform/wayland/host/wayland_serial_tracker.h"
#include "ui/ozone/platform/wayland/host/wayland_shm_buffer.h"
#include "ui/ozone/platform/wayland/host/wayland_surface.h"
#include "ui/ozone/platform/wayland/host/wayland_toplevel_window.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
namespace ui {
namespace {
DragEventSource;
DragOperation;
DragOperation DndActionToDragOperation(uint32_t action) { … }
int DndActionsToDragOperations(uint32_t actions) { … }
uint32_t DragOperationsToDndActions(int operations) { … }
}
WaylandDataDragController::WaylandDataDragController(
WaylandConnection* connection,
WaylandDataDeviceManager* data_device_manager,
WaylandPointer::Delegate* pointer_delegate,
WaylandTouch::Delegate* touch_delegate)
: … { … }
WaylandDataDragController::~WaylandDataDragController() { … }
bool WaylandDataDragController::StartSession(const OSExchangeData& data,
int operations,
DragEventSource source) { … }
void WaylandDataDragController::CancelSession() { … }
bool WaylandDataDragController::IsDragInProgress() const { … }
void WaylandDataDragController::UpdateDragImage(const gfx::ImageSkia& image,
const gfx::Vector2d& offset) { … }
bool WaylandDataDragController::ShouldReleaseCaptureForDrag(
ui::OSExchangeData* data) const { … }
bool WaylandDataDragController::IsWindowDragSessionRunning() const { … }
void WaylandDataDragController::DumpState(std::ostream& out) const { … }
bool WaylandDataDragController::IsDragSource() const { … }
void WaylandDataDragController::DrawIcon() { … }
void WaylandDataDragController::OnDragSurfaceFrame(void* data,
struct wl_callback* callback,
uint32_t time) { … }
SkBitmap WaylandDataDragController::GetIconBitmap() { … }
void WaylandDataDragController::DrawIconInternal() { … }
void WaylandDataDragController::OnDragOffer(
std::unique_ptr<WaylandDataOffer> offer) { … }
void WaylandDataDragController::OnDragEnter(WaylandWindow* window,
const gfx::PointF& location,
base::TimeTicks timestamp,
uint32_t serial) { … }
void WaylandDataDragController::OnDragMotion(const gfx::PointF& location,
base::TimeTicks timestamp) { … }
void WaylandDataDragController::OnDragLeave(base::TimeTicks timestamp) { … }
void WaylandDataDragController::OnDragDrop(base::TimeTicks timestamp) { … }
void WaylandDataDragController::OnDataSourceFinish(WaylandDataSource* source,
base::TimeTicks timestamp,
bool completed) { … }
void WaylandDataDragController::OnDataSourceDropPerformed(
WaylandDataSource* source,
base::TimeTicks timestamp) { … }
const WaylandWindow* WaylandDataDragController::GetDragTarget() const { … }
void WaylandDataDragController::OnDataSourceSend(WaylandDataSource* source,
const std::string& mime_type,
std::string* buffer) { … }
void WaylandDataDragController::OnWindowRemoved(WaylandWindow* window) { … }
void WaylandDataDragController::PostDataFetchingTask(
const gfx::PointF& location,
base::TimeTicks start_time,
const scoped_refptr<CancelFlag>& cancel_flag) { … }
void WaylandDataDragController::OnDataFetchingFinished(
base::TimeTicks timestamp,
std::unique_ptr<OSExchangeData> received_data) { … }
void WaylandDataDragController::CancelDataFetchingIfNeeded() { … }
void WaylandDataDragController::Reset() { … }
void WaylandDataDragController::HandleDragEnd(DragResult result,
base::TimeTicks timestamp) { … }
std::optional<wl::Serial>
WaylandDataDragController::GetAndValidateSerialForDrag(DragEventSource source) { … }
void WaylandDataDragController::SetOfferedExchangeDataProvider(
const OSExchangeData& data) { … }
const WaylandExchangeDataProvider*
WaylandDataDragController::GetOfferedExchangeDataProvider() const { … }
bool WaylandDataDragController::IsWindowDraggingSession(
const ui::OSExchangeData& data) const { … }
void WaylandDataDragController::SetUpWindowDraggingSessionIfNeeded(
const ui::OSExchangeData& data) { … }
void WaylandDataDragController::DispatchPointerRelease(
base::TimeTicks timestamp) { … }
bool WaylandDataDragController::CanDispatchEvent(const PlatformEvent& event) { … }
uint32_t WaylandDataDragController::DispatchEvent(const PlatformEvent& event) { … }
base::TaskRunner& WaylandDataDragController::GetDataFetchTaskRunner() { … }
}