From c71ad953fb86af763c9f8b192abadde87ce4fe6a Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 18 Dec 2012 11:26:49 +0100 Subject: Rename "support" to "extras" everywhere, to match the new module name Change-Id: Ic089aa287b38b756bb9f0bc252c4120859afcefa Reviewed-by: Richard J. Moore --- qtx11extras.pro | 1 + qtx11support.pro | 1 - src/src.pro | 2 +- src/x11extras/doc/qtx11extras.qdocconf | 46 ++++ src/x11extras/qtx11extrasglobal.h | 65 ++++++ src/x11extras/qx11info_x11.cpp | 276 +++++++++++++++++++++++ src/x11extras/qx11info_x11.h | 82 +++++++ src/x11extras/x11extras.pro | 12 + src/x11support/doc/qtx11support.qdocconf | 46 ---- src/x11support/qtx11supportglobal.h | 65 ------ src/x11support/qx11info_x11.cpp | 276 ----------------------- src/x11support/qx11info_x11.h | 82 ------- src/x11support/x11support.pro | 12 - sync.profile | 2 +- tests/auto/cmake/test_qx11_module/CMakeLists.txt | 8 +- tests/auto/cmake/test_qx11_module/main.cpp | 6 +- tests/auto/qx11info/qx11info.pro | 2 +- 17 files changed, 492 insertions(+), 492 deletions(-) create mode 100644 qtx11extras.pro delete mode 100644 qtx11support.pro create mode 100644 src/x11extras/doc/qtx11extras.qdocconf create mode 100644 src/x11extras/qtx11extrasglobal.h create mode 100644 src/x11extras/qx11info_x11.cpp create mode 100644 src/x11extras/qx11info_x11.h create mode 100644 src/x11extras/x11extras.pro delete mode 100644 src/x11support/doc/qtx11support.qdocconf delete mode 100644 src/x11support/qtx11supportglobal.h delete mode 100644 src/x11support/qx11info_x11.cpp delete mode 100644 src/x11support/qx11info_x11.h delete mode 100644 src/x11support/x11support.pro diff --git a/qtx11extras.pro b/qtx11extras.pro new file mode 100644 index 0000000..58c33f2 --- /dev/null +++ b/qtx11extras.pro @@ -0,0 +1 @@ +load(qt_parts) diff --git a/qtx11support.pro b/qtx11support.pro deleted file mode 100644 index 58c33f2..0000000 --- a/qtx11support.pro +++ /dev/null @@ -1 +0,0 @@ -load(qt_parts) diff --git a/src/src.pro b/src/src.pro index 97de7b0..184bfd5 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS += x11support +SUBDIRS += x11extras diff --git a/src/x11extras/doc/qtx11extras.qdocconf b/src/x11extras/doc/qtx11extras.qdocconf new file mode 100644 index 0000000..da6fd58 --- /dev/null +++ b/src/x11extras/doc/qtx11extras.qdocconf @@ -0,0 +1,46 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) + +# Name of the project which must match the outputdir. Determines the .index file +project = qtx11extras + +# Directories in which to search for files to document and images. +# By default set to the root directory of the project for sources +# and headers and qdoc will therefore generate output for each file. +# Images should be placed in /dic/images and examples in +# /examples. +# Paths are relative to the location of this file. +exampledirs += ../../../examples \ + snippets + +headerdirs += .. +imagedirs += images +sourcedirs += .. + +depends += qtcore qtwidgets + +# The following parameters are for creating a qhp file, the qhelpgenerator +# program can convert the qhp file into a qch file which can be opened in +# Qt Assistant and/or Qt Creator. + +# Defines the name of the project. You cannot use operators (+, =, -) in +# the name. Properties for this project are set using a qhp..property +# format. +qhp.projects = qtx11extras + +# Sets the name of the output qhp file. +qhp.qtx11extras.file = qtx11extras.qhp + +# Namespace for the output file. This namespace is used to distinguish between +# different documentation files in Creator/Assistant. +qhp.qtx11extras.namespace = org.qt-project.qtx11extras.500 + +# Title for the package, will be the main title for the package in +# Assistant/Creator. +qhp.qtx11extras.indexTitle = Qt X11 Extra Classes Documentation + +# Only update the name of the project for the next variables. +qhp.qtx11extras.virtualFolder = qtx11extras +qhp.qtx11extras.subprojects = classes +qhp.qtx11extras.subprojects.classes.title = Qt X11 Extras C++ Classes +qhp.qtx11extras.subprojects.classes.selectors = class fake:headerfile +qhp.qtx11extras.subprojects.classes.sortPages = true diff --git a/src/x11extras/qtx11extrasglobal.h b/src/x11extras/qtx11extrasglobal.h new file mode 100644 index 0000000..0e4b1c4 --- /dev/null +++ b/src/x11extras/qtx11extrasglobal.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Intel Corporation. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTX11EXTRASGLOBAL_H +#define QTX11EXTRASGLOBAL_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +#ifndef QT_STATIC +# if defined(QT_BUILD_X11EXTRAS_LIB) +# define Q_X11EXTRAS_EXPORT Q_DECL_EXPORT +# else +# define Q_X11EXTRAS_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_X11EXTRAS_EXPORT +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QTX11EXTRASGLOBAL_H diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp new file mode 100644 index 0000000..db3c0a1 --- /dev/null +++ b/src/x11extras/qx11info_x11.cpp @@ -0,0 +1,276 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2012 Richard Moore +** Copyright (C) 2012 David Faure +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// An implementation of QX11Info for Qt5. This code only provides the +// static methods of the QX11Info, not the methods for getting information +// about particular widgets or pixmaps. +// + +#include "qx11info_x11.h" + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +/*! + \class QX11Info + \brief The QX11Info class provides information about the X display + configuration. + + The class provides two APIs: a set of non-static functions that + provide information about a specific widget or pixmap, and a set + of static functions that provide the default information for the + application. + + \warning This class is only available on X11. For querying + per-screen information in a portable way, use QDesktopWidget. +*/ + +/*! + Constructs an empty QX11Info object. +*/ +QX11Info::QX11Info() +{ +} + +/*! + Returns the horizontal resolution of the given \a screen in terms of the + number of dots per inch. + + The \a screen argument is an X screen number. Be aware that if + the user's system uses Xinerama (as opposed to traditional X11 + multiscreen), there is only one X screen. Use QDesktopWidget to + query for information about Xinerama screens. + + \sa setAppDpiX(), appDpiY() +*/ +int QX11Info::appDpiX(int screen) +{ + if (screen == -1) { + const QScreen *scr = QGuiApplication::primaryScreen(); + if (!scr) + return 75; + return qRound(scr->logicalDotsPerInchX()); + } + + QList screens = QGuiApplication::screens(); + if (screen >= screens.size()) + return 0; + + return screens[screen]->logicalDotsPerInchX(); +} + +/*! + Returns the vertical resolution of the given \a screen in terms of the + number of dots per inch. + + The \a screen argument is an X screen number. Be aware that if + the user's system uses Xinerama (as opposed to traditional X11 + multiscreen), there is only one X screen. Use QDesktopWidget to + query for information about Xinerama screens. + + \sa setAppDpiY(), appDpiX() +*/ +int QX11Info::appDpiY(int screen) +{ + if (screen == -1) { + const QScreen *scr = QGuiApplication::primaryScreen(); + if (!scr) + return 75; + return qRound(scr->logicalDotsPerInchY()); + } + + QList screens = QGuiApplication::screens(); + if (screen > screens.size()) + return 0; + + return screens[screen]->logicalDotsPerInchY(); +} + +/*! + Returns a handle for the applications root window on the given \a screen. + + The \a screen argument is an X screen number. Be aware that if + the user's system uses Xinerama (as opposed to traditional X11 + multiscreen), there is only one X screen. Use QDesktopWidget to + query for information about Xinerama screens. + + \sa QApplication::desktop() +*/ +Qt::HANDLE QX11Info::appRootWindow(int screen) +{ + if (!qApp) + return 0; +#if 0 + // This looks like it should work, but gives the wrong value. + QDesktopWidget *desktop = QApplication::desktop(); + QWidget *screenWidget = desktop->screen(screen); + QWindow *window = screenWidget->windowHandle(); +#else + Q_UNUSED(screen); + + QDesktopWidget *desktop = QApplication::desktop(); + QWindow *window = desktop->windowHandle(); +#endif + return Qt::HANDLE(window->winId()); +} + +/*! + Returns the number of the screen where the application is being + displayed. + + \sa display(), screen() +*/ +int QX11Info::appScreen() +{ + if (!qApp) + return 0; + QDesktopWidget *desktop = QApplication::desktop(); + return desktop->primaryScreen(); +} + +/*! + Returns the X11 time. + + \sa setAppTime(), appUserTime() +*/ +unsigned long QX11Info::appTime() +{ + if (!qApp) + return 0; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + QScreen* screen = QGuiApplication::primaryScreen(); + return static_cast(reinterpret_cast(native->nativeResourceForScreen("apptime", screen))); +} + +/*! + Returns the X11 user time. + + \sa setAppUserTime(), appTime() +*/ +unsigned long QX11Info::appUserTime() +{ + if (!qApp) + return 0; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + QScreen* screen = QGuiApplication::primaryScreen(); + return static_cast(reinterpret_cast(native->nativeResourceForScreen("appusertime", screen))); +} + +/*! + Sets the X11 time to the value specified by \a time. + + \sa appTime(), setAppUserTime() +*/ +void QX11Info::setAppTime(unsigned long time) +{ + if (!qApp) + return; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + typedef void (*SetAppTimeFunc)(QScreen *, xcb_timestamp_t); + QScreen* screen = QGuiApplication::primaryScreen(); + SetAppTimeFunc func = reinterpret_cast(native->nativeResourceFunctionForScreen("setapptime")); + if (func) + func(screen, time); + else + qWarning("Internal error: QPA plugin doesn't implement setAppTime"); +} + +/*! + Sets the X11 user time as specified by \a time. + + \sa appUserTime(), setAppTime() +*/ +void QX11Info::setAppUserTime(unsigned long time) +{ + if (!qApp) + return; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + typedef void (*SetAppUserTimeFunc)(QScreen *, xcb_timestamp_t); + QScreen* screen = QGuiApplication::primaryScreen(); + SetAppUserTimeFunc func = reinterpret_cast(native->nativeResourceFunctionForScreen("setappusertime")); + if (func) + func(screen, time); + else + qWarning("Internal error: QPA plugin doesn't implement setAppUserTime"); +} + +/*! + Returns the default display for the application. + + \sa appScreen() +*/ +Display *QX11Info::display() +{ + if (!qApp) + return NULL; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + void *display = native->nativeResourceForScreen(QByteArray("display"), QGuiApplication::primaryScreen()); + return reinterpret_cast(display); +} + +/*! + Returns the default XCB connection for the application. + + \sa display() +*/ +xcb_connection_t *QX11Info::connection() +{ + if (!qApp) + return NULL; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + + void *connection = native->nativeResourceForWindow(QByteArray("connection"), 0); + return reinterpret_cast(connection); +} + +QT_END_NAMESPACE diff --git a/src/x11extras/qx11info_x11.h b/src/x11extras/qx11info_x11.h new file mode 100644 index 0000000..224d9d4 --- /dev/null +++ b/src/x11extras/qx11info_x11.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QX11INFO_X11_H +#define QX11INFO_X11_H + +#include +#include "QtX11Extras/qtx11extrasglobal.h" + +typedef struct _XDisplay Display; +struct xcb_connection_t; + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class Q_X11EXTRAS_EXPORT QX11Info +{ +public: + static int appDpiX(int screen=-1); + static int appDpiY(int screen=-1); + + static Qt::HANDLE appRootWindow(int screen=-1); + static int appScreen(); + + static unsigned long appTime(); + static unsigned long appUserTime(); + + static void setAppTime(unsigned long time); + static void setAppUserTime(unsigned long time); + + static Display *display(); + static xcb_connection_t *connection(); + +private: + QX11Info(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QX11INFO_X11_H + diff --git a/src/x11extras/x11extras.pro b/src/x11extras/x11extras.pro new file mode 100644 index 0000000..80dc421 --- /dev/null +++ b/src/x11extras/x11extras.pro @@ -0,0 +1,12 @@ +TARGET = QtX11Extras + +DEFINES += QT_NO_USING_NAMESPACE + +QMAKE_DOCS = $$PWD/doc/qtx11extras.qdocconf + +load(qt_module) + +QT += widgets gui-private + +HEADERS += qx11info_x11.h +SOURCES += qx11info_x11.cpp diff --git a/src/x11support/doc/qtx11support.qdocconf b/src/x11support/doc/qtx11support.qdocconf deleted file mode 100644 index ba5db5c..0000000 --- a/src/x11support/doc/qtx11support.qdocconf +++ /dev/null @@ -1,46 +0,0 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) - -# Name of the project which must match the outputdir. Determines the .index file -project = qtx11support - -# Directories in which to search for files to document and images. -# By default set to the root directory of the project for sources -# and headers and qdoc will therefore generate output for each file. -# Images should be placed in /dic/images and examples in -# /examples. -# Paths are relative to the location of this file. -exampledirs += ../../../examples \ - snippets - -headerdirs += .. -imagedirs += images -sourcedirs += .. - -depends += qtcore qtwidgets - -# The following parameters are for creating a qhp file, the qhelpgenerator -# program can convert the qhp file into a qch file which can be opened in -# Qt Assistant and/or Qt Creator. - -# Defines the name of the project. You cannot use operators (+, =, -) in -# the name. Properties for this project are set using a qhp..property -# format. -qhp.projects = qtx11support - -# Sets the name of the output qhp file. -qhp.qtx11support.file = qtx11support.qhp - -# Namespace for the output file. This namespace is used to distinguish between -# different documentation files in Creator/Assistant. -qhp.qtx11support.namespace = org.qt-project.qtx11support.500 - -# Title for the package, will be the main title for the package in -# Assistant/Creator. -qhp.qtx11support.indexTitle = Qt X11 Support Documentation - -# Only update the name of the project for the next variables. -qhp.qtx11support.virtualFolder = qtx11support -qhp.qtx11support.subprojects = classes -qhp.qtx11support.subprojects.classes.title = Qt X11 Support C++ Classes -qhp.qtx11support.subprojects.classes.selectors = class fake:headerfile -qhp.qtx11support.subprojects.classes.sortPages = true diff --git a/src/x11support/qtx11supportglobal.h b/src/x11support/qtx11supportglobal.h deleted file mode 100644 index 054f9a0..0000000 --- a/src/x11support/qtx11supportglobal.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Intel Corporation. -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTX11SUPPORTGLOBAL_H -#define QTX11SUPPORTGLOBAL_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_X11SUPPORT_LIB) -# define Q_X11SUPPORT_EXPORT Q_DECL_EXPORT -# else -# define Q_X11SUPPORT_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_X11SUPPORT_EXPORT -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QTX11SUPPORTGLOBAL_H diff --git a/src/x11support/qx11info_x11.cpp b/src/x11support/qx11info_x11.cpp deleted file mode 100644 index db3c0a1..0000000 --- a/src/x11support/qx11info_x11.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Copyright (C) 2012 Richard Moore -** Copyright (C) 2012 David Faure -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// An implementation of QX11Info for Qt5. This code only provides the -// static methods of the QX11Info, not the methods for getting information -// about particular widgets or pixmaps. -// - -#include "qx11info_x11.h" - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - - -/*! - \class QX11Info - \brief The QX11Info class provides information about the X display - configuration. - - The class provides two APIs: a set of non-static functions that - provide information about a specific widget or pixmap, and a set - of static functions that provide the default information for the - application. - - \warning This class is only available on X11. For querying - per-screen information in a portable way, use QDesktopWidget. -*/ - -/*! - Constructs an empty QX11Info object. -*/ -QX11Info::QX11Info() -{ -} - -/*! - Returns the horizontal resolution of the given \a screen in terms of the - number of dots per inch. - - The \a screen argument is an X screen number. Be aware that if - the user's system uses Xinerama (as opposed to traditional X11 - multiscreen), there is only one X screen. Use QDesktopWidget to - query for information about Xinerama screens. - - \sa setAppDpiX(), appDpiY() -*/ -int QX11Info::appDpiX(int screen) -{ - if (screen == -1) { - const QScreen *scr = QGuiApplication::primaryScreen(); - if (!scr) - return 75; - return qRound(scr->logicalDotsPerInchX()); - } - - QList screens = QGuiApplication::screens(); - if (screen >= screens.size()) - return 0; - - return screens[screen]->logicalDotsPerInchX(); -} - -/*! - Returns the vertical resolution of the given \a screen in terms of the - number of dots per inch. - - The \a screen argument is an X screen number. Be aware that if - the user's system uses Xinerama (as opposed to traditional X11 - multiscreen), there is only one X screen. Use QDesktopWidget to - query for information about Xinerama screens. - - \sa setAppDpiY(), appDpiX() -*/ -int QX11Info::appDpiY(int screen) -{ - if (screen == -1) { - const QScreen *scr = QGuiApplication::primaryScreen(); - if (!scr) - return 75; - return qRound(scr->logicalDotsPerInchY()); - } - - QList screens = QGuiApplication::screens(); - if (screen > screens.size()) - return 0; - - return screens[screen]->logicalDotsPerInchY(); -} - -/*! - Returns a handle for the applications root window on the given \a screen. - - The \a screen argument is an X screen number. Be aware that if - the user's system uses Xinerama (as opposed to traditional X11 - multiscreen), there is only one X screen. Use QDesktopWidget to - query for information about Xinerama screens. - - \sa QApplication::desktop() -*/ -Qt::HANDLE QX11Info::appRootWindow(int screen) -{ - if (!qApp) - return 0; -#if 0 - // This looks like it should work, but gives the wrong value. - QDesktopWidget *desktop = QApplication::desktop(); - QWidget *screenWidget = desktop->screen(screen); - QWindow *window = screenWidget->windowHandle(); -#else - Q_UNUSED(screen); - - QDesktopWidget *desktop = QApplication::desktop(); - QWindow *window = desktop->windowHandle(); -#endif - return Qt::HANDLE(window->winId()); -} - -/*! - Returns the number of the screen where the application is being - displayed. - - \sa display(), screen() -*/ -int QX11Info::appScreen() -{ - if (!qApp) - return 0; - QDesktopWidget *desktop = QApplication::desktop(); - return desktop->primaryScreen(); -} - -/*! - Returns the X11 time. - - \sa setAppTime(), appUserTime() -*/ -unsigned long QX11Info::appTime() -{ - if (!qApp) - return 0; - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - QScreen* screen = QGuiApplication::primaryScreen(); - return static_cast(reinterpret_cast(native->nativeResourceForScreen("apptime", screen))); -} - -/*! - Returns the X11 user time. - - \sa setAppUserTime(), appTime() -*/ -unsigned long QX11Info::appUserTime() -{ - if (!qApp) - return 0; - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - QScreen* screen = QGuiApplication::primaryScreen(); - return static_cast(reinterpret_cast(native->nativeResourceForScreen("appusertime", screen))); -} - -/*! - Sets the X11 time to the value specified by \a time. - - \sa appTime(), setAppUserTime() -*/ -void QX11Info::setAppTime(unsigned long time) -{ - if (!qApp) - return; - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - typedef void (*SetAppTimeFunc)(QScreen *, xcb_timestamp_t); - QScreen* screen = QGuiApplication::primaryScreen(); - SetAppTimeFunc func = reinterpret_cast(native->nativeResourceFunctionForScreen("setapptime")); - if (func) - func(screen, time); - else - qWarning("Internal error: QPA plugin doesn't implement setAppTime"); -} - -/*! - Sets the X11 user time as specified by \a time. - - \sa appUserTime(), setAppTime() -*/ -void QX11Info::setAppUserTime(unsigned long time) -{ - if (!qApp) - return; - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - typedef void (*SetAppUserTimeFunc)(QScreen *, xcb_timestamp_t); - QScreen* screen = QGuiApplication::primaryScreen(); - SetAppUserTimeFunc func = reinterpret_cast(native->nativeResourceFunctionForScreen("setappusertime")); - if (func) - func(screen, time); - else - qWarning("Internal error: QPA plugin doesn't implement setAppUserTime"); -} - -/*! - Returns the default display for the application. - - \sa appScreen() -*/ -Display *QX11Info::display() -{ - if (!qApp) - return NULL; - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - - void *display = native->nativeResourceForScreen(QByteArray("display"), QGuiApplication::primaryScreen()); - return reinterpret_cast(display); -} - -/*! - Returns the default XCB connection for the application. - - \sa display() -*/ -xcb_connection_t *QX11Info::connection() -{ - if (!qApp) - return NULL; - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - - void *connection = native->nativeResourceForWindow(QByteArray("connection"), 0); - return reinterpret_cast(connection); -} - -QT_END_NAMESPACE diff --git a/src/x11support/qx11info_x11.h b/src/x11support/qx11info_x11.h deleted file mode 100644 index 68cb6a8..0000000 --- a/src/x11support/qx11info_x11.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QX11INFO_X11_H -#define QX11INFO_X11_H - -#include -#include "QtX11Support/qtx11supportglobal.h" - -typedef struct _XDisplay Display; -struct xcb_connection_t; - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_X11SUPPORT_EXPORT QX11Info -{ -public: - static int appDpiX(int screen=-1); - static int appDpiY(int screen=-1); - - static Qt::HANDLE appRootWindow(int screen=-1); - static int appScreen(); - - static unsigned long appTime(); - static unsigned long appUserTime(); - - static void setAppTime(unsigned long time); - static void setAppUserTime(unsigned long time); - - static Display *display(); - static xcb_connection_t *connection(); - -private: - QX11Info(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QX11INFO_X11_H - diff --git a/src/x11support/x11support.pro b/src/x11support/x11support.pro deleted file mode 100644 index fed7d00..0000000 --- a/src/x11support/x11support.pro +++ /dev/null @@ -1,12 +0,0 @@ -TARGET = QtX11Support - -DEFINES += QT_NO_USING_NAMESPACE - -QMAKE_DOCS = $$PWD/doc/qtx11support.qdocconf - -load(qt_module) - -QT += widgets gui-private - -HEADERS += qx11info_x11.h -SOURCES += qx11info_x11.cpp diff --git a/sync.profile b/sync.profile index 2b293ed..b610668 100644 --- a/sync.profile +++ b/sync.profile @@ -1,5 +1,5 @@ %modules = ( # path to module name map - "QtX11Support" => "$basedir/src/x11support", + "QtX11Extras" => "$basedir/src/x11extras", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); diff --git a/tests/auto/cmake/test_qx11_module/CMakeLists.txt b/tests/auto/cmake/test_qx11_module/CMakeLists.txt index d6f050e..016cf5f 100644 --- a/tests/auto/cmake/test_qx11_module/CMakeLists.txt +++ b/tests/auto/cmake/test_qx11_module/CMakeLists.txt @@ -6,14 +6,14 @@ project(test_qx11_module) find_package(Qt5Core REQUIRED) find_package(Qt5Gui REQUIRED) -find_package(Qt5X11Support REQUIRED) +find_package(Qt5X11Extras REQUIRED) include_directories( - ${Qt5X11Support_INCLUDE_DIRS} + ${Qt5X11Extras_INCLUDE_DIRS} ) add_definitions( - ${Qt5X11Support_DEFINITIONS} + ${Qt5X11Extras_DEFINITIONS} ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") @@ -21,5 +21,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") add_executable(mainapp main.cpp) target_link_libraries(mainapp - ${Qt5X11Support_LIBRARIES} + ${Qt5X11Extras_LIBRARIES} ) diff --git a/tests/auto/cmake/test_qx11_module/main.cpp b/tests/auto/cmake/test_qx11_module/main.cpp index 932521f..41f22da 100644 --- a/tests/auto/cmake/test_qx11_module/main.cpp +++ b/tests/auto/cmake/test_qx11_module/main.cpp @@ -1,8 +1,8 @@ #include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { diff --git a/tests/auto/qx11info/qx11info.pro b/tests/auto/qx11info/qx11info.pro index 2833705..9059baa 100644 --- a/tests/auto/qx11info/qx11info.pro +++ b/tests/auto/qx11info/qx11info.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qx11info -QT += x11support widgets testlib +QT += x11extras widgets testlib SOURCES += tst_qx11info.cpp -- cgit v1.2.1