From d4428ceb81d12dde60102ad0bb3d1503efc54eda Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 11 Jan 2015 19:36:41 +0100 Subject: [PATCH] Adjust preprocessor guards for Qt5/X11. This fixes the -geometry command line option and restores the "Use icons from system's theme" checkbox in the preferences. There is still code addressing Qt4 and xlib that has to be audited. This code cannot be compiled with Qt5 because the default backend is now xcb and not xlib. I have marked such code with a "FIXME QT5" comment. --- config/qt4.m4 | 13 +++++++++++++ src/frontends/qt4/GuiApplication.cpp | 6 ++++-- src/frontends/qt4/GuiApplication.h | 1 + src/frontends/qt4/GuiClipboard.cpp | 2 +- src/frontends/qt4/GuiPainter.cpp | 2 +- src/frontends/qt4/GuiPrefs.cpp | 4 ++-- src/frontends/qt4/GuiView.cpp | 4 ++-- src/frontends/qt4/GuiWorkArea.cpp | 3 ++- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/config/qt4.m4 b/config/qt4.m4 index 1346146ce7..daa11718ee 100644 --- a/config/qt4.m4 +++ b/config/qt4.m4 @@ -169,6 +169,19 @@ AC_DEFUN([QT_DO_IT_ALL], [AC_MSG_ERROR([LyX requires at least version $1 of Qt. Only version $QTLIB_VERSION has been found.]) ]) + if test x$USE_QT5 = xyes ; then + save_CPPFLAGS=$CPPFLAGS + AC_MSG_CHECKING([whether Qt uses the X Window system]) + CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES" + AC_EGREP_CPP(xcb, + [#include + QT_QPA_DEFAULT_PLATFORM_NAME], + [AC_MSG_RESULT(yes) + AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])], + [AC_MSG_RESULT(no)]) + CPPFLAGS=$save_CPPFLAGS + fi + QT_FIND_TOOL([QT_MOC], [moc]) QT_FIND_TOOL([QT_UIC], [uic]) QT_FIND_TOOL([QT_RCC], [rcc]) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index bcf7d65607..d58c9c94bb 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -115,6 +115,7 @@ #include #include +// FIXME QT5 #ifdef Q_WS_X11 #include #include @@ -167,7 +168,7 @@ namespace lyx { frontend::Application * createApplication(int & argc, char * argv[]) { -#ifndef Q_WS_X11 +#if !defined(Q_WS_X11) && !defined(QPA_XCB) // prune -geometry argument(s) by shifting // the following ones 2 places down. for (int i = 0 ; i < argc ; ++i) { @@ -1007,7 +1008,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv) setupApplescript(); #endif -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) || defined(QPA_XCB) // doubleClickInterval() is 400 ms on X11 which is just too long. // On Windows and Mac OS X, the operating system's value is used. // On Microsoft Windows, calling this function sets the double @@ -2948,6 +2949,7 @@ bool GuiApplication::longOperationStarted() { // // X11 specific stuff goes here... +// FIXME QT5 #ifdef Q_WS_X11 bool GuiApplication::x11EventFilter(XEvent * xev) { diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index e1e5ac3e3d..a5092f3efa 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -99,6 +99,7 @@ public: //@{ bool notify(QObject * receiver, QEvent * event); void commitData(QSessionManager & sm); + // FIXME QT5 #ifdef Q_WS_X11 bool x11EventFilter(XEvent * ev); #endif diff --git a/src/frontends/qt4/GuiClipboard.cpp b/src/frontends/qt4/GuiClipboard.cpp index c1ea8eac65..20043984aa 100644 --- a/src/frontends/qt4/GuiClipboard.cpp +++ b/src/frontends/qt4/GuiClipboard.cpp @@ -541,7 +541,7 @@ bool GuiClipboard::hasInternal() const // are notified of changes. However, on Windows ownership is // emulated by Qt through the OleIsCurrentClipboard() API, while // on Mac OS X we deal with this issue by ourself. -#if defined(Q_WS_X11) || defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) +#ifndef Q_OS_MAC return true; #else return false; diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index 95ab52a98f..5718fbb60a 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -38,7 +38,7 @@ // Set USE_PIXMAP_CACHE to 1 for enabling the use of a Pixmap cache when // drawing text. This is especially useful for older PPC/Mac systems. -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) || defined(QPA_XCB) #define USE_PIXMAP_CACHE 0 #else #define USE_PIXMAP_CACHE 1 diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 9e806c4733..937d9303b6 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1046,7 +1046,7 @@ void PrefScreenFonts::updateRC(LyXRC const & rc) updateScreenFontSizes(rc); pixmapCacheCB->setChecked(rc.use_pixmap_cache); -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) || defined(QPA_XCB) pixmapCacheCB->setEnabled(false); #endif @@ -2540,7 +2540,7 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form) iconSetCO->addItem(qt_("Classic"), "classic"); iconSetCO->addItem(qt_("Oxygen"), "oxygen"); -#if (!defined Q_WS_X11 || QT_VERSION < 0x040600) +#if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600) useSystemThemeIconsCB->hide(); #endif } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 1ca0adddfd..5ddcdb4741 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -635,7 +635,7 @@ void GuiView::saveLayout() const QSettings settings; settings.beginGroup("views"); settings.beginGroup(QString::number(id_)); -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) || defined(QPA_XCB) settings.setValue("pos", pos()); settings.setValue("size", size()); #else @@ -679,7 +679,7 @@ bool GuiView::restoreLayout() } setIconSize(icon_size); -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) || defined(QPA_XCB) QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint(); QSize size = settings.value("size", QSize(690, 510)).toSize(); resize(size); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 1656d4d416..c34a9aba5d 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -695,6 +695,7 @@ void GuiWorkArea::scrollTo(int value) } // Show the cursor immediately after any operation. startBlinkingCursor(); + // FIXME QT5 #ifdef Q_WS_X11 QApplication::syncX(); #endif @@ -1060,7 +1061,7 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * ev) // do nothing if there are other events // (the auto repeated events come too fast) // it looks like this is only needed on X11 -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) || defined(QPA_XCB) if (qApp->hasPendingEvents() && ev->isAutoRepeat()) { switch (ev->key()) { case Qt::Key_PageDown: