File indexing completed on 2024-05-12 05:32: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.h"
0019 #include "wayland/datadevicemanager.h"
0020 #include "wayland/seat.h"
0021 #include "wayland_server.h"
0022 #include "window.h"
0023 #include "workspace.h"
0024 
0025 namespace KWin
0026 {
0027 namespace Xwl
0028 {
0029 
0030 DataBridge::DataBridge()
0031 {
0032     init();
0033 }
0034 
0035 void DataBridge::init()
0036 {
0037     m_clipboard = new Clipboard(atoms->clipboard, this);
0038     m_dnd = new Dnd(atoms->xdnd_selection, this);
0039     m_primary = new Primary(atoms->primary, this);
0040     kwinApp()->installNativeEventFilter(this);
0041 }
0042 
0043 bool DataBridge::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *)
0044 {
0045     if (eventType == "xcb_generic_event_t") {
0046         xcb_generic_event_t *event = static_cast<xcb_generic_event_t *>(message);
0047         return m_clipboard->filterEvent(event) || m_dnd->filterEvent(event) || m_primary->filterEvent(event);
0048     }
0049     return false;
0050 }
0051 
0052 DragEventReply DataBridge::dragMoveFilter(Window *target)
0053 {
0054     return m_dnd->dragMoveFilter(target);
0055 }
0056 
0057 } // namespace Xwl
0058 } // namespace KWin
0059 
0060 #include "moc_databridge.cpp"