summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-11-19 13:37:45 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-19 17:12:58 +0100
commit433e7cef1e05181e717419d0eda3af777106dadf (patch)
treea3b649c3fdb297537b16ef2f859fa14a74bea5aa /src/widgets
parente8c677a9305f9485d65135eb59ca5b63c2106287 (diff)
QSystemTrayIcon/X11: Use display obtained as native screen resource.
Previously, the screen name was used, which contained the display name. This was changed to return the xrandr-name. Task-number: QTBUG-5416 Change-Id: I560143d6d459a8051c9640079cf7d39a3caebfec Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 62dab8fa11..5fefa08f77 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -102,21 +102,14 @@ QX11SystemTrayContext::QX11SystemTrayContext() : m_display(0), m_screenNumber(0)
qWarning("%s: No screen.", Q_FUNC_INFO);
return;
}
- // Open display using screen name and retrieve screen number from "hostname:0.0"
- const QByteArray name = screen->name().toLocal8Bit();
- const int dotPos = name.lastIndexOf('.');
- if (dotPos != -1) {
- bool ok;
- const int n = name.mid(dotPos + 1).toInt(&ok);
- if (ok)
- m_screenNumber = n;
- }
- m_display = XOpenDisplay(name.constData());
- if (!m_display) {
- qWarning("%s: Cannot open display '%s'.", Q_FUNC_INFO, name.constData());
+ void *displayV = QGuiApplication::platformNativeInterface()->nativeResourceForScreen(QByteArrayLiteral("display"), screen);
+ if (!displayV) {
+ qWarning("%s: Unable to obtain X11 display of primary screen.", Q_FUNC_INFO);
return;
}
+ m_display = static_cast<Display *>(displayV);
+
const QByteArray netSysTray = "_NET_SYSTEM_TRAY_S" + QByteArray::number(m_screenNumber);
m_systemTraySelection = XInternAtom(m_display, netSysTray.constData(), False);
if (!m_systemTraySelection) {
@@ -134,8 +127,6 @@ Window QX11SystemTrayContext::locateSystemTray() const
QX11SystemTrayContext::~QX11SystemTrayContext()
{
- if (m_display)
- XCloseDisplay(m_display);
}
Q_GLOBAL_STATIC(QX11SystemTrayContext, qX11SystemTrayContext)