/usr/include/libfm-qt/xdndworkaround.h is in libfm-qt-dev 0.11.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | /*
* Copyright (C) 2016 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* Note:
* This is a workaround for the following Qt5 bugs.
*
* #49947: Drop events have broken mimeData()->urls() and text/uri-list.
* #47981: Qt5.4 regression: Dropping text/urilist over browser windows stop working.
*
* Related LXQt bug: https://github.com/lxde/lxqt/issues/688
*
* This workaround is not 100% reliable, but it should work most of the time.
* In theory, when there are multiple drag and drops at nearly the same time and
* you are using a remote X11 instance via a slow network connection, this workaround
* might break. However, that should be a really rare corner case.
*
* How this fix works:
* 1. Hook QApplication to filter raw X11 events
* 2. Intercept SelectionRequest events sent from XDnd target window.
* 3. Check if the data requested have the type "text/uri-list" or "x-moz-url"
* 4. Bypass the broken Qt5 code and send the mime data to the target with our own code.
*
* The mime data is obtained during the most recent mouse button release event.
* This can be incorrect in some corner cases, but it is still a simple and
* good enough approximation that returns the correct data most of the time.
* Anyway, a workarond is just a workaround. Ask Qt developers to fix their bugs.
*/
#ifndef XDNDWORKAROUND_H
#define XDNDWORKAROUND_H
#include <QtGlobal>
#include <QObject>
#include <QAbstractNativeEventFilter>
#include <xcb/xcb.h>
#include <QByteArray>
class QDrag;
class XdndWorkaround : public QAbstractNativeEventFilter
{
public:
XdndWorkaround();
~XdndWorkaround();
bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) override;
static QByteArray atomName(xcb_atom_t atom);
static xcb_atom_t internAtom(const char* name, int len = -1);
static QByteArray windowProperty(xcb_window_t window, xcb_atom_t propAtom, xcb_atom_t typeAtom, int len);
static void setWindowProperty(xcb_window_t window, xcb_atom_t propAtom, xcb_atom_t typeAtom, void* data, int len, int format = 8);
private:
bool clientMessage(xcb_client_message_event_t* event);
bool selectionNotify(xcb_selection_notify_event_t* event);
// This part is for Qt >= 5.4 only
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
private:
bool selectionRequest(xcb_selection_request_event_t* event);
bool genericEvent(xcb_ge_generic_event_t *event);
// _QBasicDrag* xcbDrag() const;
void buttonRelease();
QDrag* lastDrag_;
// xinput related
bool xinput2Enabled_;
int xinputOpCode_;
int xinputEventBase_;
int xinputErrorBase_;
#endif // Qt >= 5.4
};
#endif // XDNDWORKAROUND_H
|