summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/x11extras/qx11info_x11.cpp10
-rw-r--r--src/x11extras/qx11info_x11.h2
-rw-r--r--tests/auto/qx11info/tst_qx11info.cpp9
3 files changed, 21 insertions, 0 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp
index 713e76c..85aa9e1 100644
--- a/src/x11extras/qx11info_x11.cpp
+++ b/src/x11extras/qx11info_x11.cpp
@@ -83,6 +83,16 @@ QX11Info::QX11Info()
}
/*!
+ Returns true if the application is currently running on X11.
+
+ \since 5.2
+ */
+bool QX11Info::isPlatformX11()
+{
+ return QGuiApplication::platformName() == QLatin1String("xcb");
+}
+
+/*!
Returns the horizontal resolution of the given \a screen in terms of the
number of dots per inch.
diff --git a/src/x11extras/qx11info_x11.h b/src/x11extras/qx11info_x11.h
index bbc7ff4..d5d00f3 100644
--- a/src/x11extras/qx11info_x11.h
+++ b/src/x11extras/qx11info_x11.h
@@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE
class Q_X11EXTRAS_EXPORT QX11Info
{
public:
+ static bool isPlatformX11();
+
static int appDpiX(int screen=-1);
static int appDpiY(int screen=-1);
diff --git a/tests/auto/qx11info/tst_qx11info.cpp b/tests/auto/qx11info/tst_qx11info.cpp
index b680834..ab741be 100644
--- a/tests/auto/qx11info/tst_qx11info.cpp
+++ b/tests/auto/qx11info/tst_qx11info.cpp
@@ -52,6 +52,7 @@ class tst_QX11Info : public QObject
private slots:
void staticFunctionsBeforeQApplication();
+ void isPlatformX11();
void appTime();
};
@@ -120,6 +121,14 @@ void tst_QX11Info::staticFunctionsBeforeQApplication()
QCOMPARE(appTime, 0ul);
}
+void tst_QX11Info::isPlatformX11()
+{
+ int argc = 0;
+ QApplication app(argc, 0);
+
+ QVERIFY(QX11Info::isPlatformX11());
+}
+
void tst_QX11Info::appTime()
{
int argc = 0;