KWin
Loading...
Searching...
No Matches
xwldrophandler.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org>
6 SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#include "xwldrophandler.h"
12#include "databridge.h"
13#include "dnd.h"
14#include "drag_wl.h"
15#include "wayland/seat.h"
16#include "wayland_server.h"
17#include "workspace.h"
18#include "x11window.h"
19
20namespace KWin::Xwl
21{
22
25 , m_dnd(dnd)
26{
27}
28
29void XwlDropHandler::drop()
30{
31 if (m_xvisit) {
32 m_xvisit->drop();
33 }
34}
35
36bool XwlDropHandler::handleClientMessage(xcb_client_message_event_t *event)
37{
38 for (auto visit : m_previousVisits) {
39 if (visit->handleClientMessage(event)) {
40 return true;
41 }
42 }
43
44 if (m_xvisit && m_xvisit->handleClientMessage(event)) {
45 return true;
46 }
47 return false;
48}
49
51{
52 auto client = workspace()->findClient([surface](const X11Window *c) {
53 return c->surface() == surface;
54 });
55 if (m_xvisit && client == m_xvisit->target()) {
56 return;
57 }
58 // leave current target
59 if (m_xvisit) {
60 m_xvisit->leave();
61 if (!m_xvisit->finished()) {
62 connect(m_xvisit, &Xvisit::finish, this, [this](Xvisit *visit) {
63 m_previousVisits.removeOne(visit);
64 delete visit;
65 });
66 m_previousVisits.push_back(m_xvisit);
67 } else {
68 delete m_xvisit;
69 }
70 m_xvisit = nullptr;
71 }
72 if (client) {
73 m_xvisit = new Xvisit(client, waylandServer()->seat()->dragSource(), m_dnd, this);
74 }
75}
76}
77
78#include "moc_xwldrophandler.cpp"
Resource representing a wl_surface.
Definition surface.h:80
SurfaceInterface * surface() const
Definition window.cpp:342
X11Window * findClient(std::function< bool(const X11Window *)> func) const
Finds the first Client matching the condition expressed by passed in func.
X11Window * target() const
Definition drag_wl.h:70
bool handleClientMessage(xcb_client_message_event_t *event)
Definition drag_wl.cpp:90
void finish(Xvisit *self)
void updateDragTarget(SurfaceInterface *surface, quint32 serial) override
bool handleClientMessage(xcb_client_message_event_t *event)
WaylandServer * waylandServer()
Workspace * workspace()
Definition workspace.h:830