Merge lp:~jm-leddy/ubuntu/oneiric/unity-2d/unsetenvvariables into lp:ubuntu/oneiric-updates/unity-2d

Proposed by James M. Leddy
Status: Merged
Merge reported by: Dimitri John Ledkov
Merged at revision: not available
Proposed branch: lp:~jm-leddy/ubuntu/oneiric/unity-2d/unsetenvvariables
Merge into: lp:ubuntu/oneiric-updates/unity-2d
Diff against target: 311 lines (+259/-0)
6 files modified
.pc/applied-patches (+1/-0)
.pc/unset-dbus-env-variables.patch/libunity-2d-private/src/unity2dapplication.cpp (+211/-0)
debian/changelog (+8/-0)
debian/patches/series (+1/-0)
debian/patches/unset-dbus-env-variables.patch (+27/-0)
libunity-2d-private/src/unity2dapplication.cpp (+11/-0)
To merge this branch: bzr merge lp:~jm-leddy/ubuntu/oneiric/unity-2d/unsetenvvariables
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Approve
Ubuntu branches Pending
Łukasz Zemczak Pending
Review via email: mp+122350@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James M. Leddy (jm-leddy) wrote :

Sorry about that, I accidentally cherry picked from the unity development branch. This resubmission should be good.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Did you mean to subscribe us three? If you want a sponsor, the default branch reviewer should be left as "ubuntu branches" and then one of the sponsors for the day will look into it.

Revision history for this message
James M. Leddy (jm-leddy) wrote :

Hey Dmitrijs, I subscribed you because you had looked it over last time, and I figured it would be better if it went to someone that was familiar with the issue. I'm trying to unsubscribe you two, but I can't figure out how to do it. Do you know how?

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

What is more annoying, is that another 1.3 got fixes merged & swooshed passed in the mean time.
I redid the merge and will sponsor this in a second.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2012-06-13 18:36:00 +0000
3+++ .pc/applied-patches 2012-08-31 19:52:18 +0000
4@@ -1,2 +1,3 @@
5 debian-changes-4.12.0-0ubuntu1.1
6 fix-event-timestamps.patch
7+unset-dbus-env-variables.patch
8
9=== added directory '.pc/unset-dbus-env-variables.patch'
10=== added directory '.pc/unset-dbus-env-variables.patch/libunity-2d-private'
11=== added directory '.pc/unset-dbus-env-variables.patch/libunity-2d-private/src'
12=== added file '.pc/unset-dbus-env-variables.patch/libunity-2d-private/src/unity2dapplication.cpp'
13--- .pc/unset-dbus-env-variables.patch/libunity-2d-private/src/unity2dapplication.cpp 1970-01-01 00:00:00 +0000
14+++ .pc/unset-dbus-env-variables.patch/libunity-2d-private/src/unity2dapplication.cpp 2012-08-31 19:52:18 +0000
15@@ -0,0 +1,211 @@
16+/*
17+ * Unity2d
18+ *
19+ * Copyright 2010 Canonical Ltd.
20+ *
21+ * Authors:
22+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
23+ *
24+ * This program is free software; you can redistribute it and/or modify
25+ * it under the terms of the GNU General Public License as published by
26+ * the Free Software Foundation; version 3.
27+ *
28+ * This program is distributed in the hope that it will be useful,
29+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+ * GNU General Public License for more details.
32+ *
33+ * You should have received a copy of the GNU General Public License
34+ * along with this program. If not, see <http://www.gnu.org/licenses/>
35+ */
36+
37+// Self
38+#include "unity2dapplication.h"
39+#include "config.h"
40+
41+// libunity-2d
42+#include <debug_p.h>
43+#include <gconnector.h>
44+#include <gscopedpointer.h>
45+#include <unity2ddebug.h>
46+#include <unity2dtr.h>
47+
48+// Qt
49+#include <QFont>
50+#include <QWindowsStyle>
51+#include <QAccessible>
52+#include <QAccessibleWidget>
53+#include <QWidget>
54+
55+// GTK
56+#include <gtk/gtk.h>
57+#include <pango/pango.h>
58+
59+static const char* A11Y_SCHEMA = "org.gnome.desktop.interface";
60+static const char* A11Y_KEY = "toolkit-accessibility";
61+
62+///////////////////////////////
63+class PlatformFontTracker
64+{
65+public:
66+ PlatformFontTracker()
67+ {
68+ m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-font-name",
69+ G_CALLBACK(PlatformFontTracker::onFontChanged), this);
70+
71+ updateFont();
72+ }
73+
74+private:
75+ void updateFont()
76+ {
77+ gchar* fontName = 0;
78+ g_object_get(gtk_settings_get_default(), "gtk-font-name", &fontName, NULL);
79+ GScopedPointer<PangoFontDescription, pango_font_description_free> fontDescription(
80+ pango_font_description_from_string(fontName)
81+ );
82+ g_free(fontName);
83+
84+ int size = pango_font_description_get_size(fontDescription.data());
85+
86+ QFont font = QFont(
87+ pango_font_description_get_family(fontDescription.data()),
88+ size / PANGO_SCALE
89+ );
90+
91+ QApplication::setFont(font);
92+ }
93+
94+ static void onFontChanged(GObject*, GParamSpec*, PlatformFontTracker* obj)
95+ {
96+ obj->updateFont();
97+ }
98+
99+ GConnector m_gConnector;
100+};
101+
102+///////////////////////////////
103+AbstractX11EventFilter::~AbstractX11EventFilter()
104+{
105+ Unity2dApplication* application = Unity2dApplication::instance();
106+ if (application != NULL) {
107+ application->removeX11EventFilter(this);
108+ }
109+}
110+
111+///////////////////////////////
112+static bool arrayContains(char** begin, char** end, const char* string)
113+{
114+ for (char** ptr = begin; ptr != end; ++ptr) {
115+ if (strcmp(*ptr, string) == 0) {
116+ return true;
117+ }
118+ }
119+ return false;
120+}
121+
122+QAccessibleInterface *panelFactory(const QString &classname, QObject *object)
123+{
124+ QAccessibleInterface *interface = 0;
125+
126+ if (classname == "Unity2dPanel" && object && object->isWidgetType()) {
127+ interface = new QAccessibleWidget(static_cast<QWidget *>(object), QAccessible::ToolBar);
128+ }
129+
130+ return interface;
131+}
132+
133+void Unity2dApplication::earlySetup(int& argc, char** argv)
134+{
135+ // Parts of unity-2d uses GTK so it needs to be initialized
136+ gtk_init(&argc, &argv);
137+
138+ Unity2dDebug::installHandlers();
139+
140+ /* Enable a11y for all Unity 2d components.
141+ * See https://bugs.launchpad.net/ubuntu/+source/qt-at-spi/+bug/877358
142+ *
143+ * Note: We cannot use the Qt bindings to dconf because it requires a
144+ * QApplication object, which we don't have at this point.
145+ */
146+ GObjectScopedPointer<GSettings> settings(g_settings_new(A11Y_SCHEMA));
147+ if (g_settings_get_boolean(settings.data(), A11Y_KEY)) {
148+ qputenv("QT_ACCESSIBILITY", "1");
149+ }
150+
151+ /* When the environment variable QT_GRAPHICSSYSTEM is not set, force
152+ * graphics system to 'raster' instead of the default 'native' which on X11
153+ * is 'XRender'. 'XRender' defaults to using a TrueColor visual. We do
154+ * _not_ mimick that behaviour with 'raster' by calling
155+ * QApplication::setColorSpec because of bugs where some pixmaps become
156+ * blueish or black rectangular artifacts were appearing randomly:
157+ *
158+ * https://bugs.launchpad.net/unity-2d/+bug/689877
159+ * https://bugs.launchpad.net/unity-2d/+bug/734143
160+ */
161+ if(getenv("QT_GRAPHICSSYSTEM") == 0) {
162+ QApplication::setGraphicsSystem("raster");
163+ }
164+
165+ /* Unless style has been specified in args, set default Qt style to
166+ * QWindowStyle to avoid loading QGtkStyle. We don't want to load QGtkStyle
167+ * because it uses libgtk2, which causes conflicts with our gtk3 code.
168+ */
169+ if (!arrayContains(argv, argv + argc, "-style")) {
170+ QApplication::setStyle(new QWindowsStyle);
171+ }
172+}
173+
174+Unity2dApplication::Unity2dApplication(int& argc, char** argv)
175+: QApplication(argc, argv)
176+, m_platformFontTracker(new PlatformFontTracker)
177+{
178+ /* Configure translations */
179+ Unity2dTr::init("unity-2d", INSTALL_PREFIX "/share/locale");
180+ if (u2dTr("QT_LAYOUT_DIRECTION") == "RTL") {
181+ QApplication::setLayoutDirection(Qt::RightToLeft);
182+ }
183+
184+ /* Allow developers to run Unity 2D uninstalled by telling dconf-qt
185+ where to look for Unity 2D's schemas.
186+ It relies on the fact that the schema is compiled when running cmake.
187+ */
188+ if (!isRunningInstalled()) {
189+ qputenv("GSETTINGS_SCHEMA_DIR", unity2dDirectory().toLocal8Bit() + "/data");
190+ }
191+
192+ QAccessible::installFactory(panelFactory);
193+}
194+
195+Unity2dApplication::~Unity2dApplication()
196+{
197+ qDeleteAll(m_x11EventFilters);
198+ delete m_platformFontTracker;
199+}
200+
201+Unity2dApplication* Unity2dApplication::instance()
202+{
203+ return qobject_cast<Unity2dApplication*>(QCoreApplication::instance());
204+}
205+
206+void Unity2dApplication::installX11EventFilter(AbstractX11EventFilter* filter)
207+{
208+ m_x11EventFilters.append(filter);
209+}
210+
211+void Unity2dApplication::removeX11EventFilter(AbstractX11EventFilter* filter)
212+{
213+ m_x11EventFilters.removeAll(filter);
214+}
215+
216+bool Unity2dApplication::x11EventFilter(XEvent* event)
217+{
218+ Q_FOREACH(AbstractX11EventFilter* filter, m_x11EventFilters) {
219+ if (filter->x11EventFilter(event)) {
220+ return true;
221+ }
222+ }
223+ return QApplication::x11EventFilter(event);
224+}
225+
226+#include <unity2dapplication.moc>
227
228=== modified file 'debian/changelog'
229--- debian/changelog 2012-06-13 18:36:00 +0000
230+++ debian/changelog 2012-08-31 19:52:18 +0000
231@@ -1,3 +1,11 @@
232+unity-2d (4.12.0-0ubuntu1.3) oneiric-proposed; urgency=low
233+
234+ [ Chris Coulson ]
235+ * DBUS_STARTER_ADDRESS and DBUS_STARTER_BUS_TYPE aren't always unset from
236+ environment making gedit and possibly others fail to start (LP: #873027)
237+
238+ -- James M Leddy <james.leddy@ubuntu.com> Fri, 31 Aug 2012 15:04:49 -0400
239+
240 unity-2d (4.12.0-0ubuntu1.2) oneiric-security; urgency=low
241
242 * Fix issue with unity-2d sending the wrong event timestamp when closing an
243
244=== modified file 'debian/patches/series'
245--- debian/patches/series 2012-06-13 18:36:00 +0000
246+++ debian/patches/series 2012-08-31 19:52:18 +0000
247@@ -1,2 +1,3 @@
248 debian-changes-4.12.0-0ubuntu1.1
249 fix-event-timestamps.patch
250+unset-dbus-env-variables.patch
251
252=== added file 'debian/patches/unset-dbus-env-variables.patch'
253--- debian/patches/unset-dbus-env-variables.patch 1970-01-01 00:00:00 +0000
254+++ debian/patches/unset-dbus-env-variables.patch 2012-08-31 19:52:18 +0000
255@@ -0,0 +1,27 @@
256+--- a/libunity-2d-private/src/unity2dapplication.cpp
257++++ b/libunity-2d-private/src/unity2dapplication.cpp
258+@@ -41,6 +41,9 @@
259+ #include <gtk/gtk.h>
260+ #include <pango/pango.h>
261+
262++// libc
263++#include <stdlib.h>
264++
265+ static const char* A11Y_SCHEMA = "org.gnome.desktop.interface";
266+ static const char* A11Y_KEY = "toolkit-accessibility";
267+
268+@@ -146,6 +149,14 @@
269+ if(getenv("QT_GRAPHICSSYSTEM") == 0) {
270+ QApplication::setGraphicsSystem("raster");
271+ }
272++
273++ /* We have these if we were DBus activated, but we don't want our child
274++ * processes to inherit them
275++ *
276++ * https://launchpad.net/bugs/873027
277++ */
278++ unsetenv("DBUS_STARTER_ADDRESS");
279++ unsetenv("DBUS_STARTER_BUS_TYPE");
280+
281+ /* Unless style has been specified in args, set default Qt style to
282+ * QWindowStyle to avoid loading QGtkStyle. We don't want to load QGtkStyle
283
284=== modified file 'libunity-2d-private/src/unity2dapplication.cpp'
285--- libunity-2d-private/src/unity2dapplication.cpp 2011-11-23 15:05:39 +0000
286+++ libunity-2d-private/src/unity2dapplication.cpp 2012-08-31 19:52:18 +0000
287@@ -41,6 +41,9 @@
288 #include <gtk/gtk.h>
289 #include <pango/pango.h>
290
291+// libc
292+#include <stdlib.h>
293+
294 static const char* A11Y_SCHEMA = "org.gnome.desktop.interface";
295 static const char* A11Y_KEY = "toolkit-accessibility";
296
297@@ -146,6 +149,14 @@
298 if(getenv("QT_GRAPHICSSYSTEM") == 0) {
299 QApplication::setGraphicsSystem("raster");
300 }
301+
302+ /* We have these if we were DBus activated, but we don't want our child
303+ * processes to inherit them
304+ *
305+ * https://launchpad.net/bugs/873027
306+ */
307+ unsetenv("DBUS_STARTER_ADDRESS");
308+ unsetenv("DBUS_STARTER_BUS_TYPE");
309
310 /* Unless style has been specified in args, set default Qt style to
311 * QWindowStyle to avoid loading QGtkStyle. We don't want to load QGtkStyle

Subscribers

People subscribed via source and target branches