#include <QThreadPool>
#include <QWidget>
-// FIXME QT5
#ifdef Q_WS_X11
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#undef CursorShape
#undef None
+#elif defined(QPA_XCB)
+#include <xcb/xcb.h>
+#include <X11/Xatom.h>
+#include <X11/Intrinsic.h>
+#undef None
#endif
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
// Install translator for GUI elements.
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
// 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.
//
// X11 specific stuff goes here...
-// FIXME QT5
#ifdef Q_WS_X11
bool GuiApplication::x11EventFilter(XEvent * xev)
{
}
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
} // namespace frontend
#include <QApplication>
#include <QList>
+#ifdef QPA_XCB
+#include <QAbstractNativeEventFilter>
+#endif
class QAbstractItemModel;
class QIcon;
initialisation should be done before the instantiation of this class.
*/
class GuiApplication : public QApplication, public Application
+#ifdef QPA_XCB
+ , public QAbstractNativeEventFilter
+#endif
{
Q_OBJECT
//@{
bool notify(QObject * receiver, QEvent * event);
void commitData(QSessionManager & sm);
- // FIXME QT5
#ifdef Q_WS_X11
bool x11EventFilter(XEvent * ev);
+#elif defined(QPA_XCB)
+ virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result);
#endif
//@}