File indexing completed on 2024-05-19 16:35:35

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_interface.h"
0014 
0015 #include <QPoint>
0016 
0017 namespace KWaylandServer
0018 {
0019 class SurfaceInterface;
0020 }
0021 
0022 namespace KWin
0023 {
0024 class Window;
0025 
0026 namespace Xwl
0027 {
0028 class Drag;
0029 enum class DragEventReply;
0030 
0031 class XwlDropHandler;
0032 
0033 /**
0034  * Represents the drag and drop mechanism, on X side this is the XDND protocol.
0035  * For more information on XDND see: https://johnlindal.wixsite.com/xdnd
0036  */
0037 class Dnd : public Selection
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     explicit Dnd(xcb_atom_t atom, QObject *parent);
0043 
0044     static uint32_t version();
0045     XwlDropHandler *dropHandler() const;
0046 
0047     void doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) override;
0048     void x11OffersChanged(const QStringList &added, const QStringList &removed) override;
0049     bool handleClientMessage(xcb_client_message_event_t *event) override;
0050 
0051     DragEventReply dragMoveFilter(Window *target, const QPoint &pos);
0052 
0053     using DnDAction = KWaylandServer::DataDeviceManagerInterface::DnDAction;
0054     using DnDActions = KWaylandServer::DataDeviceManagerInterface::DnDActions;
0055     static DnDAction atomToClientAction(xcb_atom_t atom);
0056     static xcb_atom_t clientActionToAtom(DnDAction action);
0057 
0058 private:
0059     // start and end Wl native client drags (Wl -> Xwl)
0060     void startDrag();
0061     void endDrag();
0062     void clearOldDrag(Drag *drag);
0063 
0064     // active drag or null when no drag active
0065     Drag *m_currentDrag = nullptr;
0066     QVector<Drag *> m_oldDrags;
0067 
0068     XwlDropHandler *m_dropHandler;
0069 
0070     Q_DISABLE_COPY(Dnd)
0071 };
0072 
0073 } // namespace Xwl
0074 } // namespace KWin