Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.cpp.systemtrayicon qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.cpp
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.cpp.systemtrayicon	2014-03-30 15:36:45.000000000 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.cpp	2014-03-31 18:16:39.707974934 -0500
Rex Dieter 8ec4a9
@@ -158,15 +158,23 @@ void Window::createIconGroupBox()
Rex Dieter 9f99ed
     iconComboBox->addItem(QIcon(":/images/bad.svg"), tr("Bad"));
Rex Dieter 9f99ed
     iconComboBox->addItem(QIcon(":/images/heart.svg"), tr("Heart"));
Rex Dieter 9f99ed
     iconComboBox->addItem(QIcon(":/images/trash.svg"), tr("Trash"));
Rex Dieter 9f99ed
+    iconComboBox->addItem(QIcon::fromTheme("system-file-manager"), tr("File Manager"));
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
     showIconCheckBox = new QCheckBox(tr("Show icon"));
Rex Dieter 9f99ed
     showIconCheckBox->setChecked(true);
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    jitToolTipCheckBox = new QCheckBox(tr("Just In Time Tooltip"));
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
     QHBoxLayout *iconLayout = new QHBoxLayout;
Rex Dieter 9f99ed
     iconLayout->addWidget(iconLabel);
Rex Dieter 9f99ed
     iconLayout->addWidget(iconComboBox);
Rex Dieter 9f99ed
     iconLayout->addStretch();
Rex Dieter 9f99ed
     iconLayout->addWidget(showIconCheckBox);
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    iconLayout->addWidget(jitToolTipCheckBox);
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
     iconGroupBox->setLayout(iconLayout);
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 8ec4a9
@@ -254,5 +262,37 @@ void Window::createTrayIcon()
Rex Dieter 9f99ed
     trayIconMenu->addAction(quitAction);
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
     trayIcon = new QSystemTrayIcon(this);
Rex Dieter 9f99ed
+    QByteArray category = qgetenv("SNI_CATEGORY");
Rex Dieter 9f99ed
+    if (!category.isEmpty()) {
Rex Dieter 9f99ed
+        trayIcon->setProperty("_qt_sni_category", QString::fromLocal8Bit(category));
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
     trayIcon->setContextMenu(trayIconMenu);
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    trayIcon->installEventFilter(this);
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+bool Window::eventFilter(QObject *, QEvent *event)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    switch(event->type()) {
Rex Dieter 9f99ed
+    case QEvent::ToolTip:
Rex Dieter 9f99ed
+        if (jitToolTipCheckBox->isChecked()) {
Rex Dieter 9f99ed
+            QString timeString = QTime::currentTime().toString();
Rex Dieter 9f99ed
+            trayIcon->setToolTip(tr("Current Time: %1").arg(timeString));
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+        break;
Rex Dieter 9f99ed
+    case QEvent::Wheel: {
Rex Dieter 9f99ed
+        QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);
Rex Dieter 9f99ed
+        int delta = wheelEvent->delta() > 0 ? 1 : -1;
Rex Dieter 9f99ed
+        int index = (iconComboBox->currentIndex() + delta) % iconComboBox->count();
Rex Dieter 9f99ed
+        iconComboBox->setCurrentIndex(index);
Rex Dieter 9f99ed
+        break;
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    default:
Rex Dieter 9f99ed
+        break;
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    return false;
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
+#endif
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.h.systemtrayicon qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.h
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.h.systemtrayicon	2014-03-30 15:36:45.000000000 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/examples/desktop/systray/window.h	2014-03-31 18:16:39.707974934 -0500
Rex Dieter 8ec4a9
@@ -69,6 +69,9 @@ public:
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 protected:
Rex Dieter 9f99ed
     void closeEvent(QCloseEvent *event);
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    bool eventFilter(QObject *object, QEvent *event);
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 private slots:
Rex Dieter 9f99ed
     void setIcon(int index);
Rex Dieter 8ec4a9
@@ -86,6 +89,9 @@ private:
Rex Dieter 9f99ed
     QLabel *iconLabel;
Rex Dieter 9f99ed
     QComboBox *iconComboBox;
Rex Dieter 9f99ed
     QCheckBox *showIconCheckBox;
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    QCheckBox *jitToolTipCheckBox;
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
     QGroupBox *messageGroupBox;
Rex Dieter 9f99ed
     QLabel *typeLabel;
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys.cpp.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys.cpp
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys.cpp.systemtrayicon	2014-03-31 18:16:39.707974934 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys.cpp	2014-03-31 18:16:39.707974934 -0500
Rex Dieter 9f99ed
@@ -0,0 +1,65 @@
Rex Dieter 9f99ed
+/****************************************************************************
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
Rex Dieter 9f99ed
+** All rights reserved.
Rex Dieter 9f99ed
+** Contact: Nokia Corporation (qt-info@nokia.com)
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** This file is part of the QtGui module of the Qt Toolkit.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_BEGIN_LICENSE:LGPL$
Rex Dieter 9f99ed
+** GNU Lesser General Public License Usage
Rex Dieter 9f99ed
+** This file may be used under the terms of the GNU Lesser General Public
Rex Dieter 9f99ed
+** License version 2.1 as published by the Free Software Foundation and
Rex Dieter 9f99ed
+** appearing in the file LICENSE.LGPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU Lesser
Rex Dieter 9f99ed
+** General Public License version 2.1 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** In addition, as a special exception, Nokia gives you certain additional
Rex Dieter 9f99ed
+** rights. These rights are described in the Nokia Qt LGPL Exception
Rex Dieter 9f99ed
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** GNU General Public License Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used under the terms of the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 as published by the Free Software Foundation
Rex Dieter 9f99ed
+** and appearing in the file LICENSE.GPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/copyleft/gpl.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Other Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used in accordance with the terms and
Rex Dieter 9f99ed
+** conditions contained in a signed written agreement between you and Nokia.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_END_LICENSE$
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+****************************************************************************/
Rex Dieter 9f99ed
+#ifndef QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#include "qabstractsystemtrayiconsys_p.h"
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QSystemTrayIconSysFactoryInterface::QSystemTrayIconSysFactoryInterface()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+/////////////////////////////////////////////////
Rex Dieter 9f99ed
+QAbstractSystemTrayIconSys::QAbstractSystemTrayIconSys(QSystemTrayIcon *icon)
Rex Dieter 9f99ed
+: trayIcon(icon)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QAbstractSystemTrayIconSys::~QAbstractSystemTrayIconSys()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QAbstractSystemTrayIconSys::sendActivated(QSystemTrayIcon::ActivationReason reason)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    qtsystray_sendActivated(trayIcon, reason);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#endif
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys_p.h.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys_p.h
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys_p.h.systemtrayicon	2014-03-31 18:16:39.708974924 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qabstractsystemtrayiconsys_p.h	2014-03-31 18:16:39.708974924 -0500
Rex Dieter 9f99ed
@@ -0,0 +1,106 @@
Rex Dieter 9f99ed
+/****************************************************************************
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
Rex Dieter 9f99ed
+** All rights reserved.
Rex Dieter 9f99ed
+** Contact: Nokia Corporation (qt-info@nokia.com)
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** This file is part of the QtGui module of the Qt Toolkit.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_BEGIN_LICENSE:LGPL$
Rex Dieter 9f99ed
+** GNU Lesser General Public License Usage
Rex Dieter 9f99ed
+** This file may be used under the terms of the GNU Lesser General Public
Rex Dieter 9f99ed
+** License version 2.1 as published by the Free Software Foundation and
Rex Dieter 9f99ed
+** appearing in the file LICENSE.LGPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU Lesser
Rex Dieter 9f99ed
+** General Public License version 2.1 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** In addition, as a special exception, Nokia gives you certain additional
Rex Dieter 9f99ed
+** rights. These rights are described in the Nokia Qt LGPL Exception
Rex Dieter 9f99ed
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** GNU General Public License Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used under the terms of the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 as published by the Free Software Foundation
Rex Dieter 9f99ed
+** and appearing in the file LICENSE.GPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/copyleft/gpl.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Other Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used in accordance with the terms and
Rex Dieter 9f99ed
+** conditions contained in a signed written agreement between you and Nokia.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_END_LICENSE$
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+****************************************************************************/
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#ifndef QABSTRACTSYSTEMTRAYICONSYS_P_H
Rex Dieter 9f99ed
+#define QABSTRACTSYSTEMTRAYICONSYS_P_H
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+//  W A R N I N G
Rex Dieter 9f99ed
+//  -------------
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+// This file is not part of the Qt API.  It exists for the convenience
Rex Dieter 9f99ed
+// of a number of Qt sources files.  This header file may change from
Rex Dieter 9f99ed
+// version to version without notice, or even be removed.
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+// We mean it.
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#ifndef QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#include <qfactoryinterface.h>
Rex Dieter 9f99ed
+#include <qsystemtrayicon.h>
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class QAbstractSystemTrayIconSys;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class Q_GUI_EXPORT QSystemTrayIconSysFactoryInterface : public QObject, public QFactoryInterface
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    Q_OBJECT
Rex Dieter 9f99ed
+public:
Rex Dieter 9f99ed
+    QSystemTrayIconSysFactoryInterface();
Rex Dieter 9f99ed
+    virtual QAbstractSystemTrayIconSys * create(QSystemTrayIcon *) = 0;
Rex Dieter 9f99ed
+    virtual bool isAvailable() const = 0;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    // \reimp
Rex Dieter 9f99ed
+    virtual QStringList keys() const { return QStringList() << QLatin1String("default"); }
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+Q_SIGNALS:
Rex Dieter 9f99ed
+    void availableChanged(bool);
Rex Dieter 9f99ed
+};
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#define QSystemTrayIconSysFactoryInterface_iid "com.nokia.qt.QSystemTrayIconSysFactoryInterface"
Rex Dieter 9f99ed
+Q_DECLARE_INTERFACE(QSystemTrayIconSysFactoryInterface, QSystemTrayIconSysFactoryInterface_iid)
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class QRect;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class Q_GUI_EXPORT QAbstractSystemTrayIconSys
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+public:
Rex Dieter 9f99ed
+    QAbstractSystemTrayIconSys(QSystemTrayIcon *icon);
Rex Dieter 9f99ed
+    virtual ~QAbstractSystemTrayIconSys();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    virtual QRect geometry() const = 0;
Rex Dieter 9f99ed
+    virtual void updateVisibility() = 0;
Rex Dieter 9f99ed
+    virtual void updateIcon() = 0;
Rex Dieter 9f99ed
+    virtual void updateToolTip() = 0;
Rex Dieter 9f99ed
+    virtual void updateMenu() = 0;
Rex Dieter 9f99ed
+    virtual void showMessage(const QString &title, const QString &message,
Rex Dieter 9f99ed
+                     QSystemTrayIcon::MessageIcon icon, int msecs) = 0;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void sendActivated(QSystemTrayIcon::ActivationReason);
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+protected:
Rex Dieter 9f99ed
+    QSystemTrayIcon *trayIcon;
Rex Dieter 9f99ed
+};
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#endif // QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#endif // QABSTRACTSYSTEMTRAYICONSYS_P_H
Rex Dieter 9f99ed
+
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon.cpp.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon.cpp
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon.cpp.systemtrayicon	2014-03-30 15:36:49.000000000 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon.cpp	2014-03-31 18:16:39.708974924 -0500
Rex Dieter 8ec4a9
@@ -287,12 +287,6 @@ bool QSystemTrayIcon::isVisible() const
Rex Dieter 9f99ed
 */
Rex Dieter 9f99ed
 bool QSystemTrayIcon::event(QEvent *e)
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-#if defined(Q_WS_X11)
Rex Dieter 9f99ed
-    if (e->type() == QEvent::ToolTip) {
Rex Dieter 9f99ed
-        Q_D(QSystemTrayIcon);
Rex Dieter 9f99ed
-        return d->sys->deliverToolTipEvent(e);
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-#endif
Rex Dieter 9f99ed
     return QObject::event(e);
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_p.h.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_p.h
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_p.h.systemtrayicon	2014-03-30 15:36:49.000000000 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_p.h	2014-03-31 18:16:39.708974924 -0500
Rex Dieter 9f99ed
@@ -62,10 +62,17 @@
Rex Dieter 9f99ed
 #include "QtGui/qpixmap.h"
Rex Dieter 9f99ed
 #include "QtCore/qstring.h"
Rex Dieter 9f99ed
 #include "QtCore/qpointer.h"
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+#include "QtCore/qset.h"
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 QT_BEGIN_NAMESPACE
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
+#if defined(Q_WS_X11)
Rex Dieter 9f99ed
+class QAbstractSystemTrayIconSys;
Rex Dieter 9f99ed
+#else
Rex Dieter 9f99ed
 class QSystemTrayIconSys;
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
 class QToolButton;
Rex Dieter 9f99ed
 class QLabel;
Rex Dieter 9f99ed
 
Rex Dieter 8ec4a9
@@ -75,6 +82,9 @@ class QSystemTrayIconPrivate : public QO
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 public:
Rex Dieter 9f99ed
     QSystemTrayIconPrivate() : sys(0), visible(false) { }
Rex Dieter 9f99ed
+    #if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    ~QSystemTrayIconPrivate();
Rex Dieter 9f99ed
+    #endif
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
     void install_sys();
Rex Dieter 9f99ed
     void remove_sys();
Rex Dieter 8ec4a9
@@ -90,7 +100,11 @@ public:
Rex Dieter 9f99ed
     QPointer<QMenu> menu;
Rex Dieter 9f99ed
     QIcon icon;
Rex Dieter 9f99ed
     QString toolTip;
Rex Dieter 9f99ed
+    #if defined(Q_WS_X11)
Rex Dieter 9f99ed
+    QAbstractSystemTrayIconSys *sys;
Rex Dieter 9f99ed
+    #else
Rex Dieter 9f99ed
     QSystemTrayIconSys *sys;
Rex Dieter 9f99ed
+    #endif
Rex Dieter 9f99ed
     bool visible;
Rex Dieter 9f99ed
 };
Rex Dieter 9f99ed
 
Rex Dieter 8ec4a9
@@ -123,60 +137,37 @@ private:
Rex Dieter 9f99ed
 };
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 #if defined(Q_WS_X11)
Rex Dieter 9f99ed
-QT_BEGIN_INCLUDE_NAMESPACE
Rex Dieter 9f99ed
-#include <QtCore/qcoreapplication.h>
Rex Dieter 9f99ed
-#include <X11/Xlib.h>
Rex Dieter 9f99ed
-#include <X11/Xatom.h>
Rex Dieter 9f99ed
-#include <X11/Xutil.h>
Rex Dieter 9f99ed
-QT_END_INCLUDE_NAMESPACE
Rex Dieter 9f99ed
+class QSystemTrayIconSysFactoryInterface;
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-class QSystemTrayIconSys : public QWidget
Rex Dieter 9f99ed
+/**
Rex Dieter 9f99ed
+ * This class acts as a composite QSystemTrayIconSysFactory: It can create
Rex Dieter 9f99ed
+ * instances of QAbstractSystemTrayIconSys* using either a plugin or the
Rex Dieter 9f99ed
+ * builtin factory and will cause QSystemTrayIconPrivate to recreate their
Rex Dieter 9f99ed
+ * 'sys' instances if the plugin availability changes.
Rex Dieter 9f99ed
+ */
Rex Dieter 9f99ed
+class QSystemTrayIconSysFactory : public QObject
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    friend class QSystemTrayIconPrivate;
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
+    Q_OBJECT
Rex Dieter 9f99ed
 public:
Rex Dieter 9f99ed
-    QSystemTrayIconSys(QSystemTrayIcon *q);
Rex Dieter 9f99ed
-    ~QSystemTrayIconSys();
Rex Dieter 9f99ed
-    enum {
Rex Dieter 9f99ed
-        SYSTEM_TRAY_REQUEST_DOCK = 0,
Rex Dieter 9f99ed
-        SYSTEM_TRAY_BEGIN_MESSAGE = 1,
Rex Dieter 9f99ed
-        SYSTEM_TRAY_CANCEL_MESSAGE =2
Rex Dieter 9f99ed
-    };
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    void addToTray();
Rex Dieter 9f99ed
-    void updateIcon();
Rex Dieter 9f99ed
-    XVisualInfo* getSysTrayVisualInfo();
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    // QObject::event is public but QWidget's ::event() re-implementation
Rex Dieter 9f99ed
-    // is protected ;(
Rex Dieter 9f99ed
-    inline bool deliverToolTipEvent(QEvent *e)
Rex Dieter 9f99ed
-    { return QWidget::event(e); }
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    static Window sysTrayWindow;
Rex Dieter 9f99ed
-    static QList<QSystemTrayIconSys *> trayIcons;
Rex Dieter 9f99ed
-    static QCoreApplication::EventFilter oldEventFilter;
Rex Dieter 9f99ed
-    static bool sysTrayTracker(void *message, long *result);
Rex Dieter 9f99ed
-    static Window locateSystemTray();
Rex Dieter 9f99ed
-    static Atom sysTraySelection;
Rex Dieter 9f99ed
-    static XVisualInfo sysTrayVisual;
Rex Dieter 9f99ed
+    QSystemTrayIconSysFactory();
Rex Dieter 9f99ed
+    void registerSystemTrayIconPrivate(QSystemTrayIconPrivate *iconPrivate);
Rex Dieter 9f99ed
+    void unregisterSystemTrayIconPrivate(QSystemTrayIconPrivate *iconPrivate);
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-protected:
Rex Dieter 9f99ed
-    void paintEvent(QPaintEvent *pe);
Rex Dieter 9f99ed
-    void resizeEvent(QResizeEvent *re);
Rex Dieter 9f99ed
-    bool x11Event(XEvent *event);
Rex Dieter 9f99ed
-    void mousePressEvent(QMouseEvent *event);
Rex Dieter 9f99ed
-    void mouseDoubleClickEvent(QMouseEvent *event);
Rex Dieter 9f99ed
-#ifndef QT_NO_WHEELEVENT
Rex Dieter 9f99ed
-    void wheelEvent(QWheelEvent *event);
Rex Dieter 9f99ed
-#endif
Rex Dieter 9f99ed
-    bool event(QEvent *e);
Rex Dieter 9f99ed
+    QAbstractSystemTrayIconSys *create(QSystemTrayIcon *) const;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    bool isAvailable() const;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+private Q_SLOTS:
Rex Dieter 9f99ed
+    void refreshTrayIconPrivates();
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 private:
Rex Dieter 9f99ed
-    QPixmap background;
Rex Dieter 9f99ed
-    QSystemTrayIcon *q;
Rex Dieter 9f99ed
-    Colormap colormap;
Rex Dieter 9f99ed
+    QSystemTrayIconSysFactoryInterface *factory() const;
Rex Dieter 9f99ed
+    void loadPluginFactory();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    QSystemTrayIconSysFactoryInterface *pluginFactory;
Rex Dieter 9f99ed
+    QSet<QSystemTrayIconPrivate *> trayIconPrivates;
Rex Dieter 9f99ed
 };
Rex Dieter 9f99ed
-#endif // Q_WS_X11
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 QT_END_NAMESPACE
Rex Dieter 9f99ed
 
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_x11.cpp.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_x11.cpp
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_x11.cpp.systemtrayicon	2014-03-30 15:36:49.000000000 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qsystemtrayicon_x11.cpp	2014-03-31 18:16:39.709974914 -0500
Rex Dieter 9f99ed
@@ -38,311 +38,122 @@
Rex Dieter 9f99ed
 ** $QT_END_LICENSE$
Rex Dieter 9f99ed
 **
Rex Dieter 9f99ed
 ****************************************************************************/
Rex Dieter 9f99ed
+#ifndef QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#include <private/qfactoryloader_p.h>
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-#include "private/qt_x11_p.h"
Rex Dieter 9f99ed
-#include "qlabel.h"
Rex Dieter 9f99ed
-#include "qx11info_x11.h"
Rex Dieter 9f99ed
-#include "qpainter.h"
Rex Dieter 9f99ed
-#include "qpixmap.h"
Rex Dieter 9f99ed
-#include "qbitmap.h"
Rex Dieter 9f99ed
-#include "qevent.h"
Rex Dieter 9f99ed
-#include "qapplication.h"
Rex Dieter 9f99ed
-#include "qlist.h"
Rex Dieter 9f99ed
-#include "qmenu.h"
Rex Dieter 9f99ed
-#include "qtimer.h"
Rex Dieter 9f99ed
 #include "qsystemtrayicon_p.h"
Rex Dieter 9f99ed
-#include "qpaintengine.h"
Rex Dieter 9f99ed
+#include "qabstractsystemtrayiconsys_p.h"
Rex Dieter 9f99ed
+#include "qcoreapplication.h"
Rex Dieter 9f99ed
+#include "qxembedsystemtrayicon_x11_p.h"
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-#ifndef QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
 QT_BEGIN_NAMESPACE
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-Window QSystemTrayIconSys::sysTrayWindow = XNone;
Rex Dieter 9f99ed
-QList<QSystemTrayIconSys *> QSystemTrayIconSys::trayIcons;
Rex Dieter 9f99ed
-QCoreApplication::EventFilter QSystemTrayIconSys::oldEventFilter = 0;
Rex Dieter 9f99ed
-Atom QSystemTrayIconSys::sysTraySelection = XNone;
Rex Dieter 9f99ed
-XVisualInfo QSystemTrayIconSys::sysTrayVisual = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-// Locate the system tray
Rex Dieter 9f99ed
-Window QSystemTrayIconSys::locateSystemTray()
Rex Dieter 9f99ed
-{
Rex Dieter 9f99ed
-    Display *display = QX11Info::display();
Rex Dieter 9f99ed
-    if (sysTraySelection == XNone) {
Rex Dieter 9f99ed
-        int screen = QX11Info::appScreen();
Rex Dieter 9f99ed
-        QString net_sys_tray = QString::fromLatin1("_NET_SYSTEM_TRAY_S%1").arg(screen);
Rex Dieter 9f99ed
-        sysTraySelection = XInternAtom(display, net_sys_tray.toLatin1(), False);
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    return XGetSelectionOwner(QX11Info::display(), sysTraySelection);
Rex Dieter 9f99ed
-}
Rex Dieter 9f99ed
+Q_GLOBAL_STATIC(QSystemTrayIconSysFactory, qt_guiSystemTrayIconSysFactory)
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-XVisualInfo* QSystemTrayIconSys::getSysTrayVisualInfo()
Rex Dieter 9f99ed
+QSystemTrayIconSysFactory::QSystemTrayIconSysFactory()
Rex Dieter 9f99ed
+: pluginFactory(0)
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    Display *display = QX11Info::display();
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    if (!sysTrayVisual.visual) {
Rex Dieter 9f99ed
-        Window win = locateSystemTray();
Rex Dieter 9f99ed
-        if (win != XNone) {
Rex Dieter 9f99ed
-            Atom actual_type;
Rex Dieter 9f99ed
-            int actual_format;
Rex Dieter 9f99ed
-            ulong nitems, bytes_remaining;
Rex Dieter 9f99ed
-            uchar *data = 0;
Rex Dieter 9f99ed
-            int result = XGetWindowProperty(display, win, ATOM(_NET_SYSTEM_TRAY_VISUAL), 0, 1,
Rex Dieter 9f99ed
-                                            False, XA_VISUALID, &actual_type,
Rex Dieter 9f99ed
-                                            &actual_format, &nitems, &bytes_remaining, &data);
Rex Dieter 9f99ed
-            VisualID vid = 0;
Rex Dieter 9f99ed
-            if (result == Success && data && actual_type == XA_VISUALID && actual_format == 32 &&
Rex Dieter 9f99ed
-                nitems == 1 && bytes_remaining == 0)
Rex Dieter 9f99ed
-                vid = *(VisualID*)data;
Rex Dieter 9f99ed
-            if (data)
Rex Dieter 9f99ed
-                XFree(data);
Rex Dieter 9f99ed
-            if (vid == 0)
Rex Dieter 9f99ed
-                return 0;
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-            uint mask = VisualIDMask;
Rex Dieter 9f99ed
-            XVisualInfo *vi, rvi;
Rex Dieter 9f99ed
-            int count;
Rex Dieter 9f99ed
-            rvi.visualid = vid;
Rex Dieter 9f99ed
-            vi = XGetVisualInfo(display, mask, &rvi, &count);
Rex Dieter 9f99ed
-            if (vi) {
Rex Dieter 9f99ed
-                sysTrayVisual = vi[0];
Rex Dieter 9f99ed
-                XFree((char*)vi);
Rex Dieter 9f99ed
-            }
Rex Dieter 9f99ed
-            if (sysTrayVisual.depth != 32)
Rex Dieter 9f99ed
-                memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
-        }
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    return sysTrayVisual.visual ? &sysTrayVisual : 0;
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result)
Rex Dieter 9f99ed
+void QSystemTrayIconSysFactory::loadPluginFactory()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    bool retval = false;
Rex Dieter 9f99ed
-    if (QSystemTrayIconSys::oldEventFilter)
Rex Dieter 9f99ed
-        retval = QSystemTrayIconSys::oldEventFilter(message, result);
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    if (trayIcons.isEmpty())
Rex Dieter 9f99ed
-        return retval;
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    Display *display = QX11Info::display();
Rex Dieter 9f99ed
-    XEvent *ev = (XEvent *)message;
Rex Dieter 9f99ed
-    if  (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) {
Rex Dieter 9f99ed
-	sysTrayWindow = locateSystemTray();
Rex Dieter 9f99ed
-        memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
-        for (int i = 0; i < trayIcons.count(); i++) {
Rex Dieter 9f99ed
-            if (sysTrayWindow == XNone) {
Rex Dieter 9f99ed
-	        QBalloonTip::hideBalloon();
Rex Dieter 9f99ed
-                trayIcons[i]->hide(); // still no luck
Rex Dieter 9f99ed
-                trayIcons[i]->destroy();
Rex Dieter 9f99ed
-                trayIcons[i]->create();
Rex Dieter 9f99ed
-	    } else
Rex Dieter 9f99ed
-                trayIcons[i]->addToTray(); // add it to the new tray
Rex Dieter 9f99ed
-        }
Rex Dieter 9f99ed
-        retval = true;
Rex Dieter 9f99ed
-    } else if (ev->type == ClientMessage && sysTrayWindow == XNone) {
Rex Dieter 9f99ed
-        static Atom manager_atom = XInternAtom(display, "MANAGER", False);
Rex Dieter 9f99ed
-        XClientMessageEvent *cm = (XClientMessageEvent *)message;
Rex Dieter 9f99ed
-        if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) {
Rex Dieter 9f99ed
-	    sysTrayWindow = cm->data.l[2];
Rex Dieter 9f99ed
-            memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
-	    XSelectInput(display, sysTrayWindow, StructureNotifyMask);
Rex Dieter 9f99ed
-            for (int i = 0; i < trayIcons.count(); i++) {
Rex Dieter 9f99ed
-                trayIcons[i]->addToTray();
Rex Dieter 9f99ed
-            }
Rex Dieter 9f99ed
-            retval = true;
Rex Dieter 9f99ed
-        }
Rex Dieter 9f99ed
-    } else if (ev->type == PropertyNotify && ev->xproperty.atom == ATOM(_NET_SYSTEM_TRAY_VISUAL) &&
Rex Dieter 9f99ed
-               ev->xproperty.window == sysTrayWindow) {
Rex Dieter 9f99ed
-        memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
-        for (int i = 0; i < trayIcons.count(); i++) {
Rex Dieter 9f99ed
-            trayIcons[i]->addToTray();
Rex Dieter 9f99ed
-        }
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    return retval;
Rex Dieter 9f99ed
-}
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q)
Rex Dieter 9f99ed
-    : QWidget(0, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint),
Rex Dieter 9f99ed
-      q(q), colormap(0)
Rex Dieter 9f99ed
-{
Rex Dieter 9f99ed
-    setAttribute(Qt::WA_AlwaysShowToolTips);
Rex Dieter 9f99ed
-    setAttribute(Qt::WA_QuitOnClose, false);
Rex Dieter 9f99ed
-    setAttribute(Qt::WA_NoSystemBackground, true);
Rex Dieter 9f99ed
-    setAttribute(Qt::WA_PaintOnScreen);
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    static bool eventFilterAdded = false;
Rex Dieter 9f99ed
-    Display *display = QX11Info::display();
Rex Dieter 9f99ed
-    if (!eventFilterAdded) {
Rex Dieter 9f99ed
-        oldEventFilter = qApp->setEventFilter(sysTrayTracker);
Rex Dieter 9f99ed
-	eventFilterAdded = true;
Rex Dieter 9f99ed
-	Window root = QX11Info::appRootWindow();
Rex Dieter 9f99ed
-        XWindowAttributes attr;
Rex Dieter 9f99ed
-        XGetWindowAttributes(display, root, &attr);
Rex Dieter 9f99ed
-        if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) {
Rex Dieter 9f99ed
-            (void) QApplication::desktop(); // lame trick to ensure our event mask is not overridden
Rex Dieter 9f99ed
-            XSelectInput(display, root, attr.your_event_mask | StructureNotifyMask); // for MANAGER selection
Rex Dieter 9f99ed
-        }
Rex Dieter 9f99ed
+    if (pluginFactory) {
Rex Dieter 9f99ed
+        return;
Rex Dieter 9f99ed
     }
Rex Dieter 9f99ed
-    if (trayIcons.isEmpty()) {
Rex Dieter 9f99ed
-        sysTrayWindow = locateSystemTray();
Rex Dieter 9f99ed
-	if (sysTrayWindow != XNone)
Rex Dieter 9f99ed
-	    XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events
Rex Dieter 9f99ed
+#ifndef QT_NO_LIBRARY
Rex Dieter 9f99ed
+    QFactoryLoader loader(QSystemTrayIconSysFactoryInterface_iid, QLatin1String("/systemtrayicon"));
Rex Dieter 9f99ed
+    pluginFactory = qobject_cast<QSystemTrayIconSysFactoryInterface *>(loader.instance(QLatin1String("default")));
Rex Dieter 9f99ed
+    if (pluginFactory) {
Rex Dieter 9f99ed
+        // Set parent to ensure factory destructor is called when application
Rex Dieter 9f99ed
+        // is closed
Rex Dieter 9f99ed
+        pluginFactory->setParent(QCoreApplication::instance());
Rex Dieter 9f99ed
+        connect(pluginFactory, SIGNAL(availableChanged(bool)), SLOT(refreshTrayIconPrivates()));
Rex Dieter 9f99ed
     }
Rex Dieter 9f99ed
-    trayIcons.append(this);
Rex Dieter 9f99ed
-    setMouseTracking(true);
Rex Dieter 9f99ed
-#ifndef QT_NO_TOOLTIP
Rex Dieter 9f99ed
-    setToolTip(q->toolTip());
Rex Dieter 9f99ed
-#endif
Rex Dieter 9f99ed
-    if (sysTrayWindow != XNone)
Rex Dieter 9f99ed
-        addToTray();
Rex Dieter 9f99ed
+#endif // QT_NO_LIBRARY
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-QSystemTrayIconSys::~QSystemTrayIconSys()
Rex Dieter 9f99ed
+QSystemTrayIconSysFactoryInterface *QSystemTrayIconSysFactory::factory() const
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    trayIcons.removeAt(trayIcons.indexOf(this));
Rex Dieter 9f99ed
-    Display *display = QX11Info::display();
Rex Dieter 9f99ed
-    if (trayIcons.isEmpty()) {
Rex Dieter 9f99ed
-        if (sysTrayWindow == XNone)
Rex Dieter 9f99ed
-            return;
Rex Dieter 9f99ed
-        if (display)
Rex Dieter 9f99ed
-            XSelectInput(display, sysTrayWindow, 0); // stop tracking the tray
Rex Dieter 9f99ed
-        sysTrayWindow = XNone;
Rex Dieter 9f99ed
+    if (!pluginFactory) {
Rex Dieter 9f99ed
+        const_cast<QSystemTrayIconSysFactory*>(this)->loadPluginFactory();
Rex Dieter 9f99ed
     }
Rex Dieter 9f99ed
-    if (colormap)
Rex Dieter 9f99ed
-        XFreeColormap(display, colormap);
Rex Dieter 9f99ed
+    if (pluginFactory && pluginFactory->isAvailable()) {
Rex Dieter 9f99ed
+        return pluginFactory;
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    static QXEmbedSystemTrayIconSysFactory def;
Rex Dieter 9f99ed
+    return def.isAvailable() ? &def : 0;
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-void QSystemTrayIconSys::addToTray()
Rex Dieter 9f99ed
+void QSystemTrayIconSysFactory::refreshTrayIconPrivates()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    Q_ASSERT(sysTrayWindow != XNone);
Rex Dieter 9f99ed
-    Display *display = QX11Info::display();
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    XVisualInfo *vi = getSysTrayVisualInfo();
Rex Dieter 9f99ed
-    if (vi && vi->visual) {
Rex Dieter 9f99ed
-        Window root = RootWindow(display, vi->screen);
Rex Dieter 9f99ed
-        Window p = root;
Rex Dieter 9f99ed
-        if (QWidget *pw = parentWidget())
Rex Dieter 9f99ed
-            p = pw->effectiveWinId();
Rex Dieter 9f99ed
-        colormap = XCreateColormap(display, root, vi->visual, AllocNone);
Rex Dieter 9f99ed
-        XSetWindowAttributes wsa;
Rex Dieter 9f99ed
-        wsa.background_pixmap = 0;
Rex Dieter 9f99ed
-        wsa.colormap = colormap;
Rex Dieter 9f99ed
-        wsa.background_pixel = 0;
Rex Dieter 9f99ed
-        wsa.border_pixel = 0;
Rex Dieter 9f99ed
-        Window wid = XCreateWindow(display, p, -1, -1, 1, 1,
Rex Dieter 9f99ed
-                                   0, vi->depth, InputOutput, vi->visual,
Rex Dieter 9f99ed
-                                   CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa;;
Rex Dieter 9f99ed
-        create(wid);
Rex Dieter 9f99ed
-    } else {
Rex Dieter 9f99ed
-        XSetWindowBackgroundPixmap(display, winId(), ParentRelative);
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    // GNOME, NET WM Specification
Rex Dieter 9f99ed
-    static Atom netwm_tray_atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False);
Rex Dieter 9f99ed
-    long l[5] = { CurrentTime, SYSTEM_TRAY_REQUEST_DOCK, static_cast<long>(winId()), 0, 0 };
Rex Dieter 9f99ed
-    XEvent ev;
Rex Dieter 9f99ed
-    memset(&ev, 0, sizeof(ev));
Rex Dieter 9f99ed
-    ev.xclient.type = ClientMessage;
Rex Dieter 9f99ed
-    ev.xclient.window = sysTrayWindow;
Rex Dieter 9f99ed
-    ev.xclient.message_type = netwm_tray_atom;
Rex Dieter 9f99ed
-    ev.xclient.format = 32;
Rex Dieter 9f99ed
-    memcpy((char *)&ev.xclient.data, (const char *) l, sizeof(l));
Rex Dieter 9f99ed
-    XSendEvent(display, sysTrayWindow, False, 0, &ev;;
Rex Dieter 9f99ed
-    setMinimumSize(22, 22); // required at least on GNOME
Rex Dieter 9f99ed
-}
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-void QSystemTrayIconSys::updateIcon()
Rex Dieter 9f99ed
-{
Rex Dieter 9f99ed
-    update();
Rex Dieter 9f99ed
-}
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-void QSystemTrayIconSys::resizeEvent(QResizeEvent *re)
Rex Dieter 9f99ed
-{
Rex Dieter 9f99ed
-     QWidget::resizeEvent(re);
Rex Dieter 9f99ed
-     updateIcon();
Rex Dieter 9f99ed
-}
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-void QSystemTrayIconSys::paintEvent(QPaintEvent*)
Rex Dieter 9f99ed
-{
Rex Dieter 9f99ed
-    QPainter p(this);
Rex Dieter 9f99ed
-    if (!getSysTrayVisualInfo()) {
Rex Dieter 9f99ed
-        const QRegion oldSystemClip = p.paintEngine()->systemClip();
Rex Dieter 9f99ed
-        const QRect clearedRect = oldSystemClip.boundingRect();
Rex Dieter 9f99ed
-        XClearArea(QX11Info::display(), winId(), clearedRect.x(), clearedRect.y(),
Rex Dieter 9f99ed
-                   clearedRect.width(), clearedRect.height(), False);
Rex Dieter 9f99ed
-        QPaintEngine *pe = p.paintEngine();
Rex Dieter 9f99ed
-        pe->setSystemClip(clearedRect);
Rex Dieter 9f99ed
-        q->icon().paint(&p, rect());
Rex Dieter 9f99ed
-        pe->setSystemClip(oldSystemClip);
Rex Dieter 9f99ed
-    } else {
Rex Dieter 9f99ed
-        p.setCompositionMode(QPainter::CompositionMode_Source);
Rex Dieter 9f99ed
-        p.fillRect(rect(), Qt::transparent);
Rex Dieter 9f99ed
-        p.setCompositionMode(QPainter::CompositionMode_SourceOver);
Rex Dieter 9f99ed
-        q->icon().paint(&p, rect());
Rex Dieter 9f99ed
+    Q_FOREACH(QSystemTrayIconPrivate *trayIconPrivate, trayIconPrivates) {
Rex Dieter 9f99ed
+        if (trayIconPrivate->sys) {
Rex Dieter 9f99ed
+            delete trayIconPrivate->sys;
Rex Dieter 9f99ed
+            trayIconPrivate->sys = 0;
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+        // When visible is true, sys is usually not 0 but it can be 0 if the
Rex Dieter 9f99ed
+        // call to install_sys() failed.
Rex Dieter 9f99ed
+        if (trayIconPrivate->visible) {
Rex Dieter 9f99ed
+            trayIconPrivate->install_sys();
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
     }
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
Rex Dieter 9f99ed
+void QSystemTrayIconSysFactory::registerSystemTrayIconPrivate(QSystemTrayIconPrivate* trayIconPrivate)
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    QPoint globalPos = ev->globalPos();
Rex Dieter 9f99ed
-    if (ev->button() == Qt::RightButton && q->contextMenu())
Rex Dieter 9f99ed
-        q->contextMenu()->popup(globalPos);
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    if (QBalloonTip::isBalloonVisible()) {
Rex Dieter 9f99ed
-        emit q->messageClicked();
Rex Dieter 9f99ed
-        QBalloonTip::hideBalloon();
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
-    if (ev->button() == Qt::LeftButton)
Rex Dieter 9f99ed
-        emit q->activated(QSystemTrayIcon::Trigger);
Rex Dieter 9f99ed
-    else if (ev->button() == Qt::RightButton)
Rex Dieter 9f99ed
-        emit q->activated(QSystemTrayIcon::Context);
Rex Dieter 9f99ed
-    else if (ev->button() == Qt::MidButton)
Rex Dieter 9f99ed
-        emit q->activated(QSystemTrayIcon::MiddleClick);
Rex Dieter 9f99ed
+    trayIconPrivates.insert(trayIconPrivate);
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-void QSystemTrayIconSys::mouseDoubleClickEvent(QMouseEvent *ev)
Rex Dieter 9f99ed
+void QSystemTrayIconSysFactory::unregisterSystemTrayIconPrivate(QSystemTrayIconPrivate* trayIconPrivate)
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (ev->button() == Qt::LeftButton)
Rex Dieter 9f99ed
-        emit q->activated(QSystemTrayIcon::DoubleClick);
Rex Dieter 9f99ed
+    trayIconPrivates.remove(trayIconPrivate);
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-#ifndef QT_NO_WHEELEVENT
Rex Dieter 9f99ed
-void QSystemTrayIconSys::wheelEvent(QWheelEvent *e)
Rex Dieter 9f99ed
+QAbstractSystemTrayIconSys *QSystemTrayIconSysFactory::create(QSystemTrayIcon *trayIcon) const
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    QApplication::sendEvent(q, e);
Rex Dieter 9f99ed
+    QSystemTrayIconSysFactoryInterface *f = factory();
Rex Dieter 9f99ed
+    if (!f) {
Rex Dieter 9f99ed
+        qWarning("No systemtrayicon available");
Rex Dieter 9f99ed
+        return 0;
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    return f->create(trayIcon);
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
-#endif
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-bool QSystemTrayIconSys::event(QEvent *e)
Rex Dieter 9f99ed
+bool QSystemTrayIconSysFactory::isAvailable() const
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (e->type() == QEvent::ToolTip) {
Rex Dieter 9f99ed
-        return QApplication::sendEvent(q, e);
Rex Dieter 9f99ed
-    }
Rex Dieter 9f99ed
-    return QWidget::event(e);
Rex Dieter 9f99ed
+    return factory();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-bool QSystemTrayIconSys::x11Event(XEvent *event)
Rex Dieter 9f99ed
+////////////////////////////////////////////////
Rex Dieter 9f99ed
+QSystemTrayIconPrivate::~QSystemTrayIconPrivate()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (event->type == ReparentNotify)
Rex Dieter 9f99ed
-        show();
Rex Dieter 9f99ed
-    return QWidget::x11Event(event);
Rex Dieter 9f99ed
+    qt_guiSystemTrayIconSysFactory()->unregisterSystemTrayIconPrivate(this);
Rex Dieter 9f99ed
+    delete sys;
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
-////////////////////////////////////////////////////////////////////////////
Rex Dieter 9f99ed
 void QSystemTrayIconPrivate::install_sys()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
     Q_Q(QSystemTrayIcon);
Rex Dieter 9f99ed
-    if (!sys)
Rex Dieter 9f99ed
-        sys = new QSystemTrayIconSys(q);
Rex Dieter 9f99ed
+    if (!sys) {
Rex Dieter 9f99ed
+        // Register ourself even if create() fails: our "sys" will get created
Rex Dieter 9f99ed
+        // later by refreshTrayIconPrivates() if a systemtray becomes
Rex Dieter 9f99ed
+        // available. This situation can happen for applications which are
Rex Dieter 9f99ed
+        // started at login time, while the desktop itself is starting up.
Rex Dieter 9f99ed
+        qt_guiSystemTrayIconSysFactory()->registerSystemTrayIconPrivate(this);
Rex Dieter 9f99ed
+        sys = qt_guiSystemTrayIconSysFactory()->create(q);
Rex Dieter 9f99ed
+        if (!sys) {
Rex Dieter 9f99ed
+            return;
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    sys->updateVisibility();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 QRect QSystemTrayIconPrivate::geometry_sys() const
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (!sys)
Rex Dieter 9f99ed
-	return QRect();
Rex Dieter 9f99ed
-    return QRect(sys->mapToGlobal(QPoint(0, 0)), sys->size());
Rex Dieter 9f99ed
+    if (!sys || !visible)
Rex Dieter 9f99ed
+        return QRect();
Rex Dieter 9f99ed
+    return sys->geometry();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 void QSystemTrayIconPrivate::remove_sys()
Rex Dieter 8ec4a9
@@ -350,35 +161,35 @@ void QSystemTrayIconPrivate::remove_sys(
Rex Dieter 9f99ed
     if (!sys)
Rex Dieter 9f99ed
         return;
Rex Dieter 9f99ed
     QBalloonTip::hideBalloon();
Rex Dieter 9f99ed
-    sys->hide(); // this should do the trick, but...
Rex Dieter 9f99ed
-    delete sys; // wm may resize system tray only for DestroyEvents
Rex Dieter 9f99ed
-    sys = 0;
Rex Dieter 9f99ed
+    sys->updateVisibility();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 void QSystemTrayIconPrivate::updateIcon_sys()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (!sys)
Rex Dieter 9f99ed
+    if (!sys || !visible)
Rex Dieter 9f99ed
         return;
Rex Dieter 9f99ed
     sys->updateIcon();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 void QSystemTrayIconPrivate::updateMenu_sys()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-
Rex Dieter 9f99ed
+    if (!sys || !visible)
Rex Dieter 9f99ed
+        return;
Rex Dieter 9f99ed
+    sys->updateMenu();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 void QSystemTrayIconPrivate::updateToolTip_sys()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (!sys)
Rex Dieter 9f99ed
+    if (!sys || !visible)
Rex Dieter 9f99ed
         return;
Rex Dieter 9f99ed
 #ifndef QT_NO_TOOLTIP
Rex Dieter 9f99ed
-    sys->setToolTip(toolTip);
Rex Dieter 9f99ed
+    sys->updateToolTip();
Rex Dieter 9f99ed
 #endif
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    return QSystemTrayIconSys::locateSystemTray() != XNone;
Rex Dieter 9f99ed
+    return qt_guiSystemTrayIconSysFactory()->isAvailable();
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 bool QSystemTrayIconPrivate::supportsMessages_sys()
Rex Dieter 8ec4a9
@@ -389,12 +200,9 @@ bool QSystemTrayIconPrivate::supportsMes
Rex Dieter 9f99ed
 void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title,
Rex Dieter 9f99ed
                                    QSystemTrayIcon::MessageIcon icon, int msecs)
Rex Dieter 9f99ed
 {
Rex Dieter 9f99ed
-    if (!sys)
Rex Dieter 9f99ed
+    if (!sys || !visible)
Rex Dieter 9f99ed
         return;
Rex Dieter 9f99ed
-    QPoint g = sys->mapToGlobal(QPoint(0, 0));
Rex Dieter 9f99ed
-    QBalloonTip::showBalloon(icon, message, title, sys->q,
Rex Dieter 9f99ed
-                             QPoint(g.x() + sys->width()/2, g.y() + sys->height()/2),
Rex Dieter 9f99ed
-                             msecs);
Rex Dieter 9f99ed
+    sys->showMessage(message, title, icon, msecs);
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 QT_END_NAMESPACE
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11.cpp.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11.cpp
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11.cpp.systemtrayicon	2014-03-31 18:16:39.709974914 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11.cpp	2014-03-31 18:16:39.709974914 -0500
Rex Dieter 9f99ed
@@ -0,0 +1,469 @@
Rex Dieter 9f99ed
+/****************************************************************************
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
Rex Dieter 9f99ed
+** All rights reserved.
Rex Dieter 9f99ed
+** Contact: Nokia Corporation (qt-info@nokia.com)
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** This file is part of the QtGui module of the Qt Toolkit.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_BEGIN_LICENSE:LGPL$
Rex Dieter 9f99ed
+** GNU Lesser General Public License Usage
Rex Dieter 9f99ed
+** This file may be used under the terms of the GNU Lesser General Public
Rex Dieter 9f99ed
+** License version 2.1 as published by the Free Software Foundation and
Rex Dieter 9f99ed
+** appearing in the file LICENSE.LGPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU Lesser
Rex Dieter 9f99ed
+** General Public License version 2.1 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** In addition, as a special exception, Nokia gives you certain additional
Rex Dieter 9f99ed
+** rights. These rights are described in the Nokia Qt LGPL Exception
Rex Dieter 9f99ed
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** GNU General Public License Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used under the terms of the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 as published by the Free Software Foundation
Rex Dieter 9f99ed
+** and appearing in the file LICENSE.GPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/copyleft/gpl.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Other Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used in accordance with the terms and
Rex Dieter 9f99ed
+** conditions contained in a signed written agreement between you and Nokia.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_END_LICENSE$
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+****************************************************************************/
Rex Dieter 9f99ed
+#include "qxembedsystemtrayicon_x11_p.h"
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#ifndef QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#include "private/qt_x11_p.h"
Rex Dieter 9f99ed
+#include "qapplication.h"
Rex Dieter 9f99ed
+#include "qevent.h"
Rex Dieter 9f99ed
+#include "qlist.h"
Rex Dieter 9f99ed
+#include "qmenu.h"
Rex Dieter 9f99ed
+#include "qpainter.h"
Rex Dieter 9f99ed
+#include "qpaintengine.h"
Rex Dieter 9f99ed
+#include "qsystemtrayicon_p.h"
Rex Dieter 9f99ed
+#include "qx11info_x11.h"
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QT_BEGIN_INCLUDE_NAMESPACE
Rex Dieter 9f99ed
+#include <QtCore/qcoreapplication.h>
Rex Dieter 9f99ed
+#include <X11/Xlib.h>
Rex Dieter 9f99ed
+#include <X11/Xatom.h>
Rex Dieter 9f99ed
+#include <X11/Xutil.h>
Rex Dieter 9f99ed
+QT_END_INCLUDE_NAMESPACE
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QT_BEGIN_NAMESPACE
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class QSystemTrayIconWidget : public QWidget
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+public:
Rex Dieter 9f99ed
+    QSystemTrayIconWidget(QSystemTrayIcon *q, QXEmbedSystemTrayIconSys *s);
Rex Dieter 9f99ed
+    ~QSystemTrayIconWidget();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    static Window locateSystemTray();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+protected:
Rex Dieter 9f99ed
+    void paintEvent(QPaintEvent *pe);
Rex Dieter 9f99ed
+    void resizeEvent(QResizeEvent *re);
Rex Dieter 9f99ed
+    bool x11Event(XEvent *event);
Rex Dieter 9f99ed
+    void mousePressEvent(QMouseEvent *event);
Rex Dieter 9f99ed
+    void mouseDoubleClickEvent(QMouseEvent *event);
Rex Dieter 9f99ed
+#ifndef QT_NO_WHEELEVENT
Rex Dieter 9f99ed
+    void wheelEvent(QWheelEvent *event);
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+    bool event(QEvent *e);
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+private:
Rex Dieter 9f99ed
+    enum {
Rex Dieter 9f99ed
+        SYSTEM_TRAY_REQUEST_DOCK = 0,
Rex Dieter 9f99ed
+        SYSTEM_TRAY_BEGIN_MESSAGE = 1,
Rex Dieter 9f99ed
+        SYSTEM_TRAY_CANCEL_MESSAGE =2
Rex Dieter 9f99ed
+    };
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void addToTray();
Rex Dieter 9f99ed
+    static XVisualInfo* getSysTrayVisualInfo();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    static Window sysTrayWindow;
Rex Dieter 9f99ed
+    static QList<QSystemTrayIconWidget *> trayIcons;
Rex Dieter 9f99ed
+    static QCoreApplication::EventFilter oldEventFilter;
Rex Dieter 9f99ed
+    static bool sysTrayTracker(void *message, long *result);
Rex Dieter 9f99ed
+    static Atom sysTraySelection;
Rex Dieter 9f99ed
+    static XVisualInfo sysTrayVisual;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    QSystemTrayIcon *q;
Rex Dieter 9f99ed
+    QXEmbedSystemTrayIconSys *sys;
Rex Dieter 9f99ed
+    Colormap colormap;
Rex Dieter 9f99ed
+};
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+Window QSystemTrayIconWidget::sysTrayWindow = XNone;
Rex Dieter 9f99ed
+QList<QSystemTrayIconWidget *> QSystemTrayIconWidget::trayIcons;
Rex Dieter 9f99ed
+QCoreApplication::EventFilter QSystemTrayIconWidget::oldEventFilter = 0;
Rex Dieter 9f99ed
+Atom QSystemTrayIconWidget::sysTraySelection = XNone;
Rex Dieter 9f99ed
+XVisualInfo QSystemTrayIconWidget::sysTrayVisual = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QSystemTrayIconWidget::QSystemTrayIconWidget(QSystemTrayIcon* q, QXEmbedSystemTrayIconSys* sys)
Rex Dieter 9f99ed
+: QWidget(0, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint)
Rex Dieter 9f99ed
+, q(q)
Rex Dieter 9f99ed
+, sys(sys)
Rex Dieter 9f99ed
+, colormap(0)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    setAttribute(Qt::WA_AlwaysShowToolTips);
Rex Dieter 9f99ed
+    setAttribute(Qt::WA_QuitOnClose, false);
Rex Dieter 9f99ed
+    setAttribute(Qt::WA_NoSystemBackground, true);
Rex Dieter 9f99ed
+    setAttribute(Qt::WA_PaintOnScreen);
Rex Dieter 9f99ed
+    setMouseTracking(true);
Rex Dieter 9f99ed
+#ifndef QT_NO_TOOLTIP
Rex Dieter 9f99ed
+    setToolTip(q->toolTip());
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    static bool eventFilterAdded = false;
Rex Dieter 9f99ed
+    Display *display = QX11Info::display();
Rex Dieter 9f99ed
+    if (!eventFilterAdded) {
Rex Dieter 9f99ed
+        oldEventFilter = qApp->setEventFilter(sysTrayTracker);
Rex Dieter 9f99ed
+        eventFilterAdded = true;
Rex Dieter 9f99ed
+        Window root = QX11Info::appRootWindow();
Rex Dieter 9f99ed
+        XWindowAttributes attr;
Rex Dieter 9f99ed
+        XGetWindowAttributes(display, root, &attr);
Rex Dieter 9f99ed
+        if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) {
Rex Dieter 9f99ed
+            (void) QApplication::desktop(); // lame trick to ensure our event mask is not overridden
Rex Dieter 9f99ed
+            XSelectInput(display, root, attr.your_event_mask | StructureNotifyMask); // for MANAGER selection
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    if (trayIcons.isEmpty()) {
Rex Dieter 9f99ed
+        sysTrayWindow = locateSystemTray();
Rex Dieter 9f99ed
+        if (sysTrayWindow != XNone)
Rex Dieter 9f99ed
+            XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    trayIcons.append(this);
Rex Dieter 9f99ed
+    if (sysTrayWindow != XNone)
Rex Dieter 9f99ed
+        addToTray();
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QSystemTrayIconWidget::~QSystemTrayIconWidget()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    trayIcons.removeAt(trayIcons.indexOf(this));
Rex Dieter 9f99ed
+    Display *display = QX11Info::display();
Rex Dieter 9f99ed
+    if (trayIcons.isEmpty()) {
Rex Dieter 9f99ed
+        if (sysTrayWindow == XNone)
Rex Dieter 9f99ed
+            return;
Rex Dieter 9f99ed
+        if (display)
Rex Dieter 9f99ed
+            XSelectInput(display, sysTrayWindow, 0); // stop tracking the tray
Rex Dieter 9f99ed
+        sysTrayWindow = XNone;
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    if (colormap)
Rex Dieter 9f99ed
+        XFreeColormap(display, colormap);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QSystemTrayIconWidget::resizeEvent(QResizeEvent *re)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    QWidget::resizeEvent(re);
Rex Dieter 9f99ed
+    update();
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QSystemTrayIconWidget::paintEvent(QPaintEvent*)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    QPainter p(this);
Rex Dieter 9f99ed
+    if (!getSysTrayVisualInfo()) {
Rex Dieter 9f99ed
+        const QRegion oldSystemClip = p.paintEngine()->systemClip();
Rex Dieter 9f99ed
+        const QRect clearedRect = oldSystemClip.boundingRect();
Rex Dieter 9f99ed
+        XClearArea(QX11Info::display(), winId(), clearedRect.x(), clearedRect.y(),
Rex Dieter 9f99ed
+                   clearedRect.width(), clearedRect.height(), False);
Rex Dieter 9f99ed
+        QPaintEngine *pe = p.paintEngine();
Rex Dieter 9f99ed
+        pe->setSystemClip(clearedRect);
Rex Dieter 9f99ed
+        q->icon().paint(&p, rect());
Rex Dieter 9f99ed
+        pe->setSystemClip(oldSystemClip);
Rex Dieter 9f99ed
+    } else {
Rex Dieter 9f99ed
+        p.setCompositionMode(QPainter::CompositionMode_Source);
Rex Dieter 9f99ed
+        p.fillRect(rect(), Qt::transparent);
Rex Dieter 9f99ed
+        p.setCompositionMode(QPainter::CompositionMode_SourceOver);
Rex Dieter 9f99ed
+        q->icon().paint(&p, rect());
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QSystemTrayIconWidget::mousePressEvent(QMouseEvent *ev)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    QPoint globalPos = ev->globalPos();
Rex Dieter 9f99ed
+    if (ev->button() == Qt::RightButton && q->contextMenu())
Rex Dieter 9f99ed
+        q->contextMenu()->popup(globalPos);
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    if (QBalloonTip::isBalloonVisible()) {
Rex Dieter 9f99ed
+        QMetaObject::invokeMethod(q, "messageClicked");
Rex Dieter 9f99ed
+        QBalloonTip::hideBalloon();
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    if (ev->button() == Qt::LeftButton)
Rex Dieter 9f99ed
+        qtsystray_sendActivated(q, QSystemTrayIcon::Trigger);
Rex Dieter 9f99ed
+    else if (ev->button() == Qt::RightButton)
Rex Dieter 9f99ed
+        qtsystray_sendActivated(q, QSystemTrayIcon::Context);
Rex Dieter 9f99ed
+    else if (ev->button() == Qt::MidButton)
Rex Dieter 9f99ed
+        qtsystray_sendActivated(q, QSystemTrayIcon::MiddleClick);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QSystemTrayIconWidget::mouseDoubleClickEvent(QMouseEvent *ev)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (ev->button() == Qt::LeftButton)
Rex Dieter 9f99ed
+        qtsystray_sendActivated(q, QSystemTrayIcon::DoubleClick);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#ifndef QT_NO_WHEELEVENT
Rex Dieter 9f99ed
+void QSystemTrayIconWidget::wheelEvent(QWheelEvent *e)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    sys->sendWheelEventToTrayIcon(e->delta(), e->orientation());
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+bool QSystemTrayIconWidget::event(QEvent *e)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (e->type() == QEvent::ToolTip) {
Rex Dieter 9f99ed
+        sys->sendToolTipEventToTrayIcon();
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+    return QWidget::event(e);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+bool QSystemTrayIconWidget::x11Event(XEvent *event)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (event->type == ReparentNotify)
Rex Dieter 9f99ed
+        show();
Rex Dieter 9f99ed
+    return QWidget::x11Event(event);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+// Locate the system tray
Rex Dieter 9f99ed
+Window QSystemTrayIconWidget::locateSystemTray()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    Display *display = QX11Info::display();
Rex Dieter 9f99ed
+    if (sysTraySelection == XNone) {
Rex Dieter 9f99ed
+        int screen = QX11Info::appScreen();
Rex Dieter 9f99ed
+        QString net_sys_tray = QString::fromLatin1("_NET_SYSTEM_TRAY_S%1").arg(screen);
Rex Dieter 9f99ed
+        sysTraySelection = XInternAtom(display, net_sys_tray.toLatin1(), False);
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    return XGetSelectionOwner(QX11Info::display(), sysTraySelection);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+XVisualInfo* QSystemTrayIconWidget::getSysTrayVisualInfo()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    Display *display = QX11Info::display();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    if (!sysTrayVisual.visual) {
Rex Dieter 9f99ed
+        Window win = locateSystemTray();
Rex Dieter 9f99ed
+        if (win != XNone) {
Rex Dieter 9f99ed
+            Atom actual_type;
Rex Dieter 9f99ed
+            int actual_format;
Rex Dieter 9f99ed
+            ulong nitems, bytes_remaining;
Rex Dieter 9f99ed
+            uchar *data = 0;
Rex Dieter 9f99ed
+            int result = XGetWindowProperty(display, win, ATOM(_NET_SYSTEM_TRAY_VISUAL), 0, 1,
Rex Dieter 9f99ed
+                                            False, XA_VISUALID, &actual_type,
Rex Dieter 9f99ed
+                                            &actual_format, &nitems, &bytes_remaining, &data);
Rex Dieter 9f99ed
+            VisualID vid = 0;
Rex Dieter 9f99ed
+            if (result == Success && data && actual_type == XA_VISUALID && actual_format == 32 &&
Rex Dieter 9f99ed
+                nitems == 1 && bytes_remaining == 0)
Rex Dieter 9f99ed
+                vid = *(VisualID*)data;
Rex Dieter 9f99ed
+            if (data)
Rex Dieter 9f99ed
+                XFree(data);
Rex Dieter 9f99ed
+            if (vid == 0)
Rex Dieter 9f99ed
+                return 0;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+            uint mask = VisualIDMask;
Rex Dieter 9f99ed
+            XVisualInfo *vi, rvi;
Rex Dieter 9f99ed
+            int count;
Rex Dieter 9f99ed
+            rvi.visualid = vid;
Rex Dieter 9f99ed
+            vi = XGetVisualInfo(display, mask, &rvi, &count);
Rex Dieter 9f99ed
+            if (vi) {
Rex Dieter 9f99ed
+                sysTrayVisual = vi[0];
Rex Dieter 9f99ed
+                XFree((char*)vi);
Rex Dieter 9f99ed
+            }
Rex Dieter 9f99ed
+            if (sysTrayVisual.depth != 32)
Rex Dieter 9f99ed
+                memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    return sysTrayVisual.visual ? &sysTrayVisual : 0;
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+bool QSystemTrayIconWidget::sysTrayTracker(void *message, long *result)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    bool retval = false;
Rex Dieter 9f99ed
+    if (QSystemTrayIconWidget::oldEventFilter)
Rex Dieter 9f99ed
+        retval = QSystemTrayIconWidget::oldEventFilter(message, result);
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    if (trayIcons.isEmpty())
Rex Dieter 9f99ed
+        return retval;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    Display *display = QX11Info::display();
Rex Dieter 9f99ed
+    XEvent *ev = (XEvent *)message;
Rex Dieter 9f99ed
+    if  (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) {
Rex Dieter 9f99ed
+        sysTrayWindow = locateSystemTray();
Rex Dieter 9f99ed
+        memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
+        for (int i = 0; i < trayIcons.count(); i++) {
Rex Dieter 9f99ed
+            if (sysTrayWindow == XNone) {
Rex Dieter 9f99ed
+                QBalloonTip::hideBalloon();
Rex Dieter 9f99ed
+                trayIcons[i]->hide(); // still no luck
Rex Dieter 9f99ed
+                trayIcons[i]->destroy();
Rex Dieter 9f99ed
+                trayIcons[i]->create();
Rex Dieter 9f99ed
+            } else
Rex Dieter 9f99ed
+                trayIcons[i]->addToTray(); // add it to the new tray
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+        retval = true;
Rex Dieter 9f99ed
+    } else if (ev->type == ClientMessage && sysTrayWindow == XNone) {
Rex Dieter 9f99ed
+        static Atom manager_atom = XInternAtom(display, "MANAGER", False);
Rex Dieter 9f99ed
+        XClientMessageEvent *cm = (XClientMessageEvent *)message;
Rex Dieter 9f99ed
+        if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) {
Rex Dieter 9f99ed
+            sysTrayWindow = cm->data.l[2];
Rex Dieter 9f99ed
+            memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
+            XSelectInput(display, sysTrayWindow, StructureNotifyMask);
Rex Dieter 9f99ed
+            for (int i = 0; i < trayIcons.count(); i++) {
Rex Dieter 9f99ed
+                trayIcons[i]->addToTray();
Rex Dieter 9f99ed
+            }
Rex Dieter 9f99ed
+            retval = true;
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+    } else if (ev->type == PropertyNotify && ev->xproperty.atom == ATOM(_NET_SYSTEM_TRAY_VISUAL) &&
Rex Dieter 9f99ed
+               ev->xproperty.window == sysTrayWindow) {
Rex Dieter 9f99ed
+        memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
Rex Dieter 9f99ed
+        for (int i = 0; i < trayIcons.count(); i++) {
Rex Dieter 9f99ed
+            trayIcons[i]->addToTray();
Rex Dieter 9f99ed
+        }
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    return retval;
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QSystemTrayIconWidget::addToTray()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    Q_ASSERT(sysTrayWindow != XNone);
Rex Dieter 9f99ed
+    Display *display = QX11Info::display();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    XVisualInfo *vi = getSysTrayVisualInfo();
Rex Dieter 9f99ed
+    if (vi && vi->visual) {
Rex Dieter 9f99ed
+        Window root = RootWindow(display, vi->screen);
Rex Dieter 9f99ed
+        Window p = root;
Rex Dieter 9f99ed
+        if (QWidget *pw = parentWidget())
Rex Dieter 9f99ed
+            p = pw->effectiveWinId();
Rex Dieter 9f99ed
+        colormap = XCreateColormap(display, root, vi->visual, AllocNone);
Rex Dieter 9f99ed
+        XSetWindowAttributes wsa;
Rex Dieter 9f99ed
+        wsa.background_pixmap = 0;
Rex Dieter 9f99ed
+        wsa.colormap = colormap;
Rex Dieter 9f99ed
+        wsa.background_pixel = 0;
Rex Dieter 9f99ed
+        wsa.border_pixel = 0;
Rex Dieter 9f99ed
+        Window wid = XCreateWindow(display, p, -1, -1, 1, 1,
Rex Dieter 9f99ed
+                                   0, vi->depth, InputOutput, vi->visual,
Rex Dieter 9f99ed
+                                   CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa;;
Rex Dieter 9f99ed
+        create(wid);
Rex Dieter 9f99ed
+    } else {
Rex Dieter 9f99ed
+        XSetWindowBackgroundPixmap(display, winId(), ParentRelative);
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    // GNOME, NET WM Specification
Rex Dieter 9f99ed
+    static Atom netwm_tray_atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False);
Rex Dieter 9f99ed
+    long l[5] = { CurrentTime, SYSTEM_TRAY_REQUEST_DOCK, static_cast<long>(winId()), 0, 0 };
Rex Dieter 9f99ed
+    XEvent ev;
Rex Dieter 9f99ed
+    memset(&ev, 0, sizeof(ev));
Rex Dieter 9f99ed
+    ev.xclient.type = ClientMessage;
Rex Dieter 9f99ed
+    ev.xclient.window = sysTrayWindow;
Rex Dieter 9f99ed
+    ev.xclient.message_type = netwm_tray_atom;
Rex Dieter 9f99ed
+    ev.xclient.format = 32;
Rex Dieter 9f99ed
+    memcpy((char *)&ev.xclient.data, (const char *) l, sizeof(l));
Rex Dieter 9f99ed
+    XSendEvent(display, sysTrayWindow, False, 0, &ev;;
Rex Dieter 9f99ed
+    setMinimumSize(22, 22); // required at least on GNOME
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+////////////////////////////////////////////////////////////////////////////
Rex Dieter 9f99ed
+QXEmbedSystemTrayIconSys::QXEmbedSystemTrayIconSys(QSystemTrayIcon *q)
Rex Dieter 9f99ed
+: QAbstractSystemTrayIconSys(q)
Rex Dieter 9f99ed
+, widget(0)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QXEmbedSystemTrayIconSys::~QXEmbedSystemTrayIconSys()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    delete widget;
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QRect QXEmbedSystemTrayIconSys::geometry() const
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (!widget)
Rex Dieter 9f99ed
+        return QRect();
Rex Dieter 9f99ed
+    return QRect(widget->mapToGlobal(QPoint(0, 0)), widget->size());
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::updateIcon()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (!widget)
Rex Dieter 9f99ed
+        return;
Rex Dieter 9f99ed
+    widget->update();
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::updateToolTip()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (!widget)
Rex Dieter 9f99ed
+        return;
Rex Dieter 9f99ed
+    widget->setToolTip(trayIcon->toolTip());
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::showMessage(const QString &message, const QString &title,
Rex Dieter 9f99ed
+                                   QSystemTrayIcon::MessageIcon icon, int msecs)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    if (!widget)
Rex Dieter 9f99ed
+        return;
Rex Dieter 9f99ed
+    QPoint point = geometry().center();
Rex Dieter 9f99ed
+    QBalloonTip::showBalloon(icon, message, title, trayIcon, point, msecs);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::updateVisibility()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    bool visible = trayIcon->isVisible();
Rex Dieter 9f99ed
+    if (visible && !widget)
Rex Dieter 9f99ed
+        widget = new QSystemTrayIconWidget(trayIcon, this);
Rex Dieter 9f99ed
+    else if (!visible && widget) {
Rex Dieter 9f99ed
+        delete widget;
Rex Dieter 9f99ed
+        widget = 0;
Rex Dieter 9f99ed
+    }
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::sendToolTipEventToTrayIcon()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+#ifndef QT_NO_TOOLTIP
Rex Dieter 9f99ed
+    // Pass the event through QSystemTrayIcon so that it gets a chance to
Rex Dieter 9f99ed
+    // update the tooltip, then asks widget to show the tooltip
Rex Dieter 9f99ed
+    Q_ASSERT(widget);
Rex Dieter 9f99ed
+    QPoint globalPos = QCursor::pos();
Rex Dieter 9f99ed
+    QPoint pos = widget->mapFromGlobal(globalPos);
Rex Dieter 9f99ed
+    QHelpEvent event(QEvent::ToolTip, pos, globalPos);
Rex Dieter 9f99ed
+    QApplication::sendEvent(trayIcon, &event);
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::sendWheelEventToTrayIcon(int delta, Qt::Orientation orientation)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+#ifndef QT_NO_WHEELEVENT
Rex Dieter 9f99ed
+    Q_ASSERT(widget);
Rex Dieter 9f99ed
+    QPoint globalPos = QCursor::pos();
Rex Dieter 9f99ed
+    QPoint pos = widget->mapFromGlobal(globalPos);
Rex Dieter 9f99ed
+    QWheelEvent event(pos, globalPos, delta, Qt::NoButton, Qt::NoModifier, orientation);
Rex Dieter 9f99ed
+    QApplication::sendEvent(trayIcon, &event);
Rex Dieter 9f99ed
+#endif
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+void QXEmbedSystemTrayIconSys::updateMenu()
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+/////////////////////////////////////////////////////////////
Rex Dieter 9f99ed
+QAbstractSystemTrayIconSys * QXEmbedSystemTrayIconSysFactory::create(QSystemTrayIcon *icon)
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    return new QXEmbedSystemTrayIconSys(icon);
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+bool QXEmbedSystemTrayIconSysFactory::isAvailable() const
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    return QSystemTrayIconWidget::locateSystemTray() != XNone;
Rex Dieter 9f99ed
+}
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QT_END_NAMESPACE
Rex Dieter 9f99ed
+#endif //QT_NO_SYSTEMTRAYICON
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11_p.h.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11_p.h
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11_p.h.systemtrayicon	2014-03-31 18:16:39.709974914 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/qxembedsystemtrayicon_x11_p.h	2014-03-31 18:16:39.709974914 -0500
Rex Dieter 9f99ed
@@ -0,0 +1,104 @@
Rex Dieter 9f99ed
+/****************************************************************************
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
Rex Dieter 9f99ed
+** All rights reserved.
Rex Dieter 9f99ed
+** Contact: Nokia Corporation (qt-info@nokia.com)
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** This file is part of the QtGui module of the Qt Toolkit.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_BEGIN_LICENSE:LGPL$
Rex Dieter 9f99ed
+** GNU Lesser General Public License Usage
Rex Dieter 9f99ed
+** This file may be used under the terms of the GNU Lesser General Public
Rex Dieter 9f99ed
+** License version 2.1 as published by the Free Software Foundation and
Rex Dieter 9f99ed
+** appearing in the file LICENSE.LGPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU Lesser
Rex Dieter 9f99ed
+** General Public License version 2.1 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** In addition, as a special exception, Nokia gives you certain additional
Rex Dieter 9f99ed
+** rights. These rights are described in the Nokia Qt LGPL Exception
Rex Dieter 9f99ed
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** GNU General Public License Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used under the terms of the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 as published by the Free Software Foundation
Rex Dieter 9f99ed
+** and appearing in the file LICENSE.GPL included in the packaging of this
Rex Dieter 9f99ed
+** file. Please review the following information to ensure the GNU General
Rex Dieter 9f99ed
+** Public License version 3.0 requirements will be met:
Rex Dieter 9f99ed
+** http://www.gnu.org/copyleft/gpl.html.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** Other Usage
Rex Dieter 9f99ed
+** Alternatively, this file may be used in accordance with the terms and
Rex Dieter 9f99ed
+** conditions contained in a signed written agreement between you and Nokia.
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+** $QT_END_LICENSE$
Rex Dieter 9f99ed
+**
Rex Dieter 9f99ed
+****************************************************************************/
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#ifndef QXEMBEDSYSTEMTRAYICON_X11_P_H
Rex Dieter 9f99ed
+#define QXEMBEDSYSTEMTRAYICON_X11_P_H
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+//  W A R N I N G
Rex Dieter 9f99ed
+//  -------------
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+// This file is not part of the Qt API.  It exists for the convenience
Rex Dieter 9f99ed
+// of a number of Qt sources files.  This header file may change from
Rex Dieter 9f99ed
+// version to version without notice, or even be removed.
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+// We mean it.
Rex Dieter 9f99ed
+//
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#ifndef QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#include "qabstractsystemtrayiconsys_p.h"
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QT_BEGIN_NAMESPACE
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class QSystemTrayIconWidget;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+class QXEmbedSystemTrayIconSys : public QAbstractSystemTrayIconSys
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+public:
Rex Dieter 9f99ed
+    QXEmbedSystemTrayIconSys(QSystemTrayIcon *);
Rex Dieter 9f99ed
+    ~QXEmbedSystemTrayIconSys();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    QRect geometry() const;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void updateVisibility();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void updateIcon();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void updateToolTip();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void updateMenu();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void showMessage(const QString &message, const QString &title,
Rex Dieter 9f99ed
+                     QSystemTrayIcon::MessageIcon icon, int msecs);
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+private:
Rex Dieter 9f99ed
+    friend class QSystemTrayIconWidget;
Rex Dieter 9f99ed
+    QSystemTrayIconWidget *widget;
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void sendToolTipEventToTrayIcon();
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+    void sendWheelEventToTrayIcon(int delta, Qt::Orientation orientation);
Rex Dieter 9f99ed
+};
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+struct QXEmbedSystemTrayIconSysFactory : public QSystemTrayIconSysFactoryInterface
Rex Dieter 9f99ed
+{
Rex Dieter 9f99ed
+    QAbstractSystemTrayIconSys * create(QSystemTrayIcon *trayIcon);
Rex Dieter 9f99ed
+    bool isAvailable() const;
Rex Dieter 9f99ed
+};
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+QT_END_NAMESPACE
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#endif // QT_NO_SYSTEMTRAYICON
Rex Dieter 9f99ed
+
Rex Dieter 9f99ed
+#endif // QXEMBEDSYSTEMTRAYICON_X11_P_H
Rex Dieter 9f99ed
+
Rex Dieter 8ec4a9
diff -up qt-everywhere-opensource-src-4.8.6/src/gui/util/util.pri.systemtrayicon qt-everywhere-opensource-src-4.8.6/src/gui/util/util.pri
Rex Dieter 8ec4a9
--- qt-everywhere-opensource-src-4.8.6/src/gui/util/util.pri.systemtrayicon	2014-03-30 15:36:49.000000000 -0500
Rex Dieter 8ec4a9
+++ qt-everywhere-opensource-src-4.8.6/src/gui/util/util.pri	2014-03-31 18:16:39.710974903 -0500
Rex Dieter 8ec4a9
@@ -29,8 +29,13 @@ wince* {
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 unix:x11 {
Rex Dieter 9f99ed
+		HEADERS += \
Rex Dieter 9f99ed
+				util/qabstractsystemtrayiconsys_p.h \
Rex Dieter 9f99ed
+				util/qxembedsystemtrayicon_x11_p.h
Rex Dieter 9f99ed
 		SOURCES += \
Rex Dieter 9f99ed
-				util/qsystemtrayicon_x11.cpp
Rex Dieter 9f99ed
+				util/qabstractsystemtrayiconsys.cpp \
Rex Dieter 9f99ed
+				util/qsystemtrayicon_x11.cpp \
Rex Dieter 9f99ed
+				util/qxembedsystemtrayicon_x11.cpp
Rex Dieter 9f99ed
 }
Rex Dieter 9f99ed
 
Rex Dieter 9f99ed
 embedded|qpa {