summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <mgraesslin@kde.org>2013-09-02 20:51:57 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-01 13:11:51 +0200
commitf0e400e1bca13176e56cf7bb323cd0a6393a85ea (patch)
tree78524fcc97ccbd1247da0b5e184bf64ad16460df
parent1a9c2249defaa7c752f5fe6a77ed1f696bc81d3d (diff)
downloadqtx11extras-f0e400e1bca13176e56cf7bb323cd0a6393a85ea.tar.gz
Properly get X screen application is running on in appScreenv5.2.0-beta1
QDesktopWidget does not provide the X screen number. No matter on which X screen an application is started, QDesktopWidget returns 0. Therefore resolve the X screen through the native interface's x11 screen resource. The documentation is improved to make it more obvious that this is about the X screen and not the RandR screen. Change-Id: I0f78a728769cbdfcac8b67b4fd5de0934f498027 Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r--src/x11extras/qx11info_x11.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp
index 85aa9e1..8bea591 100644
--- a/src/x11extras/qx11info_x11.cpp
+++ b/src/x11extras/qx11info_x11.cpp
@@ -178,14 +178,27 @@ unsigned long QX11Info::appRootWindow(int screen)
Returns the number of the screen where the application is being
displayed.
+ This method refers to screens in the original X11 meaning with a
+ different DISPLAY environment variable per screen.
+ This information is only useful if your application needs to know
+ on which X screen it is running.
+
+ In a typical multi-head configuration, multiple physical monitors
+ are combined in one X11 screen. This means this method returns the
+ same number for each of the physical monitors. In such a setup you
+ are interested in the monitor information as provided by the X11
+ RandR extension. This is available through QDesktopWidget and QScreen.
+
\sa display(), screen()
*/
int QX11Info::appScreen()
{
if (!qApp)
return 0;
- QDesktopWidget *desktop = QApplication::desktop();
- return desktop->primaryScreen();
+ QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ if (!native)
+ return 0;
+ return reinterpret_cast<qintptr>(native->nativeResourceForIntegration(QByteArrayLiteral("x11screen")));
}
/*!