KWin
Loading...
Searching...
No Matches
drag_wl.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 "drag.h"
12
14
15#include <QList>
16#include <QPoint>
17#include <QPointer>
18
19namespace KWin
20{
21class DataDeviceInterface;
22class DataSourceInterface;
23class SurfaceInterface;
24class Window;
25class X11Window;
26
27namespace Xwl
28{
29class X11Source;
30enum class DragEventReply;
31class Xvisit;
32class Dnd;
33
34class WlToXDrag : public Drag
35{
36 Q_OBJECT
37 using Drag::Drag;
38
39public:
40 explicit WlToXDrag(Dnd *dnd);
41 DragEventReply moveFilter(Window *target) override;
42 bool handleClientMessage(xcb_client_message_event_t *event) override;
43
44private:
45 Dnd *const m_dnd;
46 Q_DISABLE_COPY(WlToXDrag)
47};
48
49// visit to an X window
50class Xvisit : public QObject
51{
52 Q_OBJECT
53
54public:
55 // TODO: handle ask action
56
57 Xvisit(X11Window *target, AbstractDataSource *dataSource, Dnd *dnd, QObject *parent);
58
59 bool handleClientMessage(xcb_client_message_event_t *event);
60 bool handleStatus(xcb_client_message_event_t *event);
61 bool handleFinished(xcb_client_message_event_t *event);
62
63 void sendPosition(const QPointF &globalPos);
64 void leave();
65
66 bool finished() const
67 {
68 return m_state.finished;
69 }
71 {
72 return m_target;
73 }
74 void drop();
75Q_SIGNALS:
76 void finish(Xvisit *self);
77
78private:
79 void sendEnter();
80 void sendDrop(uint32_t time);
81 void sendLeave();
82
83 void receiveOffer();
84 void enter();
85
86 void retrieveSupportedActions();
87 void determineProposedAction();
88 void requestDragAndDropAction();
89 void setProposedAction();
90
91 void doFinish();
92 void stopConnections();
93
94 Dnd *const m_dnd;
95 X11Window *m_target;
96 QPointer<AbstractDataSource> m_dataSource;
97 uint32_t m_version = 0;
98
99 QMetaObject::Connection m_motionConnection;
100
101 struct
102 {
103 bool pending = false;
104 bool cached = false;
105 QPoint cache;
106 } m_pos;
107
108 // supported by the Wl source
109 DataDeviceManagerInterface::DnDActions m_supportedActions = DataDeviceManagerInterface::DnDAction::None;
110 // preferred by the X client
111 DataDeviceManagerInterface::DnDAction m_preferredAction = DataDeviceManagerInterface::DnDAction::None;
112 // decided upon by the compositor
113 DataDeviceManagerInterface::DnDAction m_proposedAction = DataDeviceManagerInterface::DnDAction::None;
114
115 struct
116 {
117 bool entered = false;
118 bool dropped = false;
119 bool finished = false;
120 } m_state;
121
122 bool m_accepts = false;
123
124 Q_DISABLE_COPY(Xvisit)
125};
126
127} // namespace Xwl
128} // namespace KWin
The AbstractDataSource class abstracts the data that can be transferred to another client.
Drag(QObject *parent=nullptr)
Definition drag.cpp:19
WlToXDrag(Dnd *dnd)
Definition drag_wl.cpp:38
bool handleClientMessage(xcb_client_message_event_t *event) override
Definition drag_wl.cpp:48
DragEventReply moveFilter(Window *target) override
Definition drag_wl.cpp:43
bool handleFinished(xcb_client_message_event_t *event)
Definition drag_wl.cpp:137
void sendPosition(const QPointF &globalPos)
Definition drag_wl.cpp:159
X11Window * target() const
Definition drag_wl.h:70
bool handleStatus(xcb_client_message_event_t *event)
Definition drag_wl.cpp:100
bool handleClientMessage(xcb_client_message_event_t *event)
Definition drag_wl.cpp:90
bool finished() const
Definition drag_wl.h:66
void finish(Xvisit *self)
Xvisit(X11Window *target, AbstractDataSource *dataSource, Dnd *dnd, QObject *parent)
Definition drag_wl.cpp:53