Merge lp:~fboucault/unity-2d/panel_whitelist into lp:unity-2d

Proposed by Florian Boucault
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 686
Merged at revision: 686
Proposed branch: lp:~fboucault/unity-2d/panel_whitelist
Merge into: lp:unity-2d
Diff against target: 164 lines (+59/-0)
5 files modified
panel/applets/legacytray/CMakeLists.txt (+2/-0)
panel/applets/legacytray/fdotask.cpp (+32/-0)
panel/applets/legacytray/fdotask.h (+2/-0)
panel/applets/legacytray/legacytrayapplet.cpp (+19/-0)
panel/applets/legacytray/legacytrayapplet.h (+4/-0)
To merge this branch: bzr merge lp:~fboucault/unity-2d/panel_whitelist
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Approve
Review via email: mp+73551@code.launchpad.net

Description of the change

[panel] legacytray applet: implement a whitelist of applications that are allowed to be shown.

Whitelist is shared with Unity 3D and stored in D-Conf.

To post a comment you must log in.
Revision history for this message
Alberto Mardegan (mardy) wrote :

Code is good and the feature works properly.

But it seems to me that libwnck is not necessary here (at least, the code seems to work as well without it). I assume it's something that you forgot to remove?

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

> Code is good and the feature works properly.
>
> But it seems to me that libwnck is not necessary here (at least, the code
> seems to work as well without it). I assume it's something that you forgot to
> remove?

Absolutely! I wanted to use the newly introduced API of wnck that gives us the WM_CLASS for a given xid but it did not work reliably in my experiments.

Revision history for this message
Florian Boucault (fboucault) wrote :

And fixed.

686. By Florian Boucault

Removed unused dependency on libwnck.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Excellent, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'panel/applets/legacytray/CMakeLists.txt'
--- panel/applets/legacytray/CMakeLists.txt 2011-08-12 15:17:23 +0000
+++ panel/applets/legacytray/CMakeLists.txt 2011-09-01 09:04:30 +0000
@@ -15,6 +15,7 @@
15include_directories(15include_directories(
16 ${CMAKE_CURRENT_SOURCE_DIR}16 ${CMAKE_CURRENT_SOURCE_DIR}
17 ${CMAKE_CURRENT_BINARY_DIR}17 ${CMAKE_CURRENT_BINARY_DIR}
18 ${DCONFQT_INCLUDE_DIRS}
18 ${X11_INCLUDE_DIR}19 ${X11_INCLUDE_DIR}
19 ${libunity-2d-private_SOURCE_DIR}/src20 ${libunity-2d-private_SOURCE_DIR}/src
20 )21 )
@@ -30,6 +31,7 @@
30target_link_libraries(panelplugin-legacytray31target_link_libraries(panelplugin-legacytray
31 ${QT_QTGUI_LIBRARIES}32 ${QT_QTGUI_LIBRARIES}
32 ${QT_QTCORE_LIBRARIES}33 ${QT_QTCORE_LIBRARIES}
34 ${DCONFQT_LIBRARIES}
33 ${X11_LIBRARIES}35 ${X11_LIBRARIES}
34 ${X11_Xrender_LIB}36 ${X11_Xrender_LIB}
35 ${X11_Xcomposite_LIB}37 ${X11_Xcomposite_LIB}
3638
=== modified file 'panel/applets/legacytray/fdotask.cpp'
--- panel/applets/legacytray/fdotask.cpp 2011-02-02 16:57:00 +0000
+++ panel/applets/legacytray/fdotask.cpp 2011-09-01 09:04:30 +0000
@@ -31,6 +31,10 @@
3131
32// Qt32// Qt
33#include <QEvent>33#include <QEvent>
34#include <QX11Info>
35
36// Others
37#include <X11/Xutil.h>
3438
35namespace SystemTray39namespace SystemTray
36{40{
@@ -54,6 +58,34 @@
54 QMetaObject::invokeMethod(this, "setupXEmbedDelegate", Qt::QueuedConnection);58 QMetaObject::invokeMethod(this, "setupXEmbedDelegate", Qt::QueuedConnection);
55}59}
5660
61static void get_xwindow_wmclass(Window xwindow, QString& wmClass, QString& wmName)
62{
63 Display *xdisplay = QX11Info::display();
64
65 XClassHint hint;
66 hint.res_name = NULL;
67 hint.res_class = NULL;
68
69 XGetClassHint (xdisplay, xwindow, &hint);
70
71 if (hint.res_name) {
72 wmName = QString::fromAscii(hint.res_name);
73 XFree (hint.res_name);
74 }
75
76 if (hint.res_class) {
77 wmClass = QString::fromAscii(hint.res_class);
78 XFree (hint.res_class);
79 }
80}
81
82QString FdoTask::name()
83{
84 QString wmName, wmClass;
85 get_xwindow_wmclass(m_id, wmClass, wmName);
86 return wmClass;
87}
88
57void FdoTask::setupXEmbedDelegate()89void FdoTask::setupXEmbedDelegate()
58{90{
59 if (m_widget) {91 if (m_widget) {
6092
=== modified file 'panel/applets/legacytray/fdotask.h'
--- panel/applets/legacytray/fdotask.h 2011-01-15 01:41:03 +0000
+++ panel/applets/legacytray/fdotask.h 2011-09-01 09:04:30 +0000
@@ -42,6 +42,7 @@
42 {}42 {}
4343
44 virtual void createWidget() = 0;44 virtual void createWidget() = 0;
45 virtual QString name() = 0;
45};46};
4647
47class FdoTask : public Task48class FdoTask : public Task
@@ -52,6 +53,7 @@
52 ~FdoTask();53 ~FdoTask();
5354
54 virtual void createWidget();55 virtual void createWidget();
56 virtual QString name();
5557
56Q_SIGNALS:58Q_SIGNALS:
57 void taskDeleted(WId);59 void taskDeleted(WId);
5860
=== modified file 'panel/applets/legacytray/legacytrayapplet.cpp'
--- panel/applets/legacytray/legacytrayapplet.cpp 2011-08-22 09:17:03 +0000
+++ panel/applets/legacytray/legacytrayapplet.cpp 2011-09-01 09:04:30 +0000
@@ -29,13 +29,20 @@
29// libunity-2d-private29// libunity-2d-private
30#include <debug_p.h>30#include <debug_p.h>
3131
32// libdconf-qt
33#include <qconf.h>
34
32// Qt35// Qt
33#include <QApplication>36#include <QApplication>
34#include <QHBoxLayout>37#include <QHBoxLayout>
38#include <QVariant>
39
40#define PANEL_DCONF_SCHEMA QString("com.canonical.Unity.Panel")
3541
36LegacyTrayApplet::LegacyTrayApplet(Unity2dPanel* panel)42LegacyTrayApplet::LegacyTrayApplet(Unity2dPanel* panel)
37: Unity2d::PanelApplet(panel)43: Unity2d::PanelApplet(panel)
38, m_selectionManager(new SystemTray::FdoSelectionManager)44, m_selectionManager(new SystemTray::FdoSelectionManager)
45, m_dconfPanel(new QConf(PANEL_DCONF_SCHEMA))
39{46{
40 QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);47 QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
4148
@@ -45,15 +52,27 @@
4552
46 connect(m_selectionManager, SIGNAL(taskCreated(SystemTray::Task*)),53 connect(m_selectionManager, SIGNAL(taskCreated(SystemTray::Task*)),
47 SLOT(slotTaskCreated(SystemTray::Task*)));54 SLOT(slotTaskCreated(SystemTray::Task*)));
55
56 m_whitelist = m_dconfPanel->property("systrayWhitelist").toStringList();
48}57}
4958
50LegacyTrayApplet::~LegacyTrayApplet()59LegacyTrayApplet::~LegacyTrayApplet()
51{60{
52 delete m_selectionManager;61 delete m_selectionManager;
62 delete m_dconfPanel;
53}63}
5464
55void LegacyTrayApplet::slotTaskCreated(SystemTray::Task* task)65void LegacyTrayApplet::slotTaskCreated(SystemTray::Task* task)
56{66{
67 /* Only accept tasks whose name is in the whitelist.
68 The whitelist contains a "List of client names, resource classes or wm
69 classes to allow in the Panel's systray implementation." but here we only
70 support matching on WM_CLASS.
71 */
72 if (!m_whitelist.contains(task->name())) {
73 return;
74 }
75
57 task->createWidget();76 task->createWidget();
58 connect(task, SIGNAL(widgetCreated(QWidget*)), SLOT(slotWidgetCreated(QWidget*)));77 connect(task, SIGNAL(widgetCreated(QWidget*)), SLOT(slotWidgetCreated(QWidget*)));
59}78}
6079
=== modified file 'panel/applets/legacytray/legacytrayapplet.h'
--- panel/applets/legacytray/legacytrayapplet.h 2011-08-22 09:17:03 +0000
+++ panel/applets/legacytray/legacytrayapplet.h 2011-09-01 09:04:30 +0000
@@ -31,6 +31,8 @@
31class Task;31class Task;
32}32}
3333
34class QConf;
35
34class LegacyTrayApplet : public Unity2d::PanelApplet36class LegacyTrayApplet : public Unity2d::PanelApplet
35{37{
36Q_OBJECT38Q_OBJECT
@@ -46,6 +48,8 @@
46 Q_DISABLE_COPY(LegacyTrayApplet)48 Q_DISABLE_COPY(LegacyTrayApplet)
47 49
48 SystemTray::FdoSelectionManager* m_selectionManager;50 SystemTray::FdoSelectionManager* m_selectionManager;
51 QConf* m_dconfPanel;
52 QStringList m_whitelist;
49};53};
5054
51#endif /* LEGACYTRAYAPPLET_H */55#endif /* LEGACYTRAYAPPLET_H */

Subscribers

People subscribed via source and target branches