-#ifdef Q_WS_X11
-bool GuiApplication::x11EventFilter(XEvent * xev)
-{
- if (!current_view_)
- return false;
-
- switch (xev->type) {
- case SelectionRequest: {
- if (xev->xselectionrequest.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);
- // Refresh the selection request timestamp.
- // We have to do this by ourselves as Qt seems
- // not doing that, maybe because of our
- // "persistent selection" implementation
- // (see comments in GuiSelection.cpp).
- XSelectionEvent nev;
- nev.type = SelectionNotify;
- nev.display = xev->xselectionrequest.display;
- nev.requestor = xev->xselectionrequest.requestor;
- nev.selection = xev->xselectionrequest.selection;
- nev.target = xev->xselectionrequest.target;
- nev.property = 0L; // None
- nev.time = CurrentTime;
- XSendEvent(QX11Info::display(),
- nev.requestor, False, 0,
- reinterpret_cast<XEvent *>(&nev));
- return true;
- }
- }
- break;
- }
- case SelectionClear: {
- if (xev->xselectionclear.selection != XA_PRIMARY)
- break;
- LYXERR(Debug::SELECTION, "Lost selection.");
- BufferView * bv = current_view_->currentBufferView();
- if (bv)
- bv->clearSelection();
- break;
- }
- }
- return false;
-}
-#elif defined(QPA_XCB)