File indexing completed on 2024-11-10 04:57:40
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org> 0006 SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #include "xwldrophandler.h" 0012 #include "databridge.h" 0013 #include "dnd.h" 0014 #include "drag_wl.h" 0015 #include "wayland/seat.h" 0016 #include "wayland_server.h" 0017 #include "workspace.h" 0018 #include "x11window.h" 0019 0020 namespace KWin::Xwl 0021 { 0022 0023 XwlDropHandler::XwlDropHandler(Dnd *dnd) 0024 : AbstractDropHandler(dnd) 0025 , m_dnd(dnd) 0026 { 0027 } 0028 0029 void XwlDropHandler::drop() 0030 { 0031 if (m_xvisit) { 0032 m_xvisit->drop(); 0033 } 0034 } 0035 0036 bool XwlDropHandler::handleClientMessage(xcb_client_message_event_t *event) 0037 { 0038 for (auto visit : m_previousVisits) { 0039 if (visit->handleClientMessage(event)) { 0040 return true; 0041 } 0042 } 0043 0044 if (m_xvisit && m_xvisit->handleClientMessage(event)) { 0045 return true; 0046 } 0047 return false; 0048 } 0049 0050 void XwlDropHandler::updateDragTarget(SurfaceInterface *surface, quint32 serial) 0051 { 0052 auto client = workspace()->findClient([surface](const X11Window *c) { 0053 return c->surface() == surface; 0054 }); 0055 if (m_xvisit && client == m_xvisit->target()) { 0056 return; 0057 } 0058 // leave current target 0059 if (m_xvisit) { 0060 m_xvisit->leave(); 0061 if (!m_xvisit->finished()) { 0062 connect(m_xvisit, &Xvisit::finish, this, [this](Xvisit *visit) { 0063 m_previousVisits.removeOne(visit); 0064 delete visit; 0065 }); 0066 m_previousVisits.push_back(m_xvisit); 0067 } else { 0068 delete m_xvisit; 0069 } 0070 m_xvisit = nullptr; 0071 } 0072 if (client) { 0073 m_xvisit = new Xvisit(client, waylandServer()->seat()->dragSource(), m_dnd, this); 0074 } 0075 } 0076 } 0077 0078 #include "moc_xwldrophandler.cpp"