19#include "wayland/datasource.h"
37const static uint32_t s_version = 5;
52 xcb_connection_t *xcbConn = kwinApp()->x11Connection();
54 const uint32_t dndValues[] = {XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE};
55 xcb_create_window(xcbConn,
58 kwinApp()->x11RootWindow(),
62 XCB_WINDOW_CLASS_INPUT_OUTPUT,
68 xcb_change_property(xcbConn,
69 XCB_PROP_MODE_REPLACE,
82 if (qobject_cast<XToWlDrag *>(m_currentDrag)) {
94 auto *originSurface = seat->focusedPointerSurface();
98 if (originSurface->client() !=
waylandServer()->xWaylandConnection()) {
103 if (!seat->isPointerButtonPressed(Qt::LeftButton)) {
113 m_currentDrag =
new XToWlDrag(source,
this);
126 for (
Drag *drag : std::as_const(m_oldDrags)) {
127 if (drag->handleClientMessage(event)) {
139 Q_ASSERT(m_currentDrag);
146 if (qobject_cast<XwlDataSource *>(dragSource)) {
151 Q_ASSERT(!m_currentDrag);
154 m_currentDrag =
new WlToXDrag(
this);
155 auto source =
new WlSource(
this);
156 source->setDataSourceIface(dragSource);
168 Q_ASSERT(m_currentDrag);
170 connect(m_currentDrag, &
Drag::finish,
this, &Dnd::clearOldDrag);
171 m_oldDrags << m_currentDrag;
173 m_currentDrag =
nullptr;
176void Dnd::clearOldDrag(Drag *drag)
178 m_oldDrags.removeOne(drag);
188 return DnDAction::Copy;
190 return DnDAction::Move;
193 return DnDAction::None;
196 return DnDAction::None;
201 if (action == DnDAction::Copy) {
203 }
else if (action == DnDAction::Move) {
205 }
else if (action == DnDAction::Ask) {
207 return XCB_ATOM_NONE;
210 return XCB_ATOM_NONE;
216#include "moc_dnd.cpp"
void aboutToBeDestroyed()
Xcb::Atom xdnd_action_copy
Xcb::Atom xdnd_action_ask
Xcb::Atom xdnd_action_move
AbstractDataSource * dragSource() const
SeatInterface * seat() const
static uint32_t version()
static DnDAction atomToClientAction(xcb_atom_t atom)
Dnd(xcb_atom_t atom, QObject *parent)
void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override
XwlDropHandler * dropHandler() const
DragEventReply dragMoveFilter(Window *target)
void x11OfferLost() override
bool handleClientMessage(xcb_client_message_event_t *event) override
static xcb_atom_t clientActionToAtom(DnDAction action)
void x11OffersChanged(const QStringList &added, const QStringList &removed) override
virtual DragEventReply moveFilter(Window *target)=0
virtual bool handleClientMessage(xcb_client_message_event_t *event)=0
void createX11Source(xcb_xfixes_selection_notify_event_t *event)
void setWlSource(WlSource *source)
void ownSelection(bool own)
xcb_window_t window() const
WlSource * wlSource() const
X11Source * x11Source() const
DataDeviceManagerInterface::DnDActions DnDActions
WaylandServer * waylandServer()
KWIN_EXPORT Atoms * atoms