From 29b9b92f40fb853111418f7a9599be5adf73c565 Mon Sep 17 00:00:00 2001
From: Gatis Paeglis <gatis.paeglis@digia.com>
Date: Fri, 10 May 2013 22:47:05 +0200
Subject: [PATCH] Don't send QMouseEvent events from the QXcbDrag::timerEvent()

This is not needed. The DnD initiated scrolling is done by
installing an eventFilter which forwards all MouseMove events
to the QGuiApplicationPrivate::processDrag which creates and forwards
all the necessary QDrag* events. QAbstractScrollArea has its own logic
in the timerEvent() to make the view scroll when the pointer is standing
still on the edge and the drag process is still ongoing.

With the current implementation, widgets (during the DnD) were receiving
DragMove events even when the pointer was standing still outside auto scroll
areas.

Task-number: QTBUG-28171
Change-Id: I355d88f3eab0ad39f916f84d66f5d0af7c0ff93e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
---
 src/plugins/platforms/xcb/qxcbdrag.cpp | 20 +-------------------
 src/plugins/platforms/xcb/qxcbdrag.h   |  2 --
 2 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index dceac09be5a..91acb5de026 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -140,7 +140,6 @@ QXcbDrag::QXcbDrag(QXcbConnection *c) : QXcbObject(c)
     dropData = new QXcbDropData(this);
 
     init();
-    heartbeat = -1;
     cleanup_timer = -1;
 }
 
@@ -179,9 +178,6 @@ void QXcbDrag::startDrag()
 
     init();
 
-    heartbeat = startTimer(200);
-
-
     xcb_set_selection_owner(xcb_connection(), connection()->clipboard()->owner(),
                             atom(QXcbAtom::XdndSelection), connection()->time());
 
@@ -202,10 +198,6 @@ void QXcbDrag::startDrag()
 
 void QXcbDrag::endDrag()
 {
-    if (heartbeat != -1) {
-        killTimer(heartbeat);
-        heartbeat = -1;
-    }
     QBasicDrag::endDrag();
 }
 
@@ -485,11 +477,6 @@ void QXcbDrag::drop(const QMouseEvent *event)
 {
     QBasicDrag::drop(event);
 
-    if (heartbeat != -1) {
-        killTimer(heartbeat);
-        heartbeat = -1;
-    }
-
     if (!current_target)
         return;
 
@@ -1041,12 +1028,7 @@ void QXcbDrag::handleFinished(const xcb_client_message_event_t *event)
 
 void QXcbDrag::timerEvent(QTimerEvent* e)
 {
-    if (e->timerId() == heartbeat && source_sameanswer.isNull()) {
-        QPointF pos = QCursor::pos();
-        QMouseEvent me(QEvent::MouseMove, pos, pos, pos, Qt::LeftButton,
-                       QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
-        move(&me);
-    } else if (e->timerId() == cleanup_timer) {
+    if (e->timerId() == cleanup_timer) {
         bool stopTimer = true;
         for (int i = 0; i < transactions.count(); ++i) {
             const Transaction &t = transactions.at(i);
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h
index cc74d85b511..5678c2d3034 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.h
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -143,8 +143,6 @@ private:
     xcb_window_t current_proxy_target;
 
     QXcbScreen *current_screen;
-    // timer used when target wants "continuous" move messages (eg. scroll)
-    int heartbeat;
 
     // 10 minute timer used to discard old XdndDrop transactions
     enum { XdndDropTransactionTimeout = 600000 };
-- 
GitLab