Merge lp:~abreu-alexandre/unity-chromium-extension/12.10.fix-1138473 into lp:unity-chromium-extension/12.10

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 207
Merged at revision: 207
Proposed branch: lp:~abreu-alexandre/unity-chromium-extension/12.10.fix-1138473
Merge into: lp:unity-chromium-extension/12.10
Diff against target: 183 lines (+132/-2)
5 files modified
configure.ac (+1/-1)
npapi-plugin/src/Makefile.am (+2/-0)
npapi-plugin/src/unity-npapi-tools.c (+97/-0)
npapi-plugin/src/unity-npapi-tools.h (+30/-0)
npapi-plugin/src/unity-webapps-binding.c (+2/-1)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-chromium-extension/12.10.fix-1138473
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
Review via email: mp+152293@code.launchpad.net

Commit message

Fix #1138473: update the chromium side following the removal of the xid function from libunity-webapps

Description of the change

Fix #1138473: update the chromium side following the removal of the xid function from libunity-webapps

To post a comment you must log in.
207. By Alexandre Abreu

Fix #1138473: update the chromium side following the removal of the xid function from libunity-webapps - forgot files

Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-11-14 20:09:35 +0000
3+++ configure.ac 2013-03-07 22:12:24 +0000
4@@ -14,7 +14,7 @@
5 AC_DISABLE_STATIC
6 LT_INIT
7
8-PKG_CHECK_MODULES(UNITY_NPAPI_PLUGIN, [libunity_webapps-0.2 glib-2.0 libnotify libunity-webapps-repository])
9+PKG_CHECK_MODULES(UNITY_NPAPI_PLUGIN, [libunity_webapps-0.2 glib-2.0 libnotify libunity-webapps-repository libwnck-1.0])
10
11
12 dnl ***************************************************************************
13
14=== modified file 'npapi-plugin/src/Makefile.am'
15--- npapi-plugin/src/Makefile.am 2012-09-07 17:42:51 +0000
16+++ npapi-plugin/src/Makefile.am 2013-03-07 22:12:24 +0000
17@@ -50,6 +50,8 @@
18 unity-npapi-binding-utils.c \
19 unity-npapi-binding-utils.h \
20 unity-npapi-common.h \
21+ unity-npapi-tools.c \
22+ unity-npapi-tools.h \
23 unity-npapi-debug.h
24
25 libunity_npapi_plugin_la_LDFLAGS = $(UNITY_NPAPI_PLUGIN_COVERAGE_LDFLAGS)
26
27=== added file 'npapi-plugin/src/unity-npapi-tools.c'
28--- npapi-plugin/src/unity-npapi-tools.c 1970-01-01 00:00:00 +0000
29+++ npapi-plugin/src/unity-npapi-tools.c 2013-03-07 22:12:24 +0000
30@@ -0,0 +1,97 @@
31+/*
32+ * unity-npapi-tools.c
33+ * Copyright (C) Canonical LTD 2013
34+ *
35+ * Author: Alexandre Abreu <alexandre.abreu@canonical.com>
36+ *
37+ * This program is free software; you can redistribute it and/or modify
38+ * it under the terms of the GNU General Public License as published by
39+ * the Free Software Foundation; either version 2 of the License, or
40+ * (at your option) any later version.
41+ *
42+ * This program is distributed in the hope that it will be useful,
43+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
44+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+ * GNU General Public License for more details.
46+ *
47+ * You should have received a copy of the GNU General Public License
48+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
49+ */
50+#include <glib.h>
51+#include <string.h>
52+
53+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
54+#include <libwnck/libwnck.h>
55+#include <gtk/gtk.h>
56+#include <gdk/gdkx.h>
57+
58+#include <unity-webapps-context.h>
59+
60+#include "unity-npapi-tools.h"
61+
62+
63+void
64+unity_npapi_tools_set_xid_for_browser_window_id(UnityWebappsContext *context,
65+ int window_id)
66+{
67+ const gchar * const
68+ CHROMIUM_LINUX_SESSION_ID_PROPERTY = "CHROMIUM_LINUX_SESSION_ID_PROPERTY";
69+
70+ WnckScreen *screen;
71+ GList *windows, *walk;
72+
73+ // idempotent
74+ gtk_init(NULL, NULL);
75+
76+ screen = wnck_screen_get_default();
77+
78+ // TODO find a way to get it from the WnckScreen?
79+ GdkDisplay* display = gdk_display_get_default();
80+
81+ wnck_screen_force_update (screen);
82+
83+ windows = wnck_screen_get_windows_stacked (screen);
84+
85+ for (walk = windows; walk != NULL; walk = walk->next)
86+ {
87+ WnckWindow *window = WNCK_WINDOW (walk->data);
88+
89+ GdkWindow *active_window =
90+ gdk_x11_window_foreign_new_for_display (display,
91+ wnck_window_get_xid(window));
92+ if (NULL == active_window)
93+ {
94+ g_message ("Could not retrieve GdkWindow for xid %ld",
95+ wnck_window_get_xid(window));
96+ continue;
97+ }
98+
99+ GdkAtom atom;
100+ gint format = 0;
101+ gint out_length = 0;
102+ gint * session_id = NULL;
103+ gboolean have_prop =
104+ gdk_property_get (active_window,
105+ gdk_atom_intern(CHROMIUM_LINUX_SESSION_ID_PROPERTY,
106+ FALSE),
107+ gdk_atom_intern("CARDINAL", FALSE),
108+ 0L,
109+ 4,
110+ FALSE,
111+ &atom,
112+ &format,
113+ &out_length,
114+ (guchar **)&session_id);
115+ if (TRUE == have_prop &&
116+ NULL != session_id &&
117+ window_id == session_id[0])
118+ {
119+ unity_webapps_context_set_view_window (context,
120+ (guint64) wnck_window_get_xid (window));
121+
122+ g_free (session_id);
123+ break;
124+ }
125+ }
126+}
127+
128
129=== added file 'npapi-plugin/src/unity-npapi-tools.h'
130--- npapi-plugin/src/unity-npapi-tools.h 1970-01-01 00:00:00 +0000
131+++ npapi-plugin/src/unity-npapi-tools.h 2013-03-07 22:12:24 +0000
132@@ -0,0 +1,30 @@
133+/*
134+ * unity-npapi-tools.h
135+ * Copyright (C) Canonical LTD 2013
136+ *
137+ * Author: Alexandre Abreu <alexandre.abreu@canonical.com>
138+ *
139+ * This program is free software; you can redistribute it and/or modify
140+ * it under the terms of the GNU General Public License as published by
141+ * the Free Software Foundation; either version 2 of the License, or
142+ * (at your option) any later version.
143+ *
144+ * This program is distributed in the hope that it will be useful,
145+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
146+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
147+ * GNU General Public License for more details.
148+ *
149+ * You should have received a copy of the GNU General Public License
150+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
151+ */
152+
153+#if ! defined (UNITY_NPAPI_TOOLS_H)
154+#define UNITY_NPAPI_TOOLS_H
155+
156+typedef struct _UnityWebappsContext UnityWebappsContext;
157+
158+void
159+unity_npapi_tools_set_xid_for_browser_window_id(UnityWebappsContext *context,
160+ int window_id);
161+
162+#endif // UNITY_NPAPI_TOOLS_H
163
164=== modified file 'npapi-plugin/src/unity-webapps-binding.c'
165--- npapi-plugin/src/unity-webapps-binding.c 2012-09-12 16:22:59 +0000
166+++ npapi-plugin/src/unity-webapps-binding.c 2013-03-07 22:12:24 +0000
167@@ -39,6 +39,7 @@
168 #include "unity-npapi-binding-utils.h"
169 #include "unity-webapps-scriptable-object.h"
170 #include "unity-npapi-plugin.h"
171+#include "unity-npapi-tools.h"
172
173 NPVariant
174 unity_webapps_binding_service_new (NPP instance
175@@ -2849,7 +2850,7 @@
176
177 REACHED_UNITY_WEBAPPS_FUNC_CALL();
178
179- unity_webapps_service_set_xid_for_browser_window_id (service, context, window_id);
180+ unity_npapi_tools_set_xid_for_browser_window_id (context, window_id);
181
182 return result;
183 }

Subscribers

People subscribed via source and target branches

to all changes: