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
1=== modified file 'panel/applets/legacytray/CMakeLists.txt'
2--- panel/applets/legacytray/CMakeLists.txt 2011-08-12 15:17:23 +0000
3+++ panel/applets/legacytray/CMakeLists.txt 2011-09-01 09:04:30 +0000
4@@ -15,6 +15,7 @@
5 include_directories(
6 ${CMAKE_CURRENT_SOURCE_DIR}
7 ${CMAKE_CURRENT_BINARY_DIR}
8+ ${DCONFQT_INCLUDE_DIRS}
9 ${X11_INCLUDE_DIR}
10 ${libunity-2d-private_SOURCE_DIR}/src
11 )
12@@ -30,6 +31,7 @@
13 target_link_libraries(panelplugin-legacytray
14 ${QT_QTGUI_LIBRARIES}
15 ${QT_QTCORE_LIBRARIES}
16+ ${DCONFQT_LIBRARIES}
17 ${X11_LIBRARIES}
18 ${X11_Xrender_LIB}
19 ${X11_Xcomposite_LIB}
20
21=== modified file 'panel/applets/legacytray/fdotask.cpp'
22--- panel/applets/legacytray/fdotask.cpp 2011-02-02 16:57:00 +0000
23+++ panel/applets/legacytray/fdotask.cpp 2011-09-01 09:04:30 +0000
24@@ -31,6 +31,10 @@
25
26 // Qt
27 #include <QEvent>
28+#include <QX11Info>
29+
30+// Others
31+#include <X11/Xutil.h>
32
33 namespace SystemTray
34 {
35@@ -54,6 +58,34 @@
36 QMetaObject::invokeMethod(this, "setupXEmbedDelegate", Qt::QueuedConnection);
37 }
38
39+static void get_xwindow_wmclass(Window xwindow, QString& wmClass, QString& wmName)
40+{
41+ Display *xdisplay = QX11Info::display();
42+
43+ XClassHint hint;
44+ hint.res_name = NULL;
45+ hint.res_class = NULL;
46+
47+ XGetClassHint (xdisplay, xwindow, &hint);
48+
49+ if (hint.res_name) {
50+ wmName = QString::fromAscii(hint.res_name);
51+ XFree (hint.res_name);
52+ }
53+
54+ if (hint.res_class) {
55+ wmClass = QString::fromAscii(hint.res_class);
56+ XFree (hint.res_class);
57+ }
58+}
59+
60+QString FdoTask::name()
61+{
62+ QString wmName, wmClass;
63+ get_xwindow_wmclass(m_id, wmClass, wmName);
64+ return wmClass;
65+}
66+
67 void FdoTask::setupXEmbedDelegate()
68 {
69 if (m_widget) {
70
71=== modified file 'panel/applets/legacytray/fdotask.h'
72--- panel/applets/legacytray/fdotask.h 2011-01-15 01:41:03 +0000
73+++ panel/applets/legacytray/fdotask.h 2011-09-01 09:04:30 +0000
74@@ -42,6 +42,7 @@
75 {}
76
77 virtual void createWidget() = 0;
78+ virtual QString name() = 0;
79 };
80
81 class FdoTask : public Task
82@@ -52,6 +53,7 @@
83 ~FdoTask();
84
85 virtual void createWidget();
86+ virtual QString name();
87
88 Q_SIGNALS:
89 void taskDeleted(WId);
90
91=== modified file 'panel/applets/legacytray/legacytrayapplet.cpp'
92--- panel/applets/legacytray/legacytrayapplet.cpp 2011-08-22 09:17:03 +0000
93+++ panel/applets/legacytray/legacytrayapplet.cpp 2011-09-01 09:04:30 +0000
94@@ -29,13 +29,20 @@
95 // libunity-2d-private
96 #include <debug_p.h>
97
98+// libdconf-qt
99+#include <qconf.h>
100+
101 // Qt
102 #include <QApplication>
103 #include <QHBoxLayout>
104+#include <QVariant>
105+
106+#define PANEL_DCONF_SCHEMA QString("com.canonical.Unity.Panel")
107
108 LegacyTrayApplet::LegacyTrayApplet(Unity2dPanel* panel)
109 : Unity2d::PanelApplet(panel)
110 , m_selectionManager(new SystemTray::FdoSelectionManager)
111+, m_dconfPanel(new QConf(PANEL_DCONF_SCHEMA))
112 {
113 QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
114
115@@ -45,15 +52,27 @@
116
117 connect(m_selectionManager, SIGNAL(taskCreated(SystemTray::Task*)),
118 SLOT(slotTaskCreated(SystemTray::Task*)));
119+
120+ m_whitelist = m_dconfPanel->property("systrayWhitelist").toStringList();
121 }
122
123 LegacyTrayApplet::~LegacyTrayApplet()
124 {
125 delete m_selectionManager;
126+ delete m_dconfPanel;
127 }
128
129 void LegacyTrayApplet::slotTaskCreated(SystemTray::Task* task)
130 {
131+ /* Only accept tasks whose name is in the whitelist.
132+ The whitelist contains a "List of client names, resource classes or wm
133+ classes to allow in the Panel's systray implementation." but here we only
134+ support matching on WM_CLASS.
135+ */
136+ if (!m_whitelist.contains(task->name())) {
137+ return;
138+ }
139+
140 task->createWidget();
141 connect(task, SIGNAL(widgetCreated(QWidget*)), SLOT(slotWidgetCreated(QWidget*)));
142 }
143
144=== modified file 'panel/applets/legacytray/legacytrayapplet.h'
145--- panel/applets/legacytray/legacytrayapplet.h 2011-08-22 09:17:03 +0000
146+++ panel/applets/legacytray/legacytrayapplet.h 2011-09-01 09:04:30 +0000
147@@ -31,6 +31,8 @@
148 class Task;
149 }
150
151+class QConf;
152+
153 class LegacyTrayApplet : public Unity2d::PanelApplet
154 {
155 Q_OBJECT
156@@ -46,6 +48,8 @@
157 Q_DISABLE_COPY(LegacyTrayApplet)
158
159 SystemTray::FdoSelectionManager* m_selectionManager;
160+ QConf* m_dconfPanel;
161+ QStringList m_whitelist;
162 };
163
164 #endif /* LEGACYTRAYAPPLET_H */

Subscribers

People subscribed via source and target branches