Retrieve drop data with a proper timestamp
Occasionally drag-and-drop was returning empty mimedata due to using wrong value for timestamp. Accoring to the xdnd specification we must use timestamp from XdndPosition or XdndDroptime for retrieving the data. Task-number: QTBUG-27367 Change-Id: Iadb6b6989cfc4e8ab241e2fd0ded59355108f22f Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>bb10
parent
caaa94b041
commit
5ba061a66e
|
|
@ -846,13 +846,15 @@ QByteArray QXcbClipboard::getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtAto
|
|||
return getSelection(modeAtom, fmtAtom, atom(QXcbAtom::_QT_SELECTION));
|
||||
}
|
||||
|
||||
QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property)
|
||||
QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t time)
|
||||
{
|
||||
QByteArray buf;
|
||||
xcb_window_t win = requestor();
|
||||
|
||||
if (time == 0) time = connection()->time();
|
||||
|
||||
xcb_delete_property(xcb_connection(), win, property);
|
||||
xcb_convert_selection(xcb_connection(), win, selection, target, property, connection()->time());
|
||||
xcb_convert_selection(xcb_connection(), win, selection, target, property, time);
|
||||
|
||||
connection()->sync();
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public:
|
|||
QByteArray getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtatom);
|
||||
|
||||
xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
|
||||
QByteArray getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property);
|
||||
QByteArray getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t t = 0);
|
||||
|
||||
private:
|
||||
xcb_generic_event_t *waitForClipboardEvent(xcb_window_t win, int type, int timeout, bool checkManager = false);
|
||||
|
|
|
|||
|
|
@ -1233,7 +1233,7 @@ QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type r
|
|||
return result; // should never happen?
|
||||
|
||||
xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection);
|
||||
result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection);
|
||||
result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection, drag->targetTime());
|
||||
|
||||
return mimeConvertToFormat(c, a, result, QLatin1String(format), requestedType, encoding);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public:
|
|||
bool dndEnable(QXcbWindow *win, bool on);
|
||||
|
||||
void updatePixmap();
|
||||
xcb_timestamp_t targetTime() { return target_time; }
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent* e);
|
||||
|
|
@ -128,6 +129,7 @@ private:
|
|||
enum { xdnd_max_type = 100 };
|
||||
QList<xcb_atom_t> xdnd_types;
|
||||
|
||||
// timestamp from XdndPosition and XdndDroptime for retrieving the data
|
||||
xcb_timestamp_t target_time;
|
||||
xcb_timestamp_t source_time;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue