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

Subscribers

People subscribed via source and target branches