Changeset View
Changeset View
Standalone View
Standalone View
src/server/datadevice_interface.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | |||||
100 | void DataDeviceInterface::Private::startDrag(DataSourceInterface *dataSource, SurfaceInterface *origin, SurfaceInterface *i, quint32 serial) | 100 | void DataDeviceInterface::Private::startDrag(DataSourceInterface *dataSource, SurfaceInterface *origin, SurfaceInterface *i, quint32 serial) | ||
101 | { | 101 | { | ||
102 | // TODO: allow touch | 102 | // TODO: allow touch | ||
103 | if (seat->hasImplicitPointerGrab(serial) && seat->focusedPointerSurface() != origin) { | 103 | if (seat->hasImplicitPointerGrab(serial) && seat->focusedPointerSurface() != origin) { | ||
104 | wl_resource_post_error(resource, 0, "Surface doesn't have pointer grab"); | 104 | wl_resource_post_error(resource, 0, "Surface doesn't have pointer grab"); | ||
105 | return; | 105 | return; | ||
106 | } | 106 | } | ||
107 | // TODO: source is allowed to be null, handled client internally! | 107 | // TODO: source is allowed to be null, handled client internally! | ||
108 | Q_Q(DataDeviceInterface); | ||||
108 | source = dataSource; | 109 | source = dataSource; | ||
110 | if (dataSource) { | ||||
111 | QObject::connect(dataSource, &Resource::aboutToBeUnbound, q, [this] { source = nullptr; }); | ||||
112 | } | ||||
109 | surface = origin; | 113 | surface = origin; | ||
110 | icon = i; | 114 | icon = i; | ||
111 | drag.serial = serial; | 115 | drag.serial = serial; | ||
112 | Q_Q(DataDeviceInterface); | | |||
113 | emit q->dragStarted(); | 116 | emit q->dragStarted(); | ||
114 | } | 117 | } | ||
115 | 118 | | |||
116 | void DataDeviceInterface::Private::setSelectionCallback(wl_client *client, wl_resource *resource, wl_resource *source, uint32_t serial) | 119 | void DataDeviceInterface::Private::setSelectionCallback(wl_client *client, wl_resource *resource, wl_resource *source, uint32_t serial) | ||
117 | { | 120 | { | ||
118 | Q_UNUSED(client) | 121 | Q_UNUSED(client) | ||
119 | Q_UNUSED(serial) | 122 | Q_UNUSED(serial) | ||
120 | // TODO: verify serial | 123 | // TODO: verify serial | ||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 257 | if (d->drag.surface) { | |||
268 | } | 271 | } | ||
269 | if (d->drag.targetActionConnection) { | 272 | if (d->drag.targetActionConnection) { | ||
270 | disconnect(d->drag.targetActionConnection); | 273 | disconnect(d->drag.targetActionConnection); | ||
271 | d->drag.targetActionConnection = QMetaObject::Connection(); | 274 | d->drag.targetActionConnection = QMetaObject::Connection(); | ||
272 | } | 275 | } | ||
273 | // don't update serial, we need it | 276 | // don't update serial, we need it | ||
274 | } | 277 | } | ||
275 | if (!surface) { | 278 | if (!surface) { | ||
276 | d->seat->dragSource()->dragSource()->dndAction(DataDeviceManagerInterface::DnDAction::None); | 279 | if (auto s = d->seat->dragSource()->dragSource()) { | ||
280 | s->dndAction(DataDeviceManagerInterface::DnDAction::None); | ||||
281 | } | ||||
277 | return; | 282 | return; | ||
278 | } | 283 | } | ||
279 | auto *source = d->seat->dragSource()->dragSource(); | 284 | auto *source = d->seat->dragSource()->dragSource(); | ||
280 | DataOfferInterface *offer = d->createDataOffer(source); | 285 | DataOfferInterface *offer = d->createDataOffer(source); | ||
281 | d->drag.surface = surface; | 286 | d->drag.surface = surface; | ||
282 | if (d->seat->isDragPointer()) { | 287 | if (d->seat->isDragPointer()) { | ||
283 | d->drag.pointerPosConnection = connect(d->seat, &SeatInterface::pointerPosChanged, this, | 288 | d->drag.pointerPosConnection = connect(d->seat, &SeatInterface::pointerPosChanged, this, | ||
284 | [this] { | 289 | [this] { | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |