mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 06:49:43 +00:00
Fix external middle-mouse pasting with Qt5/X11.
Closes #9216. Patch by Jürgen and me.
This commit is contained in:
parent
03b17b5272
commit
52fee3556e
@ -115,12 +115,16 @@
|
|||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
// FIXME QT5
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#undef CursorShape
|
#undef CursorShape
|
||||||
#undef None
|
#undef None
|
||||||
|
#elif defined(QPA_XCB)
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Intrinsic.h>
|
||||||
|
#undef None
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
||||||
@ -998,6 +1002,11 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
|||||||
// Install translator for GUI elements.
|
// Install translator for GUI elements.
|
||||||
installTranslator(&d->qt_trans_);
|
installTranslator(&d->qt_trans_);
|
||||||
|
|
||||||
|
#ifdef QPA_XCB
|
||||||
|
// Enable reception of XCB events.
|
||||||
|
installNativeEventFilter(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
// FIXME: quitOnLastWindowClosed is true by default. We should have a
|
// FIXME: quitOnLastWindowClosed is true by default. We should have a
|
||||||
// lyxrc setting for this in order to let the application stay resident.
|
// lyxrc setting for this in order to let the application stay resident.
|
||||||
// But then we need some kind of dock icon, at least on Windows.
|
// But then we need some kind of dock icon, at least on Windows.
|
||||||
@ -2986,7 +2995,6 @@ bool GuiApplication::longOperationStarted() {
|
|||||||
//
|
//
|
||||||
// X11 specific stuff goes here...
|
// X11 specific stuff goes here...
|
||||||
|
|
||||||
// FIXME QT5
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
bool GuiApplication::x11EventFilter(XEvent * xev)
|
bool GuiApplication::x11EventFilter(XEvent * xev)
|
||||||
{
|
{
|
||||||
@ -3018,6 +3026,44 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#elif defined(QPA_XCB)
|
||||||
|
bool GuiApplication::nativeEventFilter(const QByteArray & eventType,
|
||||||
|
void * message, long *) Q_DECL_OVERRIDE
|
||||||
|
{
|
||||||
|
if (!current_view_ || eventType != "xcb_generic_event_t")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
xcb_generic_event_t * ev = static_cast<xcb_generic_event_t *>(message);
|
||||||
|
|
||||||
|
switch (ev->response_type) {
|
||||||
|
case XCB_SELECTION_REQUEST: {
|
||||||
|
xcb_selection_request_event_t * srev =
|
||||||
|
reinterpret_cast<xcb_selection_request_event_t *>(ev);
|
||||||
|
if (srev->selection != XA_PRIMARY)
|
||||||
|
break;
|
||||||
|
LYXERR(Debug::SELECTION, "X requested selection.");
|
||||||
|
BufferView * bv = current_view_->currentBufferView();
|
||||||
|
if (bv) {
|
||||||
|
docstring const sel = bv->requestSelection();
|
||||||
|
if (!sel.empty())
|
||||||
|
d->selection_.put(sel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case XCB_SELECTION_CLEAR: {
|
||||||
|
xcb_selection_clear_event_t * scev =
|
||||||
|
reinterpret_cast<xcb_selection_clear_event_t *>(ev);
|
||||||
|
if (scev->selection != XA_PRIMARY)
|
||||||
|
break;
|
||||||
|
LYXERR(Debug::SELECTION, "Lost selection.");
|
||||||
|
BufferView * bv = current_view_->currentBufferView();
|
||||||
|
if (bv)
|
||||||
|
bv->clearSelection();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#ifdef QPA_XCB
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
#endif
|
||||||
|
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
class QIcon;
|
class QIcon;
|
||||||
@ -47,6 +50,9 @@ There should be only one instance of this class. No Qt object
|
|||||||
initialisation should be done before the instantiation of this class.
|
initialisation should be done before the instantiation of this class.
|
||||||
*/
|
*/
|
||||||
class GuiApplication : public QApplication, public Application
|
class GuiApplication : public QApplication, public Application
|
||||||
|
#ifdef QPA_XCB
|
||||||
|
, public QAbstractNativeEventFilter
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -99,9 +105,10 @@ public:
|
|||||||
//@{
|
//@{
|
||||||
bool notify(QObject * receiver, QEvent * event);
|
bool notify(QObject * receiver, QEvent * event);
|
||||||
void commitData(QSessionManager & sm);
|
void commitData(QSessionManager & sm);
|
||||||
// FIXME QT5
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
bool x11EventFilter(XEvent * ev);
|
bool x11EventFilter(XEvent * ev);
|
||||||
|
#elif defined(QPA_XCB)
|
||||||
|
virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result);
|
||||||
#endif
|
#endif
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user