kwin/src/wayland/datadevice_interface_p.h
Vlad Zahorodnii 1c412b0f16 Introduce DragAndDropIcon
Every time the icon surface is committed, we need to accumulate the
surface offset. However, this is not easy to do on the compositor side
with the current design.

This change introduces a new class DragAndDropIcon that defines a
surface role as well as accumulates surface offsets on every commit.

This fixes a bug where the dnd icon jumps all of sudden while dragging
an image from Firefox to other applications.
2020-11-03 19:53:12 +00:00

60 lines
1.8 KiB
C++

/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <QPointer>
#include "qwayland-server-wayland.h"
namespace KWaylandServer
{
class AbstractDataSource;
class DataDeviceInterface;
class DataOfferInterface;
class DataSourceInterface;
class DragAndDropIcon;
class SeatInterface;
class SurfaceInterface;
class DataDeviceInterfacePrivate : public QtWaylandServer::wl_data_device
{
public:
static DataDeviceInterfacePrivate *get(DataDeviceInterface *device);
DataDeviceInterfacePrivate(SeatInterface *seat, DataDeviceInterface *_q, wl_resource *resource);
DataOfferInterface *createDataOffer(AbstractDataSource *source);
void endDrag();
SeatInterface *seat;
DataDeviceInterface *q;
DataSourceInterface *source = nullptr;
SurfaceInterface *surface = nullptr;
QScopedPointer<DragAndDropIcon> icon;
QPointer<DataSourceInterface> selection;
QPointer<SurfaceInterface> proxyRemoteSurface;
struct Drag {
SurfaceInterface *surface = nullptr;
QMetaObject::Connection destroyConnection;
QMetaObject::Connection posConnection;
QMetaObject::Connection sourceActionConnection;
QMetaObject::Connection targetActionConnection;
quint32 serial = 0;
};
Drag drag;
protected:
void data_device_destroy_resource(Resource *resource) override;
void data_device_start_drag(Resource *resource, wl_resource *source, wl_resource *origin, wl_resource *icon, uint32_t serial) override;
void data_device_set_selection(Resource *resource, wl_resource *source, uint32_t serial) override;
void data_device_release(Resource *resource) override;
};
} // namespace KWaylandServer