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

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 
0011 #include "kwinglobals.h"
0012 
0013 #include <QAbstractNativeEventFilter>
0014 #include <QObject>
0015 #include <QPoint>
0016 
0017 namespace KWaylandServer
0018 {
0019 class DataDeviceInterface;
0020 class SurfaceInterface;
0021 }
0022 
0023 namespace KWin
0024 {
0025 class Window;
0026 
0027 namespace Xwl
0028 {
0029 class Clipboard;
0030 class Dnd;
0031 class Primary;
0032 enum class DragEventReply;
0033 
0034 /**
0035  * Interface class for all data sharing in the context of X selections
0036  * and Wayland's internal mechanism.
0037  *
0038  * Exists only once per Xwayland session.
0039  */
0040 class DataBridge : public QObject, public QAbstractNativeEventFilter
0041 {
0042     Q_OBJECT
0043 
0044 public:
0045     explicit DataBridge();
0046 
0047     DragEventReply dragMoveFilter(Window *target, const QPoint &pos);
0048 
0049     Dnd *dnd() const
0050     {
0051         return m_dnd;
0052     }
0053 
0054 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0055     bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override;
0056 #else
0057     bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
0058 #endif
0059 
0060 private:
0061     void init();
0062 
0063     Clipboard *m_clipboard = nullptr;
0064     Dnd *m_dnd = nullptr;
0065     Primary *m_primary = nullptr;
0066 };
0067 
0068 } // namespace Xwl
0069 } // namespace KWin