File indexing completed on 2024-05-19 05:32:49

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 
0011 #include "selection.h"
0012 
0013 #include "wayland/datadevicemanager.h"
0014 
0015 #include <QPoint>
0016 
0017 namespace KWin
0018 {
0019 class SurfaceInterface;
0020 class Window;
0021 
0022 namespace Xwl
0023 {
0024 class Drag;
0025 enum class DragEventReply;
0026 
0027 class XwlDropHandler;
0028 
0029 /**
0030  * Represents the drag and drop mechanism, on X side this is the XDND protocol.
0031  * For more information on XDND see: https://johnlindal.wixsite.com/xdnd
0032  */
0033 class Dnd : public Selection
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     explicit Dnd(xcb_atom_t atom, QObject *parent);
0039 
0040     static uint32_t version();
0041     XwlDropHandler *dropHandler() const;
0042 
0043     void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override;
0044     void x11OfferLost() override;
0045     void x11OffersChanged(const QStringList &added, const QStringList &removed) override;
0046     bool handleClientMessage(xcb_client_message_event_t *event) override;
0047 
0048     DragEventReply dragMoveFilter(Window *target);
0049 
0050     using DnDAction = DataDeviceManagerInterface::DnDAction;
0051     using DnDActions = DataDeviceManagerInterface::DnDActions;
0052     static DnDAction atomToClientAction(xcb_atom_t atom);
0053     static xcb_atom_t clientActionToAtom(DnDAction action);
0054 
0055 private:
0056     // start and end Wl native client drags (Wl -> Xwl)
0057     void startDrag();
0058     void endDrag();
0059     void clearOldDrag(Drag *drag);
0060 
0061     // active drag or null when no drag active
0062     Drag *m_currentDrag = nullptr;
0063     QList<Drag *> m_oldDrags;
0064 
0065     XwlDropHandler *m_dropHandler;
0066 
0067     Q_DISABLE_COPY(Dnd)
0068 };
0069 
0070 } // namespace Xwl
0071 } // namespace KWin