chromium/ui/base/x/x11_drag_drop_client.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/x/x11_drag_drop_client.h"

#include "base/containers/flat_set.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/notreached.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/x/x11_os_exchange_data_provider.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/window_cache.h"
#include "ui/gfx/x/xproto.h"

// Reading recommended for understanding the implementation in this file:
//
// * The X Window System Concepts section in The X New Developer’s Guide
// * The X Selection Mechanism paper by Keith Packard
// * The Peer-to-Peer Communication by Means of Selections section in the
//   ICCCM (X Consortium's Inter-Client Communication Conventions Manual)
// * The XDND specification, Drag-and-Drop Protocol for the X Window System
// * The XDS specification, The Direct Save Protocol for the X Window System
//
// All the readings are freely available online.

namespace ui {

// Window property on the source window and message used by the XDS protocol.
// This atom name intentionally includes the XDS protocol version (0).
// After the source sends the XdndDrop message, this property stores the
// (path-less) name of the file to be saved, and has the type text/plain, with
// an optional charset attribute.
// When receiving an XdndDrop event, the target needs to check for the
// XdndDirectSave property on the source window. The target then modifies the
// XdndDirectSave on the source window, and sends an XdndDirectSave message to
// the source.
// After the target sends the XdndDirectSave message, this property stores an
// URL indicating the location where the source should save the file.
const char kXdndDirectSave0[] =;

namespace {

DragOperation;

constexpr int kWillAcceptDrop =;
constexpr int kWantFurtherPosEvents =;

// The lowest XDND protocol version that we understand.
//
// The XDND protocol specification says that we must support all versions
// between 3 and the version we advertise in the XDndAware property.
constexpr int kMinXdndVersion =;

// The value used in the XdndAware property.
//
// The XDND protocol version used between two windows will be the minimum
// between the two versions advertised in the XDndAware property.
constexpr int kMaxXdndVersion =;

// Window property that tells other applications the window understands XDND.
const char kXdndAware[] =;

// Window property that holds the supported drag and drop data types.
// This property is set on the XDND source window when the drag and drop data
// can be converted to more than 3 types.
const char kXdndTypeList[] =;

// These actions have the same meaning as in the W3C Drag and Drop spec.
const char kXdndActionCopy[] =;
const char kXdndActionMove[] =;
const char kXdndActionLink[] =;

// Triggers the XDS protocol.
const char kXdndActionDirectSave[] =;

// Window property that contains the possible actions that will be presented to
// the user when the drag and drop action is kXdndActionAsk.
const char kXdndActionList[] =;

// Window property pointing to a proxy window to receive XDND target messages.
// The XDND source must check the proxy window must for the XdndAware property,
// and must send all XDND messages to the proxy instead of the target. However,
// the target field in the messages must still represent the original target
// window (the window pointed to by the cursor).
const char kXdndProxy[] =;

// Message sent from an XDND source to the target when the user confirms the
// drag and drop operation.
const char kXdndDrop[] =;

// Message sent from an XDND source to the target to start the XDND protocol.
// The target must wait for an XDndPosition event before querying the data.
const char kXdndEnter[] =;

// Message sent from an XDND target to the source in response to an XdndDrop.
// The message must be sent whether the target acceepts the drop or not.
const char kXdndFinished[] =;

// Message sent from an XDND source to the target when the user cancels the drag
// and drop operation.
const char kXdndLeave[] =;

// Message sent by the XDND source when the cursor position changes.
// The source will also send an XdndPosition event right after the XdndEnter
// event, to tell the target about the initial cursor position and the desired
// drop action.
// The time stamp in the XdndPosition must be used when requesting selection
// information.
// After the target optionally acquires selection information, it must tell the
// source if it can accept the drop via an XdndStatus message.
const char kXdndPosition[] =;

// Message sent by the XDND target in response to an XdndPosition message.
// The message informs the source if the target will accept the drop, and what
// action will be taken if the drop is accepted.
const char kXdndStatus[] =;

static base::LazyInstance<std::map<x11::Window, XDragDropClient*>>::Leaky
    g_live_client_map =;

x11::Atom DragOperationToAtom(DragOperation operation) {}

DragOperation AtomToDragOperation(x11::Atom atom) {}

}  // namespace

int XGetMaskAsEventFlags() {}

// static
XDragDropClient* XDragDropClient::GetForWindow(x11::Window window) {}

XDragDropClient::XDragDropClient(XDragDropClient::Delegate* delegate,
                                 x11::Window xwindow)
    :{}

XDragDropClient::~XDragDropClient() {}

std::vector<x11::Atom> XDragDropClient::GetOfferedDragOperations() const {}

void XDragDropClient::CompleteXdndPosition(x11::Window source_window,
                                           const gfx::Point& screen_point) {}

void XDragDropClient::ProcessMouseMove(const gfx::Point& screen_point,
                                       unsigned long event_time) {}

bool XDragDropClient::HandleXdndEvent(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnXdndEnter(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnXdndPosition(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnXdndStatus(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnXdndLeave(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnXdndDrop(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnXdndFinished(const x11::ClientMessageEvent& event) {}

void XDragDropClient::OnSelectionNotify(
    const x11::SelectionNotifyEvent& xselection) {}

void XDragDropClient::InitDrag(int allowed_operations,
                               const OSExchangeData* data) {}

void XDragDropClient::CleanupDrag() {}

void XDragDropClient::UpdateModifierState(int flags) {}

void XDragDropClient::ResetDragContext() {}

void XDragDropClient::StopRepeatMouseMoveTimer() {}

void XDragDropClient::StartEndMoveLoopTimer() {}

void XDragDropClient::StopEndMoveLoopTimer() {}

void XDragDropClient::HandleMouseMovement(const gfx::Point& screen_point,
                                          int flags,
                                          base::TimeTicks event_time) {}

void XDragDropClient::HandleMouseReleased() {}

void XDragDropClient::HandleMoveLoopEnded() {}

x11::ClientMessageEvent XDragDropClient::PrepareXdndClientMessage(
    const char* message,
    x11::Window recipient) const {}

x11::Window XDragDropClient::FindWindowFor(const gfx::Point& screen_point) {}

void XDragDropClient::SendXClientEvent(x11::Window window,
                                       const x11::ClientMessageEvent& xev) {}

void XDragDropClient::SendXdndEnter(x11::Window dest_window,
                                    const std::vector<x11::Atom>& targets) {}

void XDragDropClient::SendXdndPosition(x11::Window dest_window,
                                       const gfx::Point& screen_point,
                                       unsigned long event_time) {}

void XDragDropClient::SendXdndLeave(x11::Window dest_window) {}

void XDragDropClient::SendXdndDrop(x11::Window dest_window) {}

void XDragDropClient::EndMoveLoop() {}

}  // namespace ui