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 #include "databridge.h"
0010 #include "clipboard.h"
0011 #include "dnd.h"
0012 #include "primary.h"
0013 #include "selection.h"
0014 #include "xwayland.h"
0015 
0016 #include "atoms.h"
0017 #include "wayland/clientconnection.h"
0018 #include "wayland/datadevice_interface.h"
0019 #include "wayland/datadevicemanager_interface.h"
0020 #include "wayland/seat_interface.h"
0021 #include "wayland_server.h"
0022 #include "window.h"
0023 #include "workspace.h"
0024 
0025 using namespace KWaylandServer;
0026 
0027 namespace KWin
0028 {
0029 namespace Xwl
0030 {
0031 
0032 DataBridge::DataBridge()
0033 {
0034     init();
0035 }
0036 
0037 void DataBridge::init()
0038 {
0039     m_clipboard = new Clipboard(atoms->clipboard, this);
0040     m_dnd = new Dnd(atoms->xdnd_selection, this);
0041     m_primary = new Primary(atoms->primary, this);
0042     kwinApp()->installNativeEventFilter(this);
0043 }
0044 
0045 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0046 bool DataBridge::nativeEventFilter(const QByteArray &eventType, void *message, long int *)
0047 #else
0048 bool DataBridge::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *)
0049 #endif
0050 {
0051     if (eventType == "xcb_generic_event_t") {
0052         xcb_generic_event_t *event = static_cast<xcb_generic_event_t *>(message);
0053         return m_clipboard->filterEvent(event) || m_dnd->filterEvent(event) || m_primary->filterEvent(event);
0054     }
0055     return false;
0056 }
0057 
0058 DragEventReply DataBridge::dragMoveFilter(Window *target, const QPoint &pos)
0059 {
0060     return m_dnd->dragMoveFilter(target, pos);
0061 }
0062 
0063 } // namespace Xwl
0064 } // namespace KWin