#include "qplatformdefs.h"
#include "qapplication.h"
#ifndef QT_NO_DRAGANDDROP
#include "qwidget.h"
#include "qpainter.h"
#include "qpixmap.h"
#include "qbitmap.h"
#include "qdesktopwidget.h"
#include "qevent.h"
#include "qiodevice.h"
#include "qpointer.h"
#include "qcursor.h"
#include "qelapsedtimer.h"
#include "qvariant.h"
#include "qvector.h"
#include "qurl.h"
#include "qdebug.h"
#include "qimagewriter.h"
#include "qbuffer.h"
#include "qtextcodec.h"
#include "qdnd_p.h"
#include "qapplication_p.h"
#include "qt_x11_p.h"
#include "qx11info_x11.h"
#include "qwidget_p.h"
#include "qcursor_p.h"
QT_BEGIN_NAMESPACE
// #define DND_DEBUG
#ifdef DND_DEBUG
#define DEBUG qDebug
#else
#define DEBUG if(0) qDebug
#endif
#ifdef DND_DEBUG
#define DNDDEBUG qDebug()
#else
#define DNDDEBUG if(0) qDebug()
#endif
static int findXdndDropTransactionByWindow(Window window)
{
int at = -1;
for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
if (t.target == window || t.proxy_target == window) {
at = i;
break;
}
}
return at;
}
static int findXdndDropTransactionByTime(Time timestamp)
{
int at = -1;
for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
if (t.timestamp == timestamp) {
at = i;
break;
}
}
return at;
}
// timer used to discard old XdndDrop transactions
static int transaction_expiry_timer = -1;
enum { XdndDropTransactionTimeout = 5000 }; // 5 seconds
static void restartXdndDropExpiryTimer()
{
if (transaction_expiry_timer != -1)
QDragManager::self()->killTimer(transaction_expiry_timer);
transaction_expiry_timer = QDragManager::self()->startTimer(XdndDropTransactionTimeout);
}
// find an ancestor with XdndAware on it
static Window findXdndAwareParent(Window window)
{
Window target = 0;
forever {
// check if window has XdndAware
Atom type = 0;
int f;
unsigned long n, a;
unsigned char *data = 0;
if (XGetWindowProperty(X11->display, window, ATOM(XdndAware), 0, 0, False,
AnyPropertyType, &type, &f,&n,&a,&data) == Success) {
if (data)
XFree(data);
if (type) {
target = window;
break;
}
}
// try window's parent
Window root;
Window parent;
Window *children;
uint unused;
if (!XQueryTree(X11->display, window, &root, &parent, &children, &unused))
break;
if (children)
XFree(children);
if (window == root)
break;
window = parent;
}
return target;
}
// and all this stuff is copied -into- qapp_x11.cpp
static void handle_xdnd_position(QWidget *, const XEvent *, bool);
static void handle_xdnd_status(QWidget * w, const XEvent * xe, bool /*passive*/);
const int xdnd_version = 5;
static Qt::DropAction xdndaction_to_qtaction(Atom atom)
{
if (atom == ATOM(XdndActionCopy) || atom == 0)
return Qt::CopyAction;
if (atom == ATOM(XdndActionLink))
return Qt::LinkAction;
if (atom == ATOM(XdndActionMove))
return Qt::MoveAction;
return Qt::CopyAction;
}
static int qtaction_to_xdndaction(Qt::DropAction a)
{
switch (a) {
case Qt::CopyAction:
return ATOM(XdndActionCopy);
case Qt::LinkAction:
return ATOM(XdndActionLink);
case Qt::MoveAction:
case Qt::TargetMoveAction:
return ATOM(XdndActionMove);
case Qt::IgnoreAction:
return XNone;
default:
return ATOM(XdndActionCopy);
}
}
// clean up the stuff used.
static void qt_xdnd_cleanup();
static void qt_xdnd_send_leave();
// real variables:
// xid of current drag source
static Atom qt_xdnd_dragsource_xid = 0;
// the types in this drop. 100 is no good, but at least it's big.
const int qt_xdnd_max_type = 100;
static Atom qt_xdnd_types[qt_xdnd_max_type + 1];
// timer used when target wants "continuous" move messages (eg. scroll)
static int heartbeat = -1;
// rectangle in which the answer will be the same
static QRect qt_xdnd_source_sameanswer;
// top-level window we sent position to last.
static Window qt_xdnd_current_target;
// window to send events to (always valid if qt_xdnd_current_target)
static Window qt_xdnd_current_proxy_target;
static Time qt_xdnd_source_current_time;
// widget we forwarded position to last, and local position
static QPointer<QWidget> qt_xdnd_current_widget;
static QPoint qt_xdnd_current_position;
// timestamp from the XdndPosition and XdndDrop
static Time qt_xdnd_target_current_time;
// screen number containing the pointer... -1 means default
static int qt_xdnd_current_screen = -1;
// state of dragging... true if dragging, false if not
bool qt_xdnd_dragging = false;
static bool waiting_for_status = false;
// used to preset each new QDragMoveEvent
static Qt::DropAction last_target_accepted_action = Qt::IgnoreAction;
// Shift/Ctrl handling, and final drop status
static Qt::DropAction global_accepted_action = Qt::CopyAction;
static Qt::DropActions possible_actions = Qt::IgnoreAction;
// for embedding only
static QWidget* current_embedding_widget = 0;
static XEvent last_enter_event;
// cursors
static QCursor *noDropCursor = 0;
static QCursor *moveCursor = 0;
static QCursor *copyCursor = 0;
static QCursor *linkCursor = 0;
static QPixmap *defaultPm = 0;
static const int default_pm_hotx = -2;
static const int default_pm_hoty = -16;
static const char* const default_pm[] = {
"13 9 3 1",
". c None",
" c #000000",
"X c #FFFFFF",
"X X X X X X X",
" X X X X X X ",
"X ......... X",
" X.........X ",
"X ......... X",
" X.........X ",
"X ......... X",
" X X X X X X ",
"X X X X X X X"
};
class QShapedPixmapWidget : public QWidget
{
Q_OBJECT
public:
QShapedPixmapWidget(QWidget* w) :
QWidget(w,
Qt::Tool | Qt::FramelessWindowHint
| Qt::X11BypassWindowManagerHint
| Qt::BypassGraphicsProxyWidget)
{
setAttribute(Qt::WA_X11NetWmWindowTypeDND);
}
void setPixmap(const QPixmap &pm)
{
QBitmap mask = pm.mask();
if (!mask.isNull()) {
setMask(mask);
} else {
clearMask();
}
resize(pm.width(),pm.height());
pixmap = pm;
update();
}
QPoint pm_hot;
protected:
QPixmap pixmap;
void paintEvent(QPaintEvent*)
{
QPainter p(this);
p.drawPixmap(0, 0, pixmap);
}
};
#include "qdnd_x11.moc"
struct XdndData {
QShapedPixmapWidget *deco;
QWidget* desktop_proxy;
};
static XdndData xdnd_data = { 0, 0 };
class QExtraWidget : public QWidget
{
Q_DECLARE_PRIVATE(QWidget)
public:
inline QWExtra* extraData();
inline QTLWExtra* topData();
};
inline QWExtra* QExtraWidget::extraData() { return d_func()->extraData(); }
inline QTLWExtra* QExtraWidget::topData() { return d_func()->topData(); }
static WId xdndProxy(WId w)
{
Atom type = XNone;
int f;
unsigned long n, a;
unsigned char *retval = 0;
XGetWindowProperty(X11->display, w, ATOM(XdndProxy), 0, 1, False,
XA_WINDOW, &type, &f,&n,&a,&retval);
WId *proxy_id_ptr = (WId *)retval;
WId proxy_id = 0;
if (type == XA_WINDOW && proxy_id_ptr) {
proxy_id = *proxy_id_ptr;
XFree(proxy_id_ptr);
proxy_id_ptr = 0;
// Already exists. Real?
X11->ignoreBadwindow();
XGetWindowProperty(X11->display, proxy_id, ATOM(XdndProxy), 0, 1, False,
XA_WINDOW, &type, &f,&n,&a,&retval);
proxy_id_ptr = (WId *)retval;
if (X11->badwindow() || type != XA_WINDOW || !proxy_id_ptr || *proxy_id_ptr != proxy_id)
// Bogus - we will overwrite.
proxy_id = 0;
}
if
qdnd_x11.rar_drop
版权申诉
43 浏览量
2022-09-20
20:48:12
上传
评论
收藏 14KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/6a7aa99d23544fe38965063dcf203f49_weixin_42664597.jpg!1)
小贝德罗
- 粉丝: 71
- 资源: 1万+
最新资源
- 苹果CMS红色red1电影影视主题网站模板
- 光大证券-20170725-阻力支撑相对强度(RSRS)选股-技术指标系列报告之三.pdf
- EMV 4.4 Book 1~4
- 1_pt_cfix .xlsx
- EMV 4.3 Book 1~4
- EMV 4.2 Book 1~4
- EMV 4.1 Book 1~4
- 基于Python实现的遥感图像的语义分割,分别使用Deeplab V3+和unet模型+源代码+文档说明+数据集.zip
- Python基于Django服装仓库进销存库存管理系统+源代码+文档说明+数据库(高分毕设)
- 2024魔改php版大屏微信墙互动展示系统 大屏幕互动系统程序动态背景图和配乐素材含搭建教程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)