KWin
Loading...
Searching...
No Matches
drag_x.h
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: 2019 Roman Gilg <subdiff@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include "datasource.h"
12#include "drag.h"
13
15
16#include <QList>
17#include <QPoint>
18#include <QPointer>
19
20namespace KWin
21{
22class Window;
23
24namespace Xwl
25{
26class X11Source;
27enum class DragEventReply;
28class WlVisit;
29class Dnd;
30
31using Mimes = QList<QPair<QString, xcb_atom_t>>;
32
33class XToWlDrag : public Drag
34{
35 Q_OBJECT
36
37public:
38 explicit XToWlDrag(X11Source *source, Dnd *dnd);
39 ~XToWlDrag() override;
40
41 DragEventReply moveFilter(Window *target) override;
42 bool handleClientMessage(xcb_client_message_event_t *event) override;
43
46
48 {
49 return m_source;
50 }
51
52private:
53 void setOffers(const Mimes &offers);
54 void setDragTarget();
55
56 bool checkForFinished();
57
58 Dnd *const m_dnd;
59 Mimes m_offers;
60
61 XwlDataSource m_selectionSource;
62
63 X11Source *m_source;
64 QList<QPair<xcb_timestamp_t, bool>> m_dataRequests;
65
66 WlVisit *m_visit = nullptr;
67 QList<WlVisit *> m_oldVisits;
68
69 bool m_performed = false;
70 DataDeviceManagerInterface::DnDAction m_lastSelectedDragAndDropAction = DataDeviceManagerInterface::DnDAction::None;
71
72 Q_DISABLE_COPY(XToWlDrag)
73};
74
75class WlVisit : public QObject
76{
77 Q_OBJECT
78
79public:
80 WlVisit(Window *target, XToWlDrag *drag, Dnd *dnd);
81 ~WlVisit() override;
82
83 bool handleClientMessage(xcb_client_message_event_t *event);
84 bool leave();
85
86 Window *target() const
87 {
88 return m_target;
89 }
90 xcb_window_t window() const
91 {
92 return m_window;
93 }
94 bool entered() const
95 {
96 return m_entered;
97 }
98 bool dropHandled() const
99 {
100 return m_dropHandled;
101 }
102 bool finished() const
103 {
104 return m_finished;
105 }
106 void sendFinished();
107
108Q_SIGNALS:
109 void offersReceived(const Mimes &offers);
110 void finish(WlVisit *self);
111
112private:
113 bool handleEnter(xcb_client_message_event_t *event);
114 bool handlePosition(xcb_client_message_event_t *event);
115 bool handleDrop(xcb_client_message_event_t *event);
116 bool handleLeave(xcb_client_message_event_t *event);
117
118 void sendStatus();
119
120 void getMimesFromWinProperty(Mimes &offers);
121
122 bool targetAcceptsAction() const;
123
124 void doFinish();
125 void unmapProxyWindow();
126
127 Dnd *const m_dnd;
128 Window *m_target;
129 xcb_window_t m_window;
130
131 xcb_window_t m_srcWindow = XCB_WINDOW_NONE;
132 XToWlDrag *m_drag;
133
134 uint32_t m_version = 0;
135
136 xcb_atom_t m_actionAtom;
137 DataDeviceManagerInterface::DnDAction m_action = DataDeviceManagerInterface::DnDAction::None;
138
139 bool m_mapped = false;
140 bool m_entered = false;
141 bool m_dropHandled = false;
142 bool m_finished = false;
143
144 Q_DISABLE_COPY(WlVisit)
145};
146
147} // namespace Xwl
148} // namespace KWin
WlVisit(Window *target, XToWlDrag *drag, Dnd *dnd)
Definition drag_x.cpp:253
~WlVisit() override
Definition drag_x.cpp:293
bool dropHandled() const
Definition drag_x.h:98
Window * target() const
Definition drag_x.h:86
xcb_window_t window() const
Definition drag_x.h:90
bool entered() const
Definition drag_x.h:94
void finish(WlVisit *self)
bool handleClientMessage(xcb_client_message_event_t *event)
Definition drag_x.cpp:307
bool finished() const
Definition drag_x.h:102
void offersReceived(const Mimes &offers)
bool handleClientMessage(xcb_client_message_event_t *event) override
Definition drag_x.cpp:160
void setDragAndDropAction(DataDeviceManagerInterface::DnDAction action)
Definition drag_x.cpp:173
DataDeviceManagerInterface::DnDAction selectedDragAndDropAction()
Definition drag_x.cpp:178
X11Source * x11Source() const
Definition drag_x.h:47
~XToWlDrag() override
Definition drag_x.cpp:117
DragEventReply moveFilter(Window *target) override
Definition drag_x.cpp:121
XToWlDrag(X11Source *source, Dnd *dnd)
Definition drag_x.cpp:59
QList< QPair< QString, xcb_atom_t > > Mimes
Definition drag_x.h:31