diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-06-28 11:51:29 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-30 15:08:31 +0200 |
commit | d8090022f66cc6cff6af5ed2ae702212fd172ff7 (patch) | |
tree | 9942fb8e23293c49c62590fe714b8b8d6f961304 /src/plugins/platforms/xcb/qxcbnativeinterface.cpp | |
parent | 983e921c541f6eaacb9abcddb8ec079ec5129cf1 (diff) |
Move the X11 system tray code from widgets into XCB-plugin.
- Add system tray tracker class to XCB plugin and
provide functionality via invokable slots
of the native interface.
- Remove XLib-dependency of widgets/utils.
- Reintroduce tracking of tray window destruction
and recreation, which was removed in the XLib-code
when porting it from Qt 4 to Qt 5.
This paves the way for implementing the tray icon
completely in terms of QPlatformSystemTrayIcon at some point
later.
Change-Id: Ia04268b0e2919c05874a3e9548930535332897c7
Reviewed-by: Alberto Mardegan <mardy@users.sourceforge.net>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbnativeinterface.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 9e9fd2914f..1c9903e234 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -42,7 +42,9 @@ #include "qxcbnativeinterface.h" #include "qxcbscreen.h" +#include "qxcbwindow.h" #include "qxcbintegration.h" +#include "qxcbsystemtraytracker.h" #include <private/qguiapplication_p.h> #include <QtCore/QMap> @@ -82,6 +84,7 @@ public: insert("appusertime",QXcbNativeInterface::AppUserTime); insert("hintstyle", QXcbNativeInterface::ScreenHintStyle); insert("startupid", QXcbNativeInterface::StartupId); + insert(QByteArrayLiteral("traywindow"), QXcbNativeInterface::TrayWindow); } }; @@ -100,6 +103,36 @@ void QXcbNativeInterface::beep() // For QApplication::beep() xcb_bell(connection, 0); } +static inline QXcbSystemTrayTracker *systemTrayTracker(const QScreen *s) +{ + return static_cast<const QXcbScreen *>(s->handle())->connection()->systemTrayTracker(); +} + +bool QXcbNativeInterface::systemTrayAvailable(const QScreen *screen) const +{ + return systemTrayTracker(screen); +} + +bool QXcbNativeInterface::requestSystemTrayWindowDock(const QWindow *window) +{ + const QPlatformWindow *platformWindow = window->handle(); + if (!platformWindow) + return false; + QXcbSystemTrayTracker *trayTracker = systemTrayTracker(window->screen()); + if (!trayTracker) + return false; + trayTracker->requestSystemTrayWindowDock(static_cast<const QXcbWindow *>(platformWindow)->xcb_window()); + return true; +} + +QRect QXcbNativeInterface::systemTrayWindowGlobalGeometry(const QWindow *window) +{ + if (const QPlatformWindow *platformWindow = window->handle()) + if (const QXcbSystemTrayTracker *trayTracker = systemTrayTracker(window->screen())) + return trayTracker->systemTrayWindowGlobalGeometry(static_cast<const QXcbWindow *>(platformWindow)->xcb_window()); + return QRect(); +} + void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString) { QByteArray lowerCaseResource = resourceString.toLower(); @@ -162,6 +195,11 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q break; case ScreenHintStyle: result = reinterpret_cast<void *>(xcbScreen->hintStyle() + 1); + break; + case TrayWindow: + if (QXcbSystemTrayTracker *s = systemTrayTracker(screen)) + result = (void *)quintptr(s->trayWindow()); + break; default: break; } |