Changeset View
Changeset View
Standalone View
Standalone View
xwl/databridge.cpp
Show All 15 Lines | |||||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "databridge.h" | 20 | #include "databridge.h" | ||
21 | #include "xwayland.h" | 21 | #include "xwayland.h" | ||
22 | #include "selection.h" | 22 | #include "selection.h" | ||
23 | #include "clipboard.h" | 23 | #include "clipboard.h" | ||
24 | #include "dnd.h" | ||||
24 | 25 | | |||
25 | #include "atoms.h" | 26 | #include "atoms.h" | ||
26 | #include "wayland_server.h" | 27 | #include "wayland_server.h" | ||
27 | #include "workspace.h" | 28 | #include "workspace.h" | ||
28 | #include "abstract_client.h" | 29 | #include "abstract_client.h" | ||
29 | 30 | | |||
30 | // KWayland | 31 | // KWayland | ||
31 | #include <KWayland/Client/seat.h> | 32 | #include <KWayland/Client/seat.h> | ||
Show All 39 Lines | |||||
71 | DataBridge::~DataBridge() | 72 | DataBridge::~DataBridge() | ||
72 | { | 73 | { | ||
73 | s_self = nullptr; | 74 | s_self = nullptr; | ||
74 | } | 75 | } | ||
75 | 76 | | |||
76 | void DataBridge::init() | 77 | void DataBridge::init() | ||
77 | { | 78 | { | ||
78 | m_clipboard = new Clipboard(atoms->clipboard, this); | 79 | m_clipboard = new Clipboard(atoms->clipboard, this); | ||
80 | m_dnd = new Dnd(atoms->xdnd_selection, this); | ||||
79 | waylandServer()->dispatch(); | 81 | waylandServer()->dispatch(); | ||
80 | } | 82 | } | ||
81 | 83 | | |||
82 | bool DataBridge::filterEvent(xcb_generic_event_t *event) | 84 | bool DataBridge::filterEvent(xcb_generic_event_t *event) | ||
83 | { | 85 | { | ||
84 | if (m_clipboard->filterEvent(event)) { | 86 | if (m_clipboard->filterEvent(event)) { | ||
85 | return true; | 87 | return true; | ||
86 | } | 88 | } | ||
89 | if (m_dnd->filterEvent(event)) { | ||||
90 | return true; | ||||
91 | } | ||||
87 | if (event->response_type - Xwayland::self()->xfixes()->first_event == XCB_XFIXES_SELECTION_NOTIFY) { | 92 | if (event->response_type - Xwayland::self()->xfixes()->first_event == XCB_XFIXES_SELECTION_NOTIFY) { | ||
88 | return handleXfixesNotify((xcb_xfixes_selection_notify_event_t *)event); | 93 | return handleXfixesNotify((xcb_xfixes_selection_notify_event_t *)event); | ||
89 | } | 94 | } | ||
90 | return false; | 95 | return false; | ||
91 | } | 96 | } | ||
92 | 97 | | |||
93 | bool DataBridge::handleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) | 98 | bool DataBridge::handleXfixesNotify(xcb_xfixes_selection_notify_event_t *event) | ||
94 | { | 99 | { | ||
95 | auto getSelection = [this](xcb_atom_t atom) -> Selection* { | 100 | auto getSelection = [this](xcb_atom_t atom) -> Selection* { | ||
96 | if (atom == atoms->clipboard) { | 101 | if (atom == atoms->clipboard) { | ||
97 | return m_clipboard; | 102 | return m_clipboard; | ||
98 | } | 103 | } | ||
104 | if (atom == atoms->xdnd_selection) { | ||||
105 | return m_dnd; | ||||
106 | } | ||||
99 | return nullptr; | 107 | return nullptr; | ||
100 | }; | 108 | }; | ||
101 | auto *sel = getSelection(event->selection); | 109 | auto *sel = getSelection(event->selection); | ||
102 | return sel && sel->handleXfixesNotify(event); | 110 | return sel && sel->handleXfixesNotify(event); | ||
103 | } | 111 | } | ||
104 | 112 | | |||
113 | DragEventReply DataBridge::dragMoveFilter(Toplevel *target, QPoint pos) | ||||
114 | { | ||||
115 | if (!m_dnd) { | ||||
116 | return DragEventReply::Wayland; | ||||
117 | } | ||||
118 | return m_dnd->dragMoveFilter(target, pos); | ||||
119 | } | ||||
120 | | ||||
105 | } | 121 | } | ||
106 | } | 122 | } |