From 9ebc979ae27ee0c7734bee91f2cdddcf4784d8c5 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 10 Jul 2016 02:53:30 +0300 Subject: [PATCH] make some X11 extensions optional as was in stock Qt4 this makes it possible to build without tricks on Slitaz for an example (or at least the GUI component, I have yet to test everything) where only the bare minimum is installed/available Signed-off-by: Ivailo Monev --- CMakeLists.txt | 2 +- src/gui/CMakeLists.txt | 28 ++++++++++++++++++---- src/gui/image/qnativeimage.cpp | 4 ++-- src/gui/image/qnativeimage_p.h | 2 +- src/gui/kernel/qapplication_x11.cpp | 4 ++-- src/gui/kernel/qdnd_x11.cpp | 8 +++---- src/gui/kernel/qt_x11_p.h | 10 ++++---- src/gui/painting/qwindowsurface_raster.cpp | 12 +++++----- src/gui/painting/qwindowsurface_raster_p.h | 2 +- src/plugins/platforms/xlib/qxlibstatic.h | 4 ++-- 10 files changed, 47 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8188872cf..b8ea913f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -451,7 +451,7 @@ set_package_properties(Threads PROPERTIES if(NOT KATIE_PLATFORM MATCHES "(win32|wince|mac)" AND NOT KATIE_BOOTSTRAP) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) - find_package(X11 COMPONENTS ICE SM Xcursor Xext Xfixes Xi Xinerama Xrandr Xrender X11 Xtst Xt) + find_package(X11 COMPONENTS ICE SM Xcursor Xext Xfixes XSync XShm XShape Xi Xkb Xinerama Xrandr Xrender X11 Xtst Xt) set_package_properties(X11 PROPERTIES PURPOSE "Required for X11/X.Org integration support" DESCRIPTION "Open source implementation of the X Window System" diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index a4e62dfab..433ae311b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -455,15 +455,33 @@ if(WITH_X11 AND X11_FOUND) ${EXTRA_GUI_LIBS} ${X11_LIBRARIES} ${X11_X11_LIB} - ${X11_Xrender_LIB} ${X11_Xt_LIB} - ${X11_Xfixes_LIB} - ${X11_Xcursor_LIB} - ${X11_Xinerama_LIB} ${X11_Xi_LIB} - ${X11_Xrandr_LIB} ) include_directories(${X11_INCLUDE_DIR}) + # in case those may be usefull via KATIE_DEFINITIONS the checks will have to + # be moved to the top-level CMake file + # TODO: xim + foreach(x11ext Xshape Xinerama Xrandr Xrender XSync Xkb Xfixes Xcursor Xinput XShm) + if(X11_${x11ext}_FOUND) + set(EXTRA_GUI_LIBS + ${EXTRA_GUI_LIBS} + ${X11_${x11ext}_LIB} + ) + else() + message(WARNING "The X11 ${x11ext} extension was not found") + string(TOUPPER "${x11ext}" upperext) + add_definitions(-DQT_NO_${upperext}) + endif() + endforeach() + if(NOT X11_Xinput_FOUND) + message(WARNING "X11 Xinput extension was not found thus disabling tabled support too") + add_definitions(-DQT_NO_TABLET) + endif() + if(NOT X11_SM_FOUND) + message(WARNING "X11 SM was not found thus disabling session manager support") + add_definitions(-DQT_NO_SESSIONMANAGER) + endif() endif() if(WITH_NIS AND NIS_FOUND) diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index bb2fb6b7f..e7ae87cb5 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -48,7 +48,7 @@ #include "qapplication_p.h" #include "qgraphicssystem_p.h" -#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#if defined(Q_WS_X11) && !defined(QT_NO_XSHM) #include #include #include @@ -148,7 +148,7 @@ QImage::Format QNativeImage::systemFormat() } -#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#elif defined(Q_WS_X11) && !defined(QT_NO_XSHM) QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget) : xshmimg(0), xshmpm(0) diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/image/qnativeimage_p.h index 0a2bbf2c9..c292caac2 100644 --- a/src/gui/image/qnativeimage_p.h +++ b/src/gui/image/qnativeimage_p.h @@ -88,7 +88,7 @@ public: HBITMAP bitmap; HBITMAP null_bitmap; -#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#elif defined(Q_WS_X11) && !defined(QT_NO_XSHM) XImage *xshmimg; Pixmap xshmpm; XShmSegmentInfo xshminfo; diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index a645913ed..38ef077d2 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1955,7 +1955,7 @@ void qt_init(QApplicationPrivate *priv, int, } #endif // QT_NO_XRENDER -#ifndef QT_NO_MITSHM +#ifndef QT_NO_XSHM int mitshm_minor; int mitshm_major; int mitshm_eventbase; @@ -1984,7 +1984,7 @@ void qt_init(QApplicationPrivate *priv, int, X11->use_mitshm_pixmaps = X11->use_mitshm && mitshm_pixmaps; } } -#endif // QT_NO_MITSHM +#endif // QT_NO_XSHM // initialize the graphics system - order is imporant here - it must be done before // the QColormap::initialize() call diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 58f7a8c71..5144666aa 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -1418,7 +1418,7 @@ void QDragManager::cancel(bool deleteSource) global_accepted_action = Qt::IgnoreAction; } -#ifndef QT_NO_SHAPE +#ifndef QT_NO_XSHAPE static bool windowInteractsWithPosition(const QPoint & pos, Window w, int shapeType) { @@ -1460,9 +1460,9 @@ Window findRealWindow(const QPoint & pos, Window w, int md, bool ignoreNonXdndAw AnyPropertyType, &type, &f,&n,&a,&data); if (data) XFree(data); if (type) { -#ifdef QT_NO_SHAPE +#ifdef QT_NO_XSHAPE return w; -#else // !QT_NO_SHAPE +#else // !QT_NO_XSHAPE const QPoint relPos = pos - QPoint(attr.x,attr.y); // When ShapeInput and ShapeBounding are not set they return a single rectangle with the geometry of the window, this is why we // need an && here so that in the case one is set and the other is not we still get the correct result. @@ -1475,7 +1475,7 @@ Window findRealWindow(const QPoint & pos, Window w, int md, bool ignoreNonXdndAw #endif if (windowContainsMouse) return w; -#endif // QT_NO_SHAPE +#endif // QT_NO_XSHAPE } } diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index a89127ab2..f7d902d5d 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -91,13 +91,13 @@ #endif // Q_OS_VXWORKS #include -//#define QT_NO_SHAPE -#ifdef QT_NO_SHAPE +//#define QT_NO_XSHAPE +#ifdef QT_NO_XSHAPE # define XShapeCombineRegion(a,b,c,d,e,f,g) # define XShapeCombineMask(a,b,c,d,e,f,g) #else # include -#endif // QT_NO_SHAPE +#endif // QT_NO_XSHAPE #if !defined (QT_NO_TABLET) @@ -300,9 +300,9 @@ extern "C" char *XSetIMValues(XIM /* im */, ...); #endif // X11R4 -#ifndef QT_NO_MITSHM +#ifndef QT_NO_XSHM # include -#endif // QT_NO_MITSHM +#endif // QT_NO_XSHM QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index c374ee98a..f92c8691e 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -78,7 +78,7 @@ public: #ifdef Q_WS_X11 GC gc; -#ifndef QT_NO_MITSHM +#ifndef QT_NO_XSHM uint needsSync : 1; #endif #ifndef QT_NO_XRENDER @@ -97,7 +97,7 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa d_ptr->translucentBackground = X11->use_xrender && window->x11Info().depth() == 32; #endif -#ifndef QT_NO_MITSHM +#ifndef QT_NO_XSHM d_ptr->needsSync = false; #endif #endif @@ -126,7 +126,7 @@ QPaintDevice *QRasterWindowSurface::paintDevice() return &d_ptr->image->image; } -#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#if defined(Q_WS_X11) && !defined(QT_NO_XSHM) void QRasterWindowSurface::syncX() { // delay writing to the backbuffer until we know for sure X is done reading from it @@ -139,7 +139,7 @@ void QRasterWindowSurface::syncX() void QRasterWindowSurface::beginPaint(const QRegion &rgn) { -#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#if defined(Q_WS_X11) && !defined(QT_NO_XSHM) syncX(); #endif @@ -242,7 +242,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi QRect br = rgn.boundingRect().translated(offset).intersected(clipRect); QPoint wpos = br.topLeft() - widgetOffset; -#ifndef QT_NO_MITSHM +#ifndef QT_NO_XSHM if (d_ptr->image->xshmpm) { XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc, br.x(), br.y(), br.width(), br.height(), wpos.x(), wpos.y()); @@ -395,7 +395,7 @@ bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy) if (!d->image || d->image->image.isNull()) return false; -#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#if defined(Q_WS_X11) && !defined(QT_NO_XSHM) syncX(); #endif diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h index 910dfbac5..ab7cccb4e 100644 --- a/src/gui/painting/qwindowsurface_raster_p.h +++ b/src/gui/painting/qwindowsurface_raster_p.h @@ -119,7 +119,7 @@ public: #endif // QT_MAC_USE_COCOA private: -#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) +#if defined(Q_WS_X11) && !defined(QT_NO_XSHM) void syncX(); #endif void prepareBuffer(QImage::Format format, QWidget *widget); diff --git a/src/plugins/platforms/xlib/qxlibstatic.h b/src/plugins/platforms/xlib/qxlibstatic.h index ff2df2b18..427ed270d 100644 --- a/src/plugins/platforms/xlib/qxlibstatic.h +++ b/src/plugins/platforms/xlib/qxlibstatic.h @@ -206,9 +206,9 @@ extern "C" Bool XUnregisterIMInstantiateCallback( #endif // X11R4 -#ifndef QT_NO_MITSHM +#ifndef QT_NO_XSHM # include -#endif // QT_NO_MITSHM +#endif // QT_NO_XSHM // rename a couple of X defines to get rid of name clashes // resolve the conflict between X11's FocusIn and QEvent::FocusIn