From caaa94b0419473fb39aeff2005b9830166f1ad1d Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 1 Oct 2012 12:26:20 +0200 Subject: [PATCH] Ensure that QDrag is set correctly at all times. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes broken code in handleSelectionRequest(). There are 2 cases when this function is called: 1) When XdndDrop has arrived (on mouse release) 2) When drop has not occurred yet (while mouse are still pressed down) Second case was not working due to this bug. Task-number: QTBUG-27405 Change-Id: I913cfd332128a28861e2fcc027b406eb821d2597 Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbdrag.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index ab4489af61..82a3fc8a83 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -1086,7 +1086,7 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event notify.property = XCB_NONE; notify.time = event->time; - // which transaction do we use? (note: -2 means use current manager->object) + // which transaction do we use? (note: -2 means use current currentDrag()) int at = -1; // figure out which data the requestor is really interested in @@ -1095,11 +1095,11 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event at = -2; } else { // if someone has requested data in response to XdndDrop, find the corresponding transaction. the - // spec says to call XConvertSelection() using the timestamp from the XdndDrop + // spec says to call xcb_convert_selection() using the timestamp from the XdndDrop at = findTransactionByTime(event->time); if (at == -1) { - // no dice, perhaps the client was nice enough to use the same window id in XConvertSelection() - // that we sent the XdndDrop event to. + // no dice, perhaps the client was nice enough to use the same window id in + // xcb_convert_selection() that we sent the XdndDrop event to. at = findTransactionByWindow(event->requestor); } // if (at == -1 && event->time == XCB_CURRENT_TIME) { @@ -1118,9 +1118,11 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event QDrag *transactionDrag = 0; if (at >= 0) { restartDropExpiryTimer(); - transactionDrag = transactions.at(at).drag; + } else if (at == -2) { + transactionDrag = currentDrag(); } + if (transactionDrag) { xcb_atom_t atomFormat = event->target; int dataFormat = 0;