commit d4428ceb81d12dde60102ad0bb3d1503efc54eda
Author: Enrico Forestieri <for...@lyx.org>
Date:   Sun Jan 11 19:36:41 2015 +0100

    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.

diff --git a/config/qt4.m4 b/config/qt4.m4
index 1346146..daa1171 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 <qconfig.h>
+           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 bcf7d65..d58c9c9 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -115,6 +115,7 @@
 #include <QThreadPool>
 #include <QWidget>
 
+// FIXME QT5
 #ifdef Q_WS_X11
 #include <X11/Xatom.h>
 #include <X11/Xlib.h>
@@ -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 e1e5ac3..a5092f3 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 c1ea8ea..2004398 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 95ab52a..5718fbb 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 9e806c4..937d930 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 1ca0add..5ddcdb4 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 1656d4d..c34a9ab 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:

Reply via email to