2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2018-08-22 12:56:48 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
|
2018-08-22 12:56:48 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2018-08-22 12:56:48 +00:00
|
|
|
#ifndef KWIN_XWL_DRAG_WL
|
|
|
|
#define KWIN_XWL_DRAG_WL
|
|
|
|
|
|
|
|
#include "drag.h"
|
|
|
|
|
2021-06-03 09:04:26 +00:00
|
|
|
#include <KWaylandServer/datadevicemanager_interface.h>
|
2018-08-22 12:56:48 +00:00
|
|
|
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QVector>
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
namespace KWaylandServer
|
2018-08-22 12:56:48 +00:00
|
|
|
{
|
|
|
|
class DataDeviceInterface;
|
|
|
|
class DataSourceInterface;
|
|
|
|
class SurfaceInterface;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
class Toplevel;
|
|
|
|
class AbstractClient;
|
|
|
|
|
|
|
|
namespace Xwl
|
|
|
|
{
|
|
|
|
class X11Source;
|
|
|
|
enum class DragEventReply;
|
|
|
|
class Xvisit;
|
|
|
|
|
|
|
|
class WlToXDrag : public Drag
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-09-03 11:47:57 +00:00
|
|
|
using Drag::Drag;
|
2018-08-22 12:56:48 +00:00
|
|
|
public:
|
2019-07-02 19:56:03 +00:00
|
|
|
DragEventReply moveFilter(Toplevel *target, const QPoint &pos) override;
|
2018-08-22 12:56:48 +00:00
|
|
|
bool handleClientMessage(xcb_client_message_event_t *event) override;
|
|
|
|
|
|
|
|
bool end() override;
|
|
|
|
private:
|
2019-07-02 19:56:03 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY(WlToXDrag)
|
2018-08-22 12:56:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// visit to an X window
|
|
|
|
class Xvisit : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-07-02 19:56:03 +00:00
|
|
|
|
2018-08-22 12:56:48 +00:00
|
|
|
public:
|
|
|
|
// TODO: handle ask action
|
|
|
|
|
2021-09-03 11:47:57 +00:00
|
|
|
Xvisit(AbstractClient *target, KWaylandServer::AbstractDataSource *dataSource, QObject *parent);
|
2018-08-22 12:56:48 +00:00
|
|
|
|
|
|
|
bool handleClientMessage(xcb_client_message_event_t *event);
|
2019-07-02 19:56:03 +00:00
|
|
|
bool handleStatus(xcb_client_message_event_t *event);
|
|
|
|
bool handleFinished(xcb_client_message_event_t *event);
|
2018-08-22 12:56:48 +00:00
|
|
|
|
|
|
|
void sendPosition(const QPointF &globalPos);
|
|
|
|
void leave();
|
|
|
|
|
|
|
|
bool finished() const {
|
|
|
|
return m_state.finished;
|
|
|
|
}
|
|
|
|
AbstractClient *target() const {
|
|
|
|
return m_target;
|
|
|
|
}
|
2021-09-03 11:47:57 +00:00
|
|
|
void drop();
|
2018-08-22 12:56:48 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void finish(Xvisit *self);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void sendEnter();
|
|
|
|
void sendDrop(uint32_t time);
|
|
|
|
void sendLeave();
|
|
|
|
|
|
|
|
void receiveOffer();
|
|
|
|
void enter();
|
|
|
|
|
|
|
|
void retrieveSupportedActions();
|
|
|
|
void determineProposedAction();
|
|
|
|
void requestDragAndDropAction();
|
|
|
|
void setProposedAction();
|
|
|
|
|
|
|
|
void doFinish();
|
|
|
|
void stopConnections();
|
|
|
|
|
|
|
|
AbstractClient *m_target;
|
2021-09-03 11:47:57 +00:00
|
|
|
QPointer<KWaylandServer::AbstractDataSource> m_dataSource;
|
2018-08-22 12:56:48 +00:00
|
|
|
uint32_t m_version = 0;
|
|
|
|
|
2019-07-02 19:56:03 +00:00
|
|
|
QMetaObject::Connection m_motionConnection;
|
2018-08-22 12:56:48 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
bool pending = false;
|
|
|
|
bool cached = false;
|
|
|
|
QPoint cache;
|
|
|
|
} m_pos;
|
|
|
|
|
|
|
|
// supported by the Wl source
|
2021-06-03 09:04:26 +00:00
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDActions m_supportedActions = KWaylandServer::DataDeviceManagerInterface::DnDAction::None;
|
2018-08-22 12:56:48 +00:00
|
|
|
// preferred by the X client
|
2021-06-03 09:04:26 +00:00
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDAction m_preferredAction = KWaylandServer::DataDeviceManagerInterface::DnDAction::None;
|
2018-08-22 12:56:48 +00:00
|
|
|
// decided upon by the compositor
|
2021-06-03 09:04:26 +00:00
|
|
|
KWaylandServer::DataDeviceManagerInterface::DnDAction m_proposedAction = KWaylandServer::DataDeviceManagerInterface::DnDAction::None;
|
2018-08-22 12:56:48 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
bool entered = false;
|
|
|
|
bool dropped = false;
|
|
|
|
bool finished = false;
|
|
|
|
} m_state;
|
|
|
|
|
|
|
|
bool m_accepts = false;
|
2019-07-02 19:56:03 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY(Xvisit)
|
2018-08-22 12:56:48 +00:00
|
|
|
};
|
|
|
|
|
2019-07-02 19:56:03 +00:00
|
|
|
} // namespace Xwl
|
|
|
|
} // namespace KWin
|
2018-08-22 12:56:48 +00:00
|
|
|
|
|
|
|
#endif
|