#ifdef Q_WS_X11
#include <X11/Xatom.h>
#include <X11/Xlib.h>
+#include <QX11Info>
#undef CursorShape
#undef None
#elif defined(QPA_XCB)
#include <xcb/xcb.h>
+#ifdef HAVE_QT5_X11_EXTRAS
+#include <QtX11Extras/QX11Info>
+#endif
#endif
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
QCoreApplication::setOrganizationName(app_name);
QCoreApplication::setOrganizationDomain("lyx.org");
QCoreApplication::setApplicationName(lyx_package);
+#if QT_VERSION >= 0x050000
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+#endif
qsrand(QDateTime::currentDateTime().toTime_t());
double GuiApplication::pixelRatio() const
{
#if QT_VERSION >= 0x050000
- return devicePixelRatio();
+ return qt_scale_factor * devicePixelRatio();
#else
return 1.0;
#endif
current_view_->openDocument(fname);
if (!current_view_->documentBufferView())
current_view_->close();
- else {
+ else if (cmd.origin() == FuncRequest::LYXSERVER) {
current_view_->raise();
current_view_->activateWindow();
current_view_->showNormal();
// but let's make sure
LASSERT(current_view_, break);
current_view_->openDocument(fname);
- current_view_->raise();
- current_view_->activateWindow();
- current_view_->showNormal();
+ if (cmd.origin() == FuncRequest::LYXSERVER) {
+ current_view_->raise();
+ current_view_->activateWindow();
+ current_view_->showNormal();
+ }
}
break;
}
}
+//Keep this in sync with GuiApplication::processKeySym below
+bool GuiApplication::queryKeySym(KeySymbol const & keysym,
+ KeyModifier state) const
+{
+ // Do nothing if we have nothing
+ if (!keysym.isOK() || keysym.isModifier())
+ return false;
+ // Do a one-deep top-level lookup for cancel and meta-fake keys.
+ KeySequence seq;
+ FuncRequest func = seq.addkey(keysym, state);
+ // When not cancel or meta-fake, do the normal lookup.
+ if ((func.action() != LFUN_CANCEL) && (func.action() != LFUN_META_PREFIX)) {
+ seq = d->keyseq;
+ func = seq.addkey(keysym, (state | d->meta_fake_bit));
+ }
+ // Maybe user can only reach the key via holding down shift.
+ // Let's see. But only if shift is the only modifier
+ if (func.action() == LFUN_UNKNOWN_ACTION && state == ShiftModifier)
+ // If addkey looked up a command and did not find further commands then
+ // seq has been reset at this point
+ func = seq.addkey(keysym, NoModifier);
+
+ LYXERR(Debug::KEY, " Key (queried) [action=" << func.action() << "]["
+ << seq.print(KeySequence::Portable) << ']');
+ return func.action() != LFUN_UNKNOWN_ACTION;
+}
+
+
+//Keep this in sync with GuiApplication::queryKeySym above
void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
{
LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
// Do nothing if we have nothing (JMarc)
- if (!keysym.isOK()) {
- LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
- if (current_view_)
- current_view_->restartCursor();
- return;
- }
-
- if (keysym.isModifier()) {
+ if (!keysym.isOK() || keysym.isModifier()) {
+ if (!keysym.isOK())
+ LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
if (current_view_)
current_view_->restartCursor();
return;
// Let's see. But only if shift is the only modifier
if (func.action() == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
LYXERR(Debug::KEY, "Trying without shift");
+ // If addkey looked up a command and did not find further commands then
+ // seq has been reset at this point
func = d->keyseq.addkey(keysym, NoModifier);
LYXERR(Debug::KEY, "Action now " << func.action());
}
QString const file = toqstr(lex.getString());
bool const success = readUIFile(file, true);
if (!success) {
- LYXERR0("Failed to read inlcuded file: " << fromqstr(file));
+ LYXERR0("Failed to read included file: " << fromqstr(file));
return ReadError;
}
break;
BufferView * bv = current_view_->currentBufferView();
if (bv) {
docstring const sel = bv->requestSelection();
- if (!sel.empty())
+ 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;
}
BufferView * bv = current_view_->currentBufferView();
if (bv) {
docstring const sel = bv->requestSelection();
- if (!sel.empty())
+ if (!sel.empty()) {
d->selection_.put(sel);
+#ifdef HAVE_QT5_X11_EXTRAS
+ // 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).
+ xcb_selection_notify_event_t nev;
+ nev.response_type = XCB_SELECTION_NOTIFY;
+ nev.requestor = srev->requestor;
+ nev.selection = srev->selection;
+ nev.target = srev->target;
+ nev.property = XCB_NONE;
+ nev.time = XCB_CURRENT_TIME;
+ xcb_connection_t * con = QX11Info::connection();
+ xcb_send_event(con, 0, srev->requestor,
+ XCB_EVENT_MASK_NO_EVENT,
+ reinterpret_cast<char const *>(&nev));
+ xcb_flush(con);
+#endif
+ return true;
+ }
}
break;
}