Merge lp:~attente/gtk/gtk-mir into lp:~ubuntu-desktop/gtk/ubuntugtk3
- gtk-mir
- Merge into ubuntugtk3
Status: | Merged |
---|---|
Merged at revision: | 544 |
Proposed branch: | lp:~attente/gtk/gtk-mir |
Merge into: | lp:~ubuntu-desktop/gtk/ubuntugtk3 |
Diff against target: |
2085 lines (+1996/-2) 14 files modified
debian/changelog (+20/-0) debian/control (+2/-1) debian/control.in (+2/-1) debian/patches/0001-mir-implement-window-properties.patch (+244/-0) debian/patches/0002-mir-track-focused-window.patch (+91/-0) debian/patches/0003-mir-connect-to-content-hub.patch (+108/-0) debian/patches/0004-mir-copy-clipboard-data-to-content-hub.patch (+292/-0) debian/patches/0005-mir-paste-clipboard-data-from-content-hub.patch (+415/-0) debian/patches/0006-mir-properly-handle-empty-clipboard.patch (+37/-0) debian/patches/0031-mir-fix-compile-time-warnings.patch (+77/-0) debian/patches/0032-mir-use-modal-window-hint.patch (+76/-0) debian/patches/0036-mir-use-mir_surface_spec_set_placement-for-menus.patch (+334/-0) debian/patches/0037-mir-handle-surface-placement-events.patch (+287/-0) debian/patches/series (+11/-0) |
To merge this branch: | bzr merge lp:~attente/gtk/gtk-mir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeremy Bícha | Approve | ||
Review via email: mp+316716@code.launchpad.net |
Commit message
* debian/control:
* debian/control.in:
- Build depend on libcontent-
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
- Add upstream patches from gtk-3-22 branch
Description of the change
Apply upstream patches from gtk-3-22 branch:
* debian/control:
* debian/control.in:
- Build depend on libcontent-
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
* debian/
- Add upstream patches from gtk-3-22 branch
- 544. By William Hua
-
* debian/control:
* debian/control.in:
- Build depend on libcontent-hub-glib- dev
* debian/patches/ series:
* debian/patches/ 0001-mir- implement- window- properties. patch:
* debian/patches/ 0002-mir- track-focused- window. patch:
* debian/patches/ 0003-mir- connect- to-content- hub.patch:
* debian/patches/ 0004-mir- copy-clipboard- data-to- content- hub.patch:
* debian/patches/ 0005-mir- paste-clipboard -data-from- content- hub.patch:
* debian/patches/ 0006-mir- properly- handle- empty-clipboard .patch:
* debian/patches/ 0031-mir- fix-compile- time-warnings. patch:
* debian/patches/ 0032-mir- use-modal- window- hint.patch:
* debian/patches/ 0036-mir- use-mir_ surface_ spec_set_ placement- for-menus. patch:
* debian/patches/ 0037-mir- handle- surface- placement- events. patch:
- Add upstream patches from gtk-3-22 branch
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2017-01-23 14:44:32 +0000 | |||
3 | +++ debian/changelog 2017-02-08 17:37:49 +0000 | |||
4 | @@ -1,3 +1,23 @@ | |||
5 | 1 | gtk+3.0 (3.22.7-1ubuntu3) zesty; urgency=medium | ||
6 | 2 | |||
7 | 3 | * debian/control: | ||
8 | 4 | * debian/control.in: | ||
9 | 5 | - Build depend on libcontent-hub-glib-dev | ||
10 | 6 | * debian/patches/series: | ||
11 | 7 | * debian/patches/0001-mir-implement-window-properties.patch: | ||
12 | 8 | * debian/patches/0002-mir-track-focused-window.patch: | ||
13 | 9 | * debian/patches/0003-mir-connect-to-content-hub.patch: | ||
14 | 10 | * debian/patches/0004-mir-copy-clipboard-data-to-content-hub.patch: | ||
15 | 11 | * debian/patches/0005-mir-paste-clipboard-data-from-content-hub.patch: | ||
16 | 12 | * debian/patches/0006-mir-properly-handle-empty-clipboard.patch: | ||
17 | 13 | * debian/patches/0031-mir-fix-compile-time-warnings.patch: | ||
18 | 14 | * debian/patches/0032-mir-use-modal-window-hint.patch: | ||
19 | 15 | * debian/patches/0036-mir-use-mir_surface_spec_set_placement-for-menus.patch: | ||
20 | 16 | * debian/patches/0037-mir-handle-surface-placement-events.patch: | ||
21 | 17 | - Add upstream patches from gtk-3-22 branch | ||
22 | 18 | |||
23 | 19 | -- William Hua <william.hua@canonical.com> Wed, 08 Feb 2017 10:27:45 -0500 | ||
24 | 20 | |||
25 | 1 | gtk+3.0 (3.22.7-1ubuntu2) zesty; urgency=medium | 21 | gtk+3.0 (3.22.7-1ubuntu2) zesty; urgency=medium |
26 | 2 | 22 | ||
27 | 3 | * Restore gtksocket-unscale-before-sending-configurenotify.patch: | 23 | * Restore gtksocket-unscale-before-sending-configurenotify.patch: |
28 | 4 | 24 | ||
29 | === modified file 'debian/control' | |||
30 | --- debian/control 2016-10-24 16:41:31 +0000 | |||
31 | +++ debian/control 2017-02-08 17:37:49 +0000 | |||
32 | @@ -52,7 +52,8 @@ | |||
33 | 52 | xsltproc, | 52 | xsltproc, |
34 | 53 | xvfb <!nocheck>, | 53 | xvfb <!nocheck>, |
35 | 54 | libmirclient-dev (>= 0.13.3), | 54 | libmirclient-dev (>= 0.13.3), |
37 | 55 | libmircookie-dev (>= 0.17.0) | 55 | libmircookie-dev (>= 0.17.0), |
38 | 56 | libcontent-hub-glib-dev, | ||
39 | 56 | Build-Depends-Indep: libglib2.0-doc, | 57 | Build-Depends-Indep: libglib2.0-doc, |
40 | 57 | libatk1.0-doc, | 58 | libatk1.0-doc, |
41 | 58 | libpango1.0-doc, | 59 | libpango1.0-doc, |
42 | 59 | 60 | ||
43 | === modified file 'debian/control.in' | |||
44 | --- debian/control.in 2016-10-24 16:41:31 +0000 | |||
45 | +++ debian/control.in 2017-02-08 17:37:49 +0000 | |||
46 | @@ -52,7 +52,8 @@ | |||
47 | 52 | xsltproc, | 52 | xsltproc, |
48 | 53 | xvfb <!nocheck>, | 53 | xvfb <!nocheck>, |
49 | 54 | libmirclient-dev (>= 0.13.3), | 54 | libmirclient-dev (>= 0.13.3), |
51 | 55 | libmircookie-dev (>= 0.17.0) | 55 | libmircookie-dev (>= 0.17.0), |
52 | 56 | libcontent-hub-glib-dev, | ||
53 | 56 | Build-Depends-Indep: libglib2.0-doc, | 57 | Build-Depends-Indep: libglib2.0-doc, |
54 | 57 | libatk1.0-doc, | 58 | libatk1.0-doc, |
55 | 58 | libpango1.0-doc, | 59 | libpango1.0-doc, |
56 | 59 | 60 | ||
57 | === added file 'debian/patches/0001-mir-implement-window-properties.patch' | |||
58 | --- debian/patches/0001-mir-implement-window-properties.patch 1970-01-01 00:00:00 +0000 | |||
59 | +++ debian/patches/0001-mir-implement-window-properties.patch 2017-02-08 17:37:49 +0000 | |||
60 | @@ -0,0 +1,244 @@ | |||
61 | 1 | From b6baa088dccecb25130d056f33d8078d198dd2d7 Mon Sep 17 00:00:00 2001 | ||
62 | 2 | From: William Hua <william.hua@canonical.com> | ||
63 | 3 | Date: Tue, 11 Oct 2016 19:06:12 -0400 | ||
64 | 4 | Subject: [PATCH 01/38] mir: implement window properties | ||
65 | 5 | |||
66 | 6 | https://bugzilla.gnome.org/show_bug.cgi?id=775732 | ||
67 | 7 | --- | ||
68 | 8 | gdk/mir/gdkmirwindowimpl.c | 179 +++++++++++++++++++++++++++++++++++++++++---- | ||
69 | 9 | 1 file changed, 163 insertions(+), 16 deletions(-) | ||
70 | 10 | |||
71 | 11 | diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c | ||
72 | 12 | index a7be39c..48e66ca 100644 | ||
73 | 13 | --- a/gdk/mir/gdkmirwindowimpl.c | ||
74 | 14 | +++ b/gdk/mir/gdkmirwindowimpl.c | ||
75 | 15 | @@ -36,12 +36,45 @@ | ||
76 | 16 | |||
77 | 17 | #define MAX_EGL_ATTRS 30 | ||
78 | 18 | |||
79 | 19 | +typedef struct | ||
80 | 20 | +{ | ||
81 | 21 | + GdkAtom type; | ||
82 | 22 | + GArray *array; | ||
83 | 23 | +} GdkMirProperty; | ||
84 | 24 | + | ||
85 | 25 | +static GdkMirProperty * | ||
86 | 26 | +gdk_mir_property_new (GdkAtom type, | ||
87 | 27 | + guint format, | ||
88 | 28 | + guint capacity) | ||
89 | 29 | +{ | ||
90 | 30 | + GdkMirProperty *property = g_slice_new (GdkMirProperty); | ||
91 | 31 | + | ||
92 | 32 | + property->type = type; | ||
93 | 33 | + property->array = g_array_sized_new (TRUE, FALSE, format, capacity); | ||
94 | 34 | + | ||
95 | 35 | + return property; | ||
96 | 36 | +} | ||
97 | 37 | + | ||
98 | 38 | +static void | ||
99 | 39 | +gdk_mir_property_free (gpointer data) | ||
100 | 40 | +{ | ||
101 | 41 | + GdkMirProperty *property = data; | ||
102 | 42 | + | ||
103 | 43 | + if (!property) | ||
104 | 44 | + return; | ||
105 | 45 | + | ||
106 | 46 | + g_array_unref (property->array); | ||
107 | 47 | + g_slice_free (GdkMirProperty, property); | ||
108 | 48 | +} | ||
109 | 49 | + | ||
110 | 50 | typedef struct _GdkMirWindowImplClass GdkMirWindowImplClass; | ||
111 | 51 | |||
112 | 52 | struct _GdkMirWindowImpl | ||
113 | 53 | { | ||
114 | 54 | GdkWindowImpl parent_instance; | ||
115 | 55 | |||
116 | 56 | + GHashTable *properties; | ||
117 | 57 | + | ||
118 | 58 | /* Window we are temporary for */ | ||
119 | 59 | GdkWindow *transient_for; | ||
120 | 60 | gint transient_x; | ||
121 | 61 | @@ -233,6 +266,7 @@ _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, | ||
122 | 62 | static void | ||
123 | 63 | gdk_mir_window_impl_init (GdkMirWindowImpl *impl) | ||
124 | 64 | { | ||
125 | 65 | + impl->properties = g_hash_table_new_full (NULL, NULL, NULL, gdk_mir_property_free); | ||
126 | 66 | impl->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL; | ||
127 | 67 | impl->surface_state = mir_surface_state_unknown; | ||
128 | 68 | impl->output_scale = 1; | ||
129 | 69 | @@ -687,6 +721,8 @@ gdk_mir_window_impl_finalize (GObject *object) | ||
130 | 70 | if (impl->cairo_surface) | ||
131 | 71 | cairo_surface_destroy (impl->cairo_surface); | ||
132 | 72 | |||
133 | 73 | + g_clear_pointer (&impl->properties, g_hash_table_unref); | ||
134 | 74 | + | ||
135 | 75 | G_OBJECT_CLASS (gdk_mir_window_impl_parent_class)->finalize (object); | ||
136 | 76 | } | ||
137 | 77 | |||
138 | 78 | @@ -1482,19 +1518,79 @@ gdk_mir_window_impl_simulate_button (GdkWindow *window, | ||
139 | 79 | } | ||
140 | 80 | |||
141 | 81 | static gboolean | ||
142 | 82 | -gdk_mir_window_impl_get_property (GdkWindow *window, | ||
143 | 83 | - GdkAtom property, | ||
144 | 84 | - GdkAtom type, | ||
145 | 85 | - gulong offset, | ||
146 | 86 | - gulong length, | ||
147 | 87 | - gint pdelete, | ||
148 | 88 | - GdkAtom *actual_property_type, | ||
149 | 89 | - gint *actual_format_type, | ||
150 | 90 | - gint *actual_length, | ||
151 | 91 | - guchar **data) | ||
152 | 92 | -{ | ||
153 | 93 | - //g_printerr ("gdk_mir_window_impl_get_property window=%p\n", window); | ||
154 | 94 | - return FALSE; | ||
155 | 95 | +gdk_mir_window_impl_get_property (GdkWindow *window, | ||
156 | 96 | + GdkAtom property, | ||
157 | 97 | + GdkAtom type, | ||
158 | 98 | + gulong offset, | ||
159 | 99 | + gulong length, | ||
160 | 100 | + gint pdelete, | ||
161 | 101 | + GdkAtom *actual_type, | ||
162 | 102 | + gint *actual_format, | ||
163 | 103 | + gint *actual_length, | ||
164 | 104 | + guchar **data) | ||
165 | 105 | +{ | ||
166 | 106 | + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
167 | 107 | + GdkMirProperty *mir_property; | ||
168 | 108 | + GdkAtom dummy_actual_type; | ||
169 | 109 | + gint dummy_actual_format; | ||
170 | 110 | + gint dummy_actual_length; | ||
171 | 111 | + guint width; | ||
172 | 112 | + | ||
173 | 113 | + if (!actual_type) | ||
174 | 114 | + actual_type = &dummy_actual_type; | ||
175 | 115 | + if (!actual_format) | ||
176 | 116 | + actual_format = &dummy_actual_format; | ||
177 | 117 | + if (!actual_length) | ||
178 | 118 | + actual_length = &dummy_actual_length; | ||
179 | 119 | + | ||
180 | 120 | + *actual_type = GDK_NONE; | ||
181 | 121 | + *actual_format = 0; | ||
182 | 122 | + *actual_length = 0; | ||
183 | 123 | + | ||
184 | 124 | + if (data) | ||
185 | 125 | + *data = NULL; | ||
186 | 126 | + | ||
187 | 127 | + mir_property = g_hash_table_lookup (impl->properties, property); | ||
188 | 128 | + | ||
189 | 129 | + if (!mir_property) | ||
190 | 130 | + return FALSE; | ||
191 | 131 | + | ||
192 | 132 | + width = g_array_get_element_size (mir_property->array); | ||
193 | 133 | + *actual_type = mir_property->type; | ||
194 | 134 | + *actual_format = 8 * width; | ||
195 | 135 | + | ||
196 | 136 | + /* ICCCM 2.7: GdkAtoms can be 64-bit, but ATOMs and ATOM_PAIRs have format 32 */ | ||
197 | 137 | + if (*actual_type == GDK_SELECTION_TYPE_ATOM || *actual_type == gdk_atom_intern_static_string ("ATOM_PAIR")) | ||
198 | 138 | + *actual_format = 32; | ||
199 | 139 | + | ||
200 | 140 | + if (type != GDK_NONE && type != mir_property->type) | ||
201 | 141 | + return FALSE; | ||
202 | 142 | + | ||
203 | 143 | + offset *= 4; | ||
204 | 144 | + | ||
205 | 145 | + /* round up to next nearest multiple of width */ | ||
206 | 146 | + if (length < G_MAXULONG - width + 1) | ||
207 | 147 | + length = (length - 1 + width) / width * width; | ||
208 | 148 | + else | ||
209 | 149 | + length = G_MAXULONG / width * width; | ||
210 | 150 | + | ||
211 | 151 | + /* we're skipping the first offset bytes */ | ||
212 | 152 | + if (length > mir_property->array->len * width - offset) | ||
213 | 153 | + length = mir_property->array->len * width - offset; | ||
214 | 154 | + | ||
215 | 155 | + /* leave room for null terminator */ | ||
216 | 156 | + if (length > G_MAXULONG - width) | ||
217 | 157 | + length -= width; | ||
218 | 158 | + | ||
219 | 159 | + *actual_length = length; | ||
220 | 160 | + | ||
221 | 161 | + if (data) | ||
222 | 162 | + { | ||
223 | 163 | + *data = g_memdup (mir_property->array->data + offset, length + width); | ||
224 | 164 | + memset (*data + length, 0, width); | ||
225 | 165 | + } | ||
226 | 166 | + | ||
227 | 167 | + return TRUE; | ||
228 | 168 | } | ||
229 | 169 | |||
230 | 170 | static void | ||
231 | 171 | @@ -1504,16 +1600,67 @@ gdk_mir_window_impl_change_property (GdkWindow *window, | ||
232 | 172 | gint format, | ||
233 | 173 | GdkPropMode mode, | ||
234 | 174 | const guchar *data, | ||
235 | 175 | - gint nelements) | ||
236 | 176 | + gint n_elements) | ||
237 | 177 | { | ||
238 | 178 | - //g_printerr ("gdk_mir_window_impl_change_property window=%p\n", window); | ||
239 | 179 | + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
240 | 180 | + GdkMirProperty *mir_property; | ||
241 | 181 | + GdkEvent *event; | ||
242 | 182 | + | ||
243 | 183 | + /* ICCCM 2.7: ATOMs and ATOM_PAIRs have format 32, but GdkAtoms can be 64-bit */ | ||
244 | 184 | + if (type == GDK_SELECTION_TYPE_ATOM || type == gdk_atom_intern_static_string ("ATOM_PAIR")) | ||
245 | 185 | + format = 8 * sizeof (GdkAtom); | ||
246 | 186 | + | ||
247 | 187 | + if (mode != GDK_PROP_MODE_REPLACE) | ||
248 | 188 | + mir_property = g_hash_table_lookup (impl->properties, property); | ||
249 | 189 | + else | ||
250 | 190 | + mir_property = NULL; | ||
251 | 191 | + | ||
252 | 192 | + if (!mir_property) | ||
253 | 193 | + { | ||
254 | 194 | + /* format is measured in bits, but we need to know this in bytes */ | ||
255 | 195 | + mir_property = gdk_mir_property_new (type, format / 8, n_elements); | ||
256 | 196 | + g_hash_table_insert (impl->properties, property, mir_property); | ||
257 | 197 | + } | ||
258 | 198 | + | ||
259 | 199 | + /* format is measured in bits, but we need to know this in bytes */ | ||
260 | 200 | + if (type != mir_property->type || format / 8 != g_array_get_element_size (mir_property->array)) | ||
261 | 201 | + return; | ||
262 | 202 | + | ||
263 | 203 | + if (mode == GDK_PROP_MODE_PREPEND) | ||
264 | 204 | + g_array_prepend_vals (mir_property->array, data, n_elements); | ||
265 | 205 | + else | ||
266 | 206 | + g_array_append_vals (mir_property->array, data, n_elements); | ||
267 | 207 | + | ||
268 | 208 | + event = gdk_event_new (GDK_PROPERTY_NOTIFY); | ||
269 | 209 | + event->property.window = g_object_ref (window); | ||
270 | 210 | + event->property.send_event = FALSE; | ||
271 | 211 | + event->property.atom = property; | ||
272 | 212 | + event->property.time = GDK_CURRENT_TIME; | ||
273 | 213 | + event->property.state = GDK_PROPERTY_NEW_VALUE; | ||
274 | 214 | + | ||
275 | 215 | + gdk_event_put (event); | ||
276 | 216 | + gdk_event_free (event); | ||
277 | 217 | } | ||
278 | 218 | |||
279 | 219 | static void | ||
280 | 220 | gdk_mir_window_impl_delete_property (GdkWindow *window, | ||
281 | 221 | GdkAtom property) | ||
282 | 222 | { | ||
283 | 223 | - //g_printerr ("gdk_mir_window_impl_delete_property window=%p\n", window); | ||
284 | 224 | + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
285 | 225 | + GdkEvent *event; | ||
286 | 226 | + | ||
287 | 227 | + if (g_hash_table_remove (impl->properties, property)) | ||
288 | 228 | + { | ||
289 | 229 | + event = gdk_event_new (GDK_PROPERTY_NOTIFY); | ||
290 | 230 | + event->property.window = g_object_ref (window); | ||
291 | 231 | + event->property.send_event = FALSE; | ||
292 | 232 | + event->property.atom = property; | ||
293 | 233 | + event->property.time = GDK_CURRENT_TIME; | ||
294 | 234 | + event->property.state = GDK_PROPERTY_DELETE; | ||
295 | 235 | + | ||
296 | 236 | + gdk_event_put (event); | ||
297 | 237 | + gdk_event_free (event); | ||
298 | 238 | + } | ||
299 | 239 | } | ||
300 | 240 | |||
301 | 241 | static gint | ||
302 | 242 | -- | ||
303 | 243 | 2.10.2 | ||
304 | 244 | |||
305 | 0 | 245 | ||
306 | === added file 'debian/patches/0002-mir-track-focused-window.patch' | |||
307 | --- debian/patches/0002-mir-track-focused-window.patch 1970-01-01 00:00:00 +0000 | |||
308 | +++ debian/patches/0002-mir-track-focused-window.patch 2017-02-08 17:37:49 +0000 | |||
309 | @@ -0,0 +1,91 @@ | |||
310 | 1 | From 0acb58b40fbc158f94486195e35088f610071583 Mon Sep 17 00:00:00 2001 | ||
311 | 2 | From: William Hua <william.hua@canonical.com> | ||
312 | 3 | Date: Fri, 14 Oct 2016 17:00:34 -0400 | ||
313 | 4 | Subject: [PATCH 02/38] mir: track focused window | ||
314 | 5 | |||
315 | 6 | https://bugzilla.gnome.org/show_bug.cgi?id=775732 | ||
316 | 7 | --- | ||
317 | 8 | gdk/mir/gdkmir-private.h | 4 ++++ | ||
318 | 9 | gdk/mir/gdkmirdisplay.c | 21 +++++++++++++++++++++ | ||
319 | 10 | gdk/mir/gdkmireventsource.c | 10 ++++++++-- | ||
320 | 11 | 3 files changed, 33 insertions(+), 2 deletions(-) | ||
321 | 12 | |||
322 | 13 | diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h | ||
323 | 14 | index 38f1d7a..7e3893c 100644 | ||
324 | 15 | --- a/gdk/mir/gdkmir-private.h | ||
325 | 16 | +++ b/gdk/mir/gdkmir-private.h | ||
326 | 17 | @@ -107,6 +107,10 @@ void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEv | ||
327 | 18 | |||
328 | 19 | MirPixelFormat _gdk_mir_display_get_pixel_format (GdkDisplay *display, MirBufferUsage usage); | ||
329 | 20 | |||
330 | 21 | +void _gdk_mir_display_focus_window (GdkDisplay *display, GdkWindow *window); | ||
331 | 22 | + | ||
332 | 23 | +void _gdk_mir_display_unfocus_window (GdkDisplay *display, GdkWindow *window); | ||
333 | 24 | + | ||
334 | 25 | gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display); | ||
335 | 26 | |||
336 | 27 | EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display); | ||
337 | 28 | diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c | ||
338 | 29 | index eea892c..89cfad2 100644 | ||
339 | 30 | --- a/gdk/mir/gdkmirdisplay.c | ||
340 | 31 | +++ b/gdk/mir/gdkmirdisplay.c | ||
341 | 32 | @@ -47,6 +47,8 @@ typedef struct GdkMirDisplay | ||
342 | 33 | |||
343 | 34 | GdkKeymap *keymap; | ||
344 | 35 | |||
345 | 36 | + GdkWindow *focused_window; | ||
346 | 37 | + | ||
347 | 38 | MirPixelFormat sw_pixel_format; | ||
348 | 39 | MirPixelFormat hw_pixel_format; | ||
349 | 40 | |||
350 | 41 | @@ -582,6 +584,25 @@ _gdk_mir_display_get_pixel_format (GdkDisplay *display, | ||
351 | 42 | return mir_dpy->sw_pixel_format; | ||
352 | 43 | } | ||
353 | 44 | |||
354 | 45 | +void | ||
355 | 46 | +_gdk_mir_display_focus_window (GdkDisplay *display, | ||
356 | 47 | + GdkWindow *window) | ||
357 | 48 | +{ | ||
358 | 49 | + GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display); | ||
359 | 50 | + | ||
360 | 51 | + g_set_object (&mir_display->focused_window, window); | ||
361 | 52 | +} | ||
362 | 53 | + | ||
363 | 54 | +void | ||
364 | 55 | +_gdk_mir_display_unfocus_window (GdkDisplay *display, | ||
365 | 56 | + GdkWindow *window) | ||
366 | 57 | +{ | ||
367 | 58 | + GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display); | ||
368 | 59 | + | ||
369 | 60 | + if (window == mir_display->focused_window) | ||
370 | 61 | + g_clear_object (&mir_display->focused_window); | ||
371 | 62 | +} | ||
372 | 63 | + | ||
373 | 64 | gboolean | ||
374 | 65 | _gdk_mir_display_init_egl_display (GdkDisplay *display) | ||
375 | 66 | { | ||
376 | 67 | diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c | ||
377 | 68 | index 8c7e106..a2a1a12 100644 | ||
378 | 69 | --- a/gdk/mir/gdkmireventsource.c | ||
379 | 70 | +++ b/gdk/mir/gdkmireventsource.c | ||
380 | 71 | @@ -240,9 +240,15 @@ generate_focus_event (GdkWindow *window, gboolean focused) | ||
381 | 72 | GdkEvent *event; | ||
382 | 73 | |||
383 | 74 | if (focused) | ||
384 | 75 | - gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED); | ||
385 | 76 | + { | ||
386 | 77 | + gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED); | ||
387 | 78 | + _gdk_mir_display_focus_window (gdk_window_get_display (window), window); | ||
388 | 79 | + } | ||
389 | 80 | else | ||
390 | 81 | - gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0); | ||
391 | 82 | + { | ||
392 | 83 | + gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0); | ||
393 | 84 | + _gdk_mir_display_unfocus_window (gdk_window_get_display (window), window); | ||
394 | 85 | + } | ||
395 | 86 | |||
396 | 87 | event = gdk_event_new (GDK_FOCUS_CHANGE); | ||
397 | 88 | event->focus_change.send_event = FALSE; | ||
398 | 89 | -- | ||
399 | 90 | 2.10.2 | ||
400 | 91 | |||
401 | 0 | 92 | ||
402 | === added file 'debian/patches/0003-mir-connect-to-content-hub.patch' | |||
403 | --- debian/patches/0003-mir-connect-to-content-hub.patch 1970-01-01 00:00:00 +0000 | |||
404 | +++ debian/patches/0003-mir-connect-to-content-hub.patch 2017-02-08 17:37:49 +0000 | |||
405 | @@ -0,0 +1,108 @@ | |||
406 | 1 | From 210d1279e5811ae18b0bad13f16a97c7ec98598e Mon Sep 17 00:00:00 2001 | ||
407 | 2 | From: William Hua <william.hua@canonical.com> | ||
408 | 3 | Date: Tue, 11 Oct 2016 16:53:48 -0400 | ||
409 | 4 | Subject: [PATCH 03/38] mir: connect to content-hub | ||
410 | 5 | |||
411 | 6 | https://bugzilla.gnome.org/show_bug.cgi?id=775732 | ||
412 | 7 | --- | ||
413 | 8 | configure.ac | 2 +- | ||
414 | 9 | gdk/mir/gdkmirdisplay.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
415 | 10 | 2 files changed, 43 insertions(+), 1 deletion(-) | ||
416 | 11 | |||
417 | 12 | diff --git a/configure.ac b/configure.ac | ||
418 | 13 | index ea609b3..000e37a 100644 | ||
419 | 14 | --- a/configure.ac | ||
420 | 15 | +++ b/configure.ac | ||
421 | 16 | @@ -464,7 +464,7 @@ else | ||
422 | 17 | AM_CONDITIONAL(USE_WAYLAND, false) | ||
423 | 18 | fi | ||
424 | 19 | |||
425 | 20 | -MIR_DEPENDENCIES="mirclient >= mirclient_required_version mircookie >= mircookie_required_version" | ||
426 | 21 | +MIR_DEPENDENCIES="mirclient >= mirclient_required_version mircookie >= mircookie_required_version libcontent-hub-glib" | ||
427 | 22 | if test "$enable_mir_backend" = "maybe" ; then | ||
428 | 23 | PKG_CHECK_EXISTS($MIR_DEPENDENCIES, [have_mir_deps=yes], [have_mir_deps=no]) | ||
429 | 24 | AC_MSG_CHECKING([for MIR_DEPENDENCIES]) | ||
430 | 25 | diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c | ||
431 | 26 | index 89cfad2..718ab60 100644 | ||
432 | 27 | --- a/gdk/mir/gdkmirdisplay.c | ||
433 | 28 | +++ b/gdk/mir/gdkmirdisplay.c | ||
434 | 29 | @@ -23,6 +23,8 @@ | ||
435 | 30 | #include "gdkmir.h" | ||
436 | 31 | #include "gdkmir-private.h" | ||
437 | 32 | |||
438 | 33 | +#include <com/ubuntu/content/glib/content-hub-glib.h> | ||
439 | 34 | + | ||
440 | 35 | #define GDK_TYPE_DISPLAY_MIR (gdk_mir_display_get_type ()) | ||
441 | 36 | #define GDK_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_MIR, GdkMirDisplay)) | ||
442 | 37 | #define GDK_MIR_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_MIR, GdkMirDisplayClass)) | ||
443 | 38 | @@ -57,6 +59,9 @@ typedef struct GdkMirDisplay | ||
444 | 39 | guint have_egl_buffer_age : 1; | ||
445 | 40 | guint have_egl_swap_buffers_with_damage : 1; | ||
446 | 41 | guint have_egl_surfaceless_context : 1; | ||
447 | 42 | + | ||
448 | 43 | + ContentHubService *content_service; | ||
449 | 44 | + ContentHubHandler *content_handler; | ||
450 | 45 | } GdkMirDisplay; | ||
451 | 46 | |||
452 | 47 | typedef struct GdkMirDisplayClass | ||
453 | 48 | @@ -108,6 +113,7 @@ _gdk_mir_display_open (const gchar *display_name) | ||
454 | 49 | MirConnection *connection; | ||
455 | 50 | MirPixelFormat sw_pixel_format, hw_pixel_format; | ||
456 | 51 | GdkMirDisplay *display; | ||
457 | 52 | + GDBusConnection *session; | ||
458 | 53 | |||
459 | 54 | //g_printerr ("gdk_mir_display_open\n"); | ||
460 | 55 | |||
461 | 56 | @@ -140,6 +146,39 @@ _gdk_mir_display_open (const gchar *display_name) | ||
462 | 57 | display->sw_pixel_format = sw_pixel_format; | ||
463 | 58 | display->hw_pixel_format = hw_pixel_format; | ||
464 | 59 | |||
465 | 60 | + session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); | ||
466 | 61 | + | ||
467 | 62 | + display->content_service = content_hub_service_proxy_new_sync ( | ||
468 | 63 | + session, | ||
469 | 64 | + G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES, | ||
470 | 65 | + "com.ubuntu.content.dbus.Service", | ||
471 | 66 | + "/", | ||
472 | 67 | + NULL, | ||
473 | 68 | + NULL); | ||
474 | 69 | + | ||
475 | 70 | + display->content_handler = content_hub_handler_skeleton_new (); | ||
476 | 71 | + | ||
477 | 72 | + g_dbus_interface_skeleton_export ( | ||
478 | 73 | + G_DBUS_INTERFACE_SKELETON (display->content_handler), | ||
479 | 74 | + session, | ||
480 | 75 | + "/org/gnome/gtk/content/handler", | ||
481 | 76 | + NULL); | ||
482 | 77 | + | ||
483 | 78 | + g_object_unref (session); | ||
484 | 79 | + | ||
485 | 80 | + content_hub_service_call_register_import_export_handler_sync ( | ||
486 | 81 | + display->content_service, | ||
487 | 82 | + g_application_get_application_id (g_application_get_default ()), | ||
488 | 83 | + "/org/gnome/gtk/content/handler", | ||
489 | 84 | + NULL, | ||
490 | 85 | + NULL); | ||
491 | 86 | + | ||
492 | 87 | + content_hub_service_call_handler_active_sync ( | ||
493 | 88 | + display->content_service, | ||
494 | 89 | + g_application_get_application_id (g_application_get_default ()), | ||
495 | 90 | + NULL, | ||
496 | 91 | + NULL); | ||
497 | 92 | + | ||
498 | 93 | g_signal_emit_by_name (display, "opened"); | ||
499 | 94 | |||
500 | 95 | return GDK_DISPLAY (display); | ||
501 | 96 | @@ -175,6 +214,9 @@ gdk_mir_display_dispose (GObject *object) | ||
502 | 97 | { | ||
503 | 98 | GdkMirDisplay *display = GDK_MIR_DISPLAY (object); | ||
504 | 99 | |||
505 | 100 | + g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (display->content_handler)); | ||
506 | 101 | + g_clear_object (&display->content_handler); | ||
507 | 102 | + g_clear_object (&display->content_service); | ||
508 | 103 | g_clear_object (&display->screen); | ||
509 | 104 | g_clear_object (&display->keymap); | ||
510 | 105 | g_clear_pointer (&display->event_source, g_source_unref); | ||
511 | 106 | -- | ||
512 | 107 | 2.10.2 | ||
513 | 108 | |||
514 | 0 | 109 | ||
515 | === added file 'debian/patches/0004-mir-copy-clipboard-data-to-content-hub.patch' | |||
516 | --- debian/patches/0004-mir-copy-clipboard-data-to-content-hub.patch 1970-01-01 00:00:00 +0000 | |||
517 | +++ debian/patches/0004-mir-copy-clipboard-data-to-content-hub.patch 2017-02-08 17:37:49 +0000 | |||
518 | @@ -0,0 +1,292 @@ | |||
519 | 1 | From 5c4c3f1afd9a56644c1d204df3a9f5f1526ffa38 Mon Sep 17 00:00:00 2001 | ||
520 | 2 | From: William Hua <william.hua@canonical.com> | ||
521 | 3 | Date: Wed, 12 Oct 2016 16:56:01 -0400 | ||
522 | 4 | Subject: [PATCH 04/38] mir: copy clipboard data to content-hub | ||
523 | 5 | |||
524 | 6 | https://bugzilla.gnome.org/show_bug.cgi?id=775732 | ||
525 | 7 | --- | ||
526 | 8 | gdk/mir/gdkmir-private.h | 5 ++ | ||
527 | 9 | gdk/mir/gdkmirdisplay.c | 60 +++++++++++++++++- | ||
528 | 10 | gdk/mir/gdkmirwindowimpl.c | 150 ++++++++++++++++++++++++++++++++++++++++++++- | ||
529 | 11 | 3 files changed, 212 insertions(+), 3 deletions(-) | ||
530 | 12 | |||
531 | 13 | diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h | ||
532 | 14 | index 7e3893c..a677dec 100644 | ||
533 | 15 | --- a/gdk/mir/gdkmir-private.h | ||
534 | 16 | +++ b/gdk/mir/gdkmir-private.h | ||
535 | 17 | @@ -111,6 +111,11 @@ void _gdk_mir_display_focus_window (GdkDisplay *display, GdkWindow *window); | ||
536 | 18 | |||
537 | 19 | void _gdk_mir_display_unfocus_window (GdkDisplay *display, GdkWindow *window); | ||
538 | 20 | |||
539 | 21 | +void _gdk_mir_display_create_paste (GdkDisplay *display, | ||
540 | 22 | + const gchar * const *paste_formats, | ||
541 | 23 | + gconstpointer paste_data, | ||
542 | 24 | + gsize paste_size); | ||
543 | 25 | + | ||
544 | 26 | gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display); | ||
545 | 27 | |||
546 | 28 | EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display); | ||
547 | 29 | diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c | ||
548 | 30 | index 718ab60..3dd3798 100644 | ||
549 | 31 | --- a/gdk/mir/gdkmirdisplay.c | ||
550 | 32 | +++ b/gdk/mir/gdkmirdisplay.c | ||
551 | 33 | @@ -504,7 +504,28 @@ gdk_mir_display_set_selection_owner (GdkDisplay *display, | ||
552 | 34 | guint32 time, | ||
553 | 35 | gboolean send_event) | ||
554 | 36 | { | ||
555 | 37 | - //g_printerr ("gdk_mir_display_set_selection_owner\n"); | ||
556 | 38 | + GdkEvent *event; | ||
557 | 39 | + | ||
558 | 40 | + if (selection == GDK_SELECTION_CLIPBOARD) | ||
559 | 41 | + { | ||
560 | 42 | + if (owner) | ||
561 | 43 | + { | ||
562 | 44 | + event = gdk_event_new (GDK_SELECTION_REQUEST); | ||
563 | 45 | + event->selection.window = g_object_ref (owner); | ||
564 | 46 | + event->selection.send_event = FALSE; | ||
565 | 47 | + event->selection.selection = selection; | ||
566 | 48 | + event->selection.target = gdk_atom_intern_static_string ("TARGETS"); | ||
567 | 49 | + event->selection.property = gdk_atom_intern_static_string ("AVAILABLE_TARGETS"); | ||
568 | 50 | + event->selection.time = GDK_CURRENT_TIME; | ||
569 | 51 | + event->selection.requestor = g_object_ref (owner); | ||
570 | 52 | + | ||
571 | 53 | + gdk_event_put (event); | ||
572 | 54 | + gdk_event_free (event); | ||
573 | 55 | + | ||
574 | 56 | + return TRUE; | ||
575 | 57 | + } | ||
576 | 58 | + } | ||
577 | 59 | + | ||
578 | 60 | return FALSE; | ||
579 | 61 | } | ||
580 | 62 | |||
581 | 63 | @@ -645,6 +666,43 @@ _gdk_mir_display_unfocus_window (GdkDisplay *display, | ||
582 | 64 | g_clear_object (&mir_display->focused_window); | ||
583 | 65 | } | ||
584 | 66 | |||
585 | 67 | +void | ||
586 | 68 | +_gdk_mir_display_create_paste (GdkDisplay *display, | ||
587 | 69 | + const gchar * const *paste_formats, | ||
588 | 70 | + gconstpointer paste_data, | ||
589 | 71 | + gsize paste_size) | ||
590 | 72 | +{ | ||
591 | 73 | + GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display); | ||
592 | 74 | + MirSurface *surface; | ||
593 | 75 | + MirPersistentId *persistent_id; | ||
594 | 76 | + | ||
595 | 77 | + if (!mir_display->focused_window) | ||
596 | 78 | + return; | ||
597 | 79 | + | ||
598 | 80 | + surface = gdk_mir_window_get_mir_surface (mir_display->focused_window); | ||
599 | 81 | + | ||
600 | 82 | + if (!surface) | ||
601 | 83 | + return; | ||
602 | 84 | + | ||
603 | 85 | + persistent_id = mir_surface_request_persistent_id_sync (surface); | ||
604 | 86 | + | ||
605 | 87 | + if (!persistent_id) | ||
606 | 88 | + return; | ||
607 | 89 | + | ||
608 | 90 | + if (mir_persistent_id_is_valid (persistent_id)) | ||
609 | 91 | + content_hub_service_call_create_paste_sync ( | ||
610 | 92 | + mir_display->content_service, | ||
611 | 93 | + g_application_get_application_id (g_application_get_default ()), | ||
612 | 94 | + mir_persistent_id_as_string (persistent_id), | ||
613 | 95 | + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, paste_data, paste_size, sizeof (guchar)), | ||
614 | 96 | + paste_formats, | ||
615 | 97 | + NULL, | ||
616 | 98 | + NULL, | ||
617 | 99 | + NULL); | ||
618 | 100 | + | ||
619 | 101 | + mir_persistent_id_release (persistent_id); | ||
620 | 102 | +} | ||
621 | 103 | + | ||
622 | 104 | gboolean | ||
623 | 105 | _gdk_mir_display_init_egl_display (GdkDisplay *display) | ||
624 | 106 | { | ||
625 | 107 | diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c | ||
626 | 108 | index 48e66ca..8a15816 100644 | ||
627 | 109 | --- a/gdk/mir/gdkmirwindowimpl.c | ||
628 | 110 | +++ b/gdk/mir/gdkmirwindowimpl.c | ||
629 | 111 | @@ -1594,6 +1594,140 @@ gdk_mir_window_impl_get_property (GdkWindow *window, | ||
630 | 112 | } | ||
631 | 113 | |||
632 | 114 | static void | ||
633 | 115 | +request_targets (GdkWindow *window, | ||
634 | 116 | + const GdkAtom *available_targets, | ||
635 | 117 | + gint n_available_targets) | ||
636 | 118 | +{ | ||
637 | 119 | + GArray *requested_targets; | ||
638 | 120 | + GdkAtom target_pair[2]; | ||
639 | 121 | + gchar *target_location; | ||
640 | 122 | + GdkEvent *event; | ||
641 | 123 | + gint i; | ||
642 | 124 | + | ||
643 | 125 | + requested_targets = g_array_sized_new (TRUE, FALSE, sizeof (GdkAtom), 2 * n_available_targets); | ||
644 | 126 | + | ||
645 | 127 | + for (i = 0; i < n_available_targets; i++) | ||
646 | 128 | + { | ||
647 | 129 | + target_pair[0] = available_targets[i]; | ||
648 | 130 | + | ||
649 | 131 | + if (target_pair[0] == gdk_atom_intern_static_string ("TIMESTAMP") || | ||
650 | 132 | + target_pair[0] == gdk_atom_intern_static_string ("TARGETS") || | ||
651 | 133 | + target_pair[0] == gdk_atom_intern_static_string ("MULTIPLE") || | ||
652 | 134 | + target_pair[0] == gdk_atom_intern_static_string ("SAVE_TARGETS")) | ||
653 | 135 | + continue; | ||
654 | 136 | + | ||
655 | 137 | + target_location = g_strdup_printf ("REQUESTED_TARGET_U%u", requested_targets->len / 2); | ||
656 | 138 | + target_pair[1] = gdk_atom_intern (target_location, FALSE); | ||
657 | 139 | + g_free (target_location); | ||
658 | 140 | + | ||
659 | 141 | + g_array_append_vals (requested_targets, target_pair, 2); | ||
660 | 142 | + } | ||
661 | 143 | + | ||
662 | 144 | + gdk_property_delete (window, gdk_atom_intern_static_string ("AVAILABLE_TARGETS")); | ||
663 | 145 | + gdk_property_delete (window, gdk_atom_intern_static_string ("REQUESTED_TARGETS")); | ||
664 | 146 | + | ||
665 | 147 | + gdk_property_change (window, | ||
666 | 148 | + gdk_atom_intern_static_string ("REQUESTED_TARGETS"), | ||
667 | 149 | + GDK_SELECTION_TYPE_ATOM, | ||
668 | 150 | + 8 * sizeof (GdkAtom), | ||
669 | 151 | + GDK_PROP_MODE_REPLACE, | ||
670 | 152 | + (const guchar *) requested_targets->data, | ||
671 | 153 | + requested_targets->len); | ||
672 | 154 | + | ||
673 | 155 | + g_array_unref (requested_targets); | ||
674 | 156 | + | ||
675 | 157 | + event = gdk_event_new (GDK_SELECTION_REQUEST); | ||
676 | 158 | + event->selection.window = g_object_ref (window); | ||
677 | 159 | + event->selection.send_event = FALSE; | ||
678 | 160 | + event->selection.selection = GDK_SELECTION_CLIPBOARD; | ||
679 | 161 | + event->selection.target = gdk_atom_intern_static_string ("MULTIPLE"); | ||
680 | 162 | + event->selection.property = gdk_atom_intern_static_string ("REQUESTED_TARGETS"); | ||
681 | 163 | + event->selection.time = GDK_CURRENT_TIME; | ||
682 | 164 | + event->selection.requestor = g_object_ref (window); | ||
683 | 165 | + | ||
684 | 166 | + gdk_event_put (event); | ||
685 | 167 | + gdk_event_free (event); | ||
686 | 168 | +} | ||
687 | 169 | + | ||
688 | 170 | +static void | ||
689 | 171 | +create_paste (GdkWindow *window, | ||
690 | 172 | + const GdkAtom *requested_targets, | ||
691 | 173 | + gint n_requested_targets) | ||
692 | 174 | +{ | ||
693 | 175 | + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
694 | 176 | + GPtrArray *paste_formats; | ||
695 | 177 | + GArray *paste_header; | ||
696 | 178 | + GByteArray *paste_data; | ||
697 | 179 | + gint sizes[4]; | ||
698 | 180 | + GdkMirProperty *mir_property; | ||
699 | 181 | + const gchar *paste_format; | ||
700 | 182 | + gint i; | ||
701 | 183 | + | ||
702 | 184 | + paste_formats = g_ptr_array_new_full (n_requested_targets, g_free); | ||
703 | 185 | + paste_header = g_array_sized_new (FALSE, FALSE, sizeof (gint), 1 + 4 * n_requested_targets); | ||
704 | 186 | + paste_data = g_byte_array_new (); | ||
705 | 187 | + | ||
706 | 188 | + g_array_append_val (paste_header, sizes[0]); | ||
707 | 189 | + | ||
708 | 190 | + for (i = 0; i < n_requested_targets; i++) | ||
709 | 191 | + { | ||
710 | 192 | + if (requested_targets[i] == GDK_NONE) | ||
711 | 193 | + continue; | ||
712 | 194 | + | ||
713 | 195 | + mir_property = g_hash_table_lookup (impl->properties, requested_targets[i]); | ||
714 | 196 | + | ||
715 | 197 | + if (!mir_property) | ||
716 | 198 | + continue; | ||
717 | 199 | + | ||
718 | 200 | + paste_format = _gdk_atom_name_const (mir_property->type); | ||
719 | 201 | + | ||
720 | 202 | + /* skip non-MIME targets */ | ||
721 | 203 | + if (!strchr (paste_format, '/')) | ||
722 | 204 | + { | ||
723 | 205 | + g_hash_table_remove (impl->properties, requested_targets[i]); | ||
724 | 206 | + continue; | ||
725 | 207 | + } | ||
726 | 208 | + | ||
727 | 209 | + sizes[0] = paste_data->len; | ||
728 | 210 | + sizes[1] = strlen (paste_format); | ||
729 | 211 | + sizes[2] = sizes[0] + sizes[1]; | ||
730 | 212 | + sizes[3] = mir_property->array->len * g_array_get_element_size (mir_property->array); | ||
731 | 213 | + | ||
732 | 214 | + g_ptr_array_add (paste_formats, g_strdup (paste_format)); | ||
733 | 215 | + g_array_append_vals (paste_header, sizes, 4); | ||
734 | 216 | + g_byte_array_append (paste_data, (const guint8 *) paste_format, sizes[1]); | ||
735 | 217 | + g_byte_array_append (paste_data, (const guint8 *) mir_property->array->data, sizes[3]); | ||
736 | 218 | + | ||
737 | 219 | + g_hash_table_remove (impl->properties, requested_targets[i]); | ||
738 | 220 | + } | ||
739 | 221 | + | ||
740 | 222 | + gdk_property_delete (window, gdk_atom_intern_static_string ("REQUESTED_TARGETS")); | ||
741 | 223 | + | ||
742 | 224 | + g_array_index (paste_header, gint, 0) = paste_formats->len; | ||
743 | 225 | + | ||
744 | 226 | + for (i = 0; i < paste_formats->len; i++) | ||
745 | 227 | + { | ||
746 | 228 | + g_array_index (paste_header, gint, 1 + 4 * i) += paste_header->len * sizeof (gint); | ||
747 | 229 | + g_array_index (paste_header, gint, 3 + 4 * i) += paste_header->len * sizeof (gint); | ||
748 | 230 | + } | ||
749 | 231 | + | ||
750 | 232 | + g_byte_array_prepend (paste_data, | ||
751 | 233 | + (const guint8 *) paste_header->data, | ||
752 | 234 | + paste_header->len * g_array_get_element_size (paste_header)); | ||
753 | 235 | + | ||
754 | 236 | + g_ptr_array_add (paste_formats, NULL); | ||
755 | 237 | + | ||
756 | 238 | + _gdk_mir_display_create_paste (gdk_window_get_display (window), | ||
757 | 239 | + (const gchar * const *) paste_formats->pdata, | ||
758 | 240 | + paste_data->data, | ||
759 | 241 | + paste_data->len); | ||
760 | 242 | + | ||
761 | 243 | + g_byte_array_unref (paste_data); | ||
762 | 244 | + g_array_unref (paste_header); | ||
763 | 245 | + g_ptr_array_unref (paste_formats); | ||
764 | 246 | +} | ||
765 | 247 | + | ||
766 | 248 | +static void | ||
767 | 249 | gdk_mir_window_impl_change_property (GdkWindow *window, | ||
768 | 250 | GdkAtom property, | ||
769 | 251 | GdkAtom type, | ||
770 | 252 | @@ -1604,6 +1738,7 @@ gdk_mir_window_impl_change_property (GdkWindow *window, | ||
771 | 253 | { | ||
772 | 254 | GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
773 | 255 | GdkMirProperty *mir_property; | ||
774 | 256 | + gboolean existed; | ||
775 | 257 | GdkEvent *event; | ||
776 | 258 | |||
777 | 259 | /* ICCCM 2.7: ATOMs and ATOM_PAIRs have format 32, but GdkAtoms can be 64-bit */ | ||
778 | 260 | @@ -1611,9 +1746,15 @@ gdk_mir_window_impl_change_property (GdkWindow *window, | ||
779 | 261 | format = 8 * sizeof (GdkAtom); | ||
780 | 262 | |||
781 | 263 | if (mode != GDK_PROP_MODE_REPLACE) | ||
782 | 264 | - mir_property = g_hash_table_lookup (impl->properties, property); | ||
783 | 265 | + { | ||
784 | 266 | + mir_property = g_hash_table_lookup (impl->properties, property); | ||
785 | 267 | + existed = mir_property != NULL; | ||
786 | 268 | + } | ||
787 | 269 | else | ||
788 | 270 | - mir_property = NULL; | ||
789 | 271 | + { | ||
790 | 272 | + mir_property = NULL; | ||
791 | 273 | + existed = g_hash_table_contains (impl->properties, property); | ||
792 | 274 | + } | ||
793 | 275 | |||
794 | 276 | if (!mir_property) | ||
795 | 277 | { | ||
796 | 278 | @@ -1640,6 +1781,11 @@ gdk_mir_window_impl_change_property (GdkWindow *window, | ||
797 | 279 | |||
798 | 280 | gdk_event_put (event); | ||
799 | 281 | gdk_event_free (event); | ||
800 | 282 | + | ||
801 | 283 | + if (property == gdk_atom_intern_static_string ("AVAILABLE_TARGETS")) | ||
802 | 284 | + request_targets (window, (const GdkAtom *) data, n_elements); | ||
803 | 285 | + else if (property == gdk_atom_intern_static_string ("REQUESTED_TARGETS") && existed) | ||
804 | 286 | + create_paste (window, (const GdkAtom *) data, n_elements); | ||
805 | 287 | } | ||
806 | 288 | |||
807 | 289 | static void | ||
808 | 290 | -- | ||
809 | 291 | 2.10.2 | ||
810 | 292 | |||
811 | 0 | 293 | ||
812 | === added file 'debian/patches/0005-mir-paste-clipboard-data-from-content-hub.patch' | |||
813 | --- debian/patches/0005-mir-paste-clipboard-data-from-content-hub.patch 1970-01-01 00:00:00 +0000 | |||
814 | +++ debian/patches/0005-mir-paste-clipboard-data-from-content-hub.patch 2017-02-08 17:37:49 +0000 | |||
815 | @@ -0,0 +1,415 @@ | |||
816 | 1 | From 41732391d8b93478d4b63d63f9c3cc5bbf124a2a Mon Sep 17 00:00:00 2001 | ||
817 | 2 | From: William Hua <william.hua@canonical.com> | ||
818 | 3 | Date: Sat, 15 Oct 2016 22:19:59 +0200 | ||
819 | 4 | Subject: [PATCH 05/38] mir: paste clipboard data from content-hub | ||
820 | 5 | |||
821 | 6 | https://bugzilla.gnome.org/show_bug.cgi?id=775732 | ||
822 | 7 | --- | ||
823 | 8 | gdk/mir/gdkmirdisplay.c | 339 +++++++++++++++++++++++++++++++++++++++++++++++- | ||
824 | 9 | 1 file changed, 335 insertions(+), 4 deletions(-) | ||
825 | 10 | |||
826 | 11 | diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c | ||
827 | 12 | index 3dd3798..21967ac 100644 | ||
828 | 13 | --- a/gdk/mir/gdkmirdisplay.c | ||
829 | 14 | +++ b/gdk/mir/gdkmirdisplay.c | ||
830 | 15 | @@ -23,6 +23,8 @@ | ||
831 | 16 | #include "gdkmir.h" | ||
832 | 17 | #include "gdkmir-private.h" | ||
833 | 18 | |||
834 | 19 | +#include <string.h> | ||
835 | 20 | + | ||
836 | 21 | #include <com/ubuntu/content/glib/content-hub-glib.h> | ||
837 | 22 | |||
838 | 23 | #define GDK_TYPE_DISPLAY_MIR (gdk_mir_display_get_type ()) | ||
839 | 24 | @@ -62,6 +64,7 @@ typedef struct GdkMirDisplay | ||
840 | 25 | |||
841 | 26 | ContentHubService *content_service; | ||
842 | 27 | ContentHubHandler *content_handler; | ||
843 | 28 | + GVariant *paste_data; | ||
844 | 29 | } GdkMirDisplay; | ||
845 | 30 | |||
846 | 31 | typedef struct GdkMirDisplayClass | ||
847 | 32 | @@ -107,6 +110,13 @@ static void get_pixel_formats (MirConnection *, MirPixelFormat *sw, MirPixelForm | ||
848 | 33 | |||
849 | 34 | G_DEFINE_TYPE (GdkMirDisplay, gdk_mir_display, GDK_TYPE_DISPLAY) | ||
850 | 35 | |||
851 | 36 | +static void | ||
852 | 37 | +pasteboard_changed_cb (GdkMirDisplay *display, | ||
853 | 38 | + gpointer user_data) | ||
854 | 39 | +{ | ||
855 | 40 | + g_clear_pointer (&display->paste_data, g_variant_unref); | ||
856 | 41 | +} | ||
857 | 42 | + | ||
858 | 43 | GdkDisplay * | ||
859 | 44 | _gdk_mir_display_open (const gchar *display_name) | ||
860 | 45 | { | ||
861 | 46 | @@ -156,6 +166,12 @@ _gdk_mir_display_open (const gchar *display_name) | ||
862 | 47 | NULL, | ||
863 | 48 | NULL); | ||
864 | 49 | |||
865 | 50 | + g_signal_connect_swapped ( | ||
866 | 51 | + display->content_service, | ||
867 | 52 | + "pasteboard-changed", | ||
868 | 53 | + G_CALLBACK (pasteboard_changed_cb), | ||
869 | 54 | + display); | ||
870 | 55 | + | ||
871 | 56 | display->content_handler = content_hub_handler_skeleton_new (); | ||
872 | 57 | |||
873 | 58 | g_dbus_interface_skeleton_export ( | ||
874 | 59 | @@ -214,6 +230,7 @@ gdk_mir_display_dispose (GObject *object) | ||
875 | 60 | { | ||
876 | 61 | GdkMirDisplay *display = GDK_MIR_DISPLAY (object); | ||
877 | 62 | |||
878 | 63 | + g_clear_pointer (&display->paste_data, g_variant_unref); | ||
879 | 64 | g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (display->content_handler)); | ||
880 | 65 | g_clear_object (&display->content_handler); | ||
881 | 66 | g_clear_object (&display->content_service); | ||
882 | 67 | @@ -547,10 +564,255 @@ gdk_mir_display_get_selection_property (GdkDisplay *display, | ||
883 | 68 | GdkAtom *ret_type, | ||
884 | 69 | gint *ret_format) | ||
885 | 70 | { | ||
886 | 71 | - //g_printerr ("gdk_mir_display_get_selection_property\n"); | ||
887 | 72 | + gint length; | ||
888 | 73 | + | ||
889 | 74 | + gdk_property_get (requestor, | ||
890 | 75 | + gdk_atom_intern_static_string ("GDK_SELECTION"), | ||
891 | 76 | + GDK_NONE, | ||
892 | 77 | + 0, | ||
893 | 78 | + G_MAXULONG, | ||
894 | 79 | + FALSE, | ||
895 | 80 | + ret_type, | ||
896 | 81 | + ret_format, | ||
897 | 82 | + &length, | ||
898 | 83 | + data); | ||
899 | 84 | + | ||
900 | 85 | + return length; | ||
901 | 86 | +} | ||
902 | 87 | + | ||
903 | 88 | +static gint | ||
904 | 89 | +get_format_score (const gchar *format, | ||
905 | 90 | + GdkAtom target, | ||
906 | 91 | + GdkAtom *out_type, | ||
907 | 92 | + gint *out_size) | ||
908 | 93 | +{ | ||
909 | 94 | + const gchar *target_string; | ||
910 | 95 | + GdkAtom dummy_type; | ||
911 | 96 | + gint dummy_size; | ||
912 | 97 | + | ||
913 | 98 | + target_string = _gdk_atom_name_const (target); | ||
914 | 99 | + | ||
915 | 100 | + if (!out_type) | ||
916 | 101 | + out_type = &dummy_type; | ||
917 | 102 | + | ||
918 | 103 | + if (!out_size) | ||
919 | 104 | + out_size = &dummy_size; | ||
920 | 105 | + | ||
921 | 106 | + if (!g_ascii_strcasecmp (format, target_string)) | ||
922 | 107 | + { | ||
923 | 108 | + *out_type = GDK_SELECTION_TYPE_STRING; | ||
924 | 109 | + *out_size = sizeof (guchar); | ||
925 | 110 | + | ||
926 | 111 | + return G_MAXINT; | ||
927 | 112 | + } | ||
928 | 113 | + | ||
929 | 114 | + if (target == gdk_atom_intern_static_string ("UTF8_STRING")) | ||
930 | 115 | + return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size); | ||
931 | 116 | + | ||
932 | 117 | + /* TODO: use best media type for COMPOUND_TEXT target */ | ||
933 | 118 | + if (target == gdk_atom_intern_static_string ("COMPOUND_TEXT")) | ||
934 | 119 | + return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size); | ||
935 | 120 | + | ||
936 | 121 | + if (target == GDK_TARGET_STRING) | ||
937 | 122 | + return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=iso-8859-1"), out_type, out_size); | ||
938 | 123 | + | ||
939 | 124 | + if (target == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS")) | ||
940 | 125 | + return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size); | ||
941 | 126 | + | ||
942 | 127 | + if (g_content_type_is_a (format, target_string)) | ||
943 | 128 | + { | ||
944 | 129 | + *out_type = GDK_SELECTION_TYPE_STRING; | ||
945 | 130 | + *out_size = sizeof (guchar); | ||
946 | 131 | + | ||
947 | 132 | + return 2; | ||
948 | 133 | + } | ||
949 | 134 | + | ||
950 | 135 | + if (g_content_type_is_a (target_string, format)) | ||
951 | 136 | + { | ||
952 | 137 | + *out_type = GDK_SELECTION_TYPE_STRING; | ||
953 | 138 | + *out_size = sizeof (guchar); | ||
954 | 139 | + | ||
955 | 140 | + return 1; | ||
956 | 141 | + } | ||
957 | 142 | + | ||
958 | 143 | return 0; | ||
959 | 144 | } | ||
960 | 145 | |||
961 | 146 | +static gint | ||
962 | 147 | +get_best_format_index (const gchar * const *formats, | ||
963 | 148 | + guint n_formats, | ||
964 | 149 | + GdkAtom target, | ||
965 | 150 | + GdkAtom *out_type, | ||
966 | 151 | + gint *out_size) | ||
967 | 152 | +{ | ||
968 | 153 | + gint best_i = -1; | ||
969 | 154 | + gint best_score = 0; | ||
970 | 155 | + GdkAtom best_type; | ||
971 | 156 | + gint best_size; | ||
972 | 157 | + gint score; | ||
973 | 158 | + GdkAtom type; | ||
974 | 159 | + gint size; | ||
975 | 160 | + gint i; | ||
976 | 161 | + | ||
977 | 162 | + if (!out_type) | ||
978 | 163 | + out_type = &best_type; | ||
979 | 164 | + | ||
980 | 165 | + if (!out_size) | ||
981 | 166 | + out_size = &best_size; | ||
982 | 167 | + | ||
983 | 168 | + *out_type = GDK_NONE; | ||
984 | 169 | + *out_size = 0; | ||
985 | 170 | + | ||
986 | 171 | + for (i = 0; i < n_formats; i++) | ||
987 | 172 | + { | ||
988 | 173 | + score = get_format_score (formats[i], target, &type, &size); | ||
989 | 174 | + | ||
990 | 175 | + if (score > best_score) | ||
991 | 176 | + { | ||
992 | 177 | + best_i = i; | ||
993 | 178 | + best_score = score; | ||
994 | 179 | + *out_type = type; | ||
995 | 180 | + *out_size = size; | ||
996 | 181 | + } | ||
997 | 182 | + } | ||
998 | 183 | + | ||
999 | 184 | + return best_i; | ||
1000 | 185 | +} | ||
1001 | 186 | + | ||
1002 | 187 | +static void | ||
1003 | 188 | +gdk_mir_display_real_convert_selection (GdkDisplay *display, | ||
1004 | 189 | + GdkWindow *requestor, | ||
1005 | 190 | + GdkAtom selection, | ||
1006 | 191 | + GdkAtom target, | ||
1007 | 192 | + guint32 time) | ||
1008 | 193 | +{ | ||
1009 | 194 | + GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display); | ||
1010 | 195 | + const gchar *paste_data; | ||
1011 | 196 | + gsize paste_size; | ||
1012 | 197 | + const gint *paste_header; | ||
1013 | 198 | + GPtrArray *paste_formats; | ||
1014 | 199 | + GArray *paste_targets; | ||
1015 | 200 | + GdkAtom paste_target; | ||
1016 | 201 | + GdkEvent *event; | ||
1017 | 202 | + gint best_i; | ||
1018 | 203 | + GdkAtom best_type; | ||
1019 | 204 | + gint best_size; | ||
1020 | 205 | + gint i; | ||
1021 | 206 | + | ||
1022 | 207 | + g_return_if_fail (mir_display->paste_data); | ||
1023 | 208 | + | ||
1024 | 209 | + paste_data = g_variant_get_fixed_array (mir_display->paste_data, &paste_size, sizeof (guchar)); | ||
1025 | 210 | + paste_header = (const gint *) paste_data; | ||
1026 | 211 | + paste_formats = g_ptr_array_new_full (paste_header[0], g_free); | ||
1027 | 212 | + | ||
1028 | 213 | + for (i = 0; i < paste_header[0]; i++) | ||
1029 | 214 | + g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 * i])); | ||
1030 | 215 | + | ||
1031 | 216 | + if (target == gdk_atom_intern_static_string ("TARGETS")) | ||
1032 | 217 | + { | ||
1033 | 218 | + paste_targets = g_array_sized_new (TRUE, FALSE, sizeof (GdkAtom), paste_formats->len); | ||
1034 | 219 | + | ||
1035 | 220 | + for (i = 0; i < paste_formats->len; i++) | ||
1036 | 221 | + { | ||
1037 | 222 | + paste_target = gdk_atom_intern (g_ptr_array_index (paste_formats, i), FALSE); | ||
1038 | 223 | + g_array_append_val (paste_targets, paste_target); | ||
1039 | 224 | + } | ||
1040 | 225 | + | ||
1041 | 226 | + gdk_property_change (requestor, | ||
1042 | 227 | + gdk_atom_intern_static_string ("GDK_SELECTION"), | ||
1043 | 228 | + GDK_SELECTION_TYPE_ATOM, | ||
1044 | 229 | + 8 * sizeof (GdkAtom), | ||
1045 | 230 | + GDK_PROP_MODE_REPLACE, | ||
1046 | 231 | + (const guchar *) paste_targets->data, | ||
1047 | 232 | + paste_targets->len); | ||
1048 | 233 | + | ||
1049 | 234 | + g_array_unref (paste_targets); | ||
1050 | 235 | + | ||
1051 | 236 | + event = gdk_event_new (GDK_SELECTION_NOTIFY); | ||
1052 | 237 | + event->selection.window = g_object_ref (requestor); | ||
1053 | 238 | + event->selection.send_event = FALSE; | ||
1054 | 239 | + event->selection.selection = selection; | ||
1055 | 240 | + event->selection.target = target; | ||
1056 | 241 | + event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION"); | ||
1057 | 242 | + event->selection.time = time; | ||
1058 | 243 | + event->selection.requestor = g_object_ref (requestor); | ||
1059 | 244 | + | ||
1060 | 245 | + gdk_event_put (event); | ||
1061 | 246 | + gdk_event_free (event); | ||
1062 | 247 | + } | ||
1063 | 248 | + else | ||
1064 | 249 | + { | ||
1065 | 250 | + best_i = get_best_format_index ((const gchar * const *) paste_formats->pdata, | ||
1066 | 251 | + paste_formats->len, | ||
1067 | 252 | + target, | ||
1068 | 253 | + &best_type, | ||
1069 | 254 | + &best_size); | ||
1070 | 255 | + | ||
1071 | 256 | + if (best_i >= 0) | ||
1072 | 257 | + { | ||
1073 | 258 | + gdk_property_change (requestor, | ||
1074 | 259 | + gdk_atom_intern_static_string ("GDK_SELECTION"), | ||
1075 | 260 | + best_type, | ||
1076 | 261 | + 8 * best_size, | ||
1077 | 262 | + GDK_PROP_MODE_REPLACE, | ||
1078 | 263 | + (const guchar *) paste_data + paste_header[3 + 4 * best_i], | ||
1079 | 264 | + paste_header[4 + 4 * best_i] / best_size); | ||
1080 | 265 | + | ||
1081 | 266 | + event = gdk_event_new (GDK_SELECTION_NOTIFY); | ||
1082 | 267 | + event->selection.window = g_object_ref (requestor); | ||
1083 | 268 | + event->selection.send_event = FALSE; | ||
1084 | 269 | + event->selection.selection = selection; | ||
1085 | 270 | + event->selection.target = target; | ||
1086 | 271 | + event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION"); | ||
1087 | 272 | + event->selection.time = time; | ||
1088 | 273 | + event->selection.requestor = g_object_ref (requestor); | ||
1089 | 274 | + | ||
1090 | 275 | + gdk_event_put (event); | ||
1091 | 276 | + gdk_event_free (event); | ||
1092 | 277 | + } | ||
1093 | 278 | + } | ||
1094 | 279 | + | ||
1095 | 280 | + g_ptr_array_unref (paste_formats); | ||
1096 | 281 | +} | ||
1097 | 282 | + | ||
1098 | 283 | +typedef struct | ||
1099 | 284 | +{ | ||
1100 | 285 | + GdkDisplay *display; | ||
1101 | 286 | + GdkWindow *requestor; | ||
1102 | 287 | + GdkAtom selection; | ||
1103 | 288 | + GdkAtom target; | ||
1104 | 289 | + guint32 time; | ||
1105 | 290 | +} ConvertInfo; | ||
1106 | 291 | + | ||
1107 | 292 | +static void | ||
1108 | 293 | +paste_data_ready_cb (GObject *source_object, | ||
1109 | 294 | + GAsyncResult *res, | ||
1110 | 295 | + gpointer user_data) | ||
1111 | 296 | +{ | ||
1112 | 297 | + ContentHubService *content_service = CONTENT_HUB_SERVICE (source_object); | ||
1113 | 298 | + ConvertInfo *info = user_data; | ||
1114 | 299 | + GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (info->display); | ||
1115 | 300 | + gboolean result; | ||
1116 | 301 | + | ||
1117 | 302 | + g_clear_pointer (&mir_display->paste_data, g_variant_unref); | ||
1118 | 303 | + | ||
1119 | 304 | + result = content_hub_service_call_get_latest_paste_data_finish (content_service, | ||
1120 | 305 | + &mir_display->paste_data, | ||
1121 | 306 | + res, | ||
1122 | 307 | + NULL); | ||
1123 | 308 | + | ||
1124 | 309 | + if (result) | ||
1125 | 310 | + gdk_mir_display_real_convert_selection (info->display, | ||
1126 | 311 | + info->requestor, | ||
1127 | 312 | + info->selection, | ||
1128 | 313 | + info->target, | ||
1129 | 314 | + info->time); | ||
1130 | 315 | + | ||
1131 | 316 | + g_object_unref (info->requestor); | ||
1132 | 317 | + g_object_unref (info->display); | ||
1133 | 318 | + g_free (info); | ||
1134 | 319 | +} | ||
1135 | 320 | + | ||
1136 | 321 | static void | ||
1137 | 322 | gdk_mir_display_convert_selection (GdkDisplay *display, | ||
1138 | 323 | GdkWindow *requestor, | ||
1139 | 324 | @@ -558,7 +820,46 @@ gdk_mir_display_convert_selection (GdkDisplay *display, | ||
1140 | 325 | GdkAtom target, | ||
1141 | 326 | guint32 time) | ||
1142 | 327 | { | ||
1143 | 328 | - //g_printerr ("gdk_mir_display_convert_selection\n"); | ||
1144 | 329 | + GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display); | ||
1145 | 330 | + MirSurface *surface; | ||
1146 | 331 | + MirPersistentId *persistent_id; | ||
1147 | 332 | + ConvertInfo *info; | ||
1148 | 333 | + | ||
1149 | 334 | + if (selection != GDK_SELECTION_CLIPBOARD) | ||
1150 | 335 | + return; | ||
1151 | 336 | + else if (mir_display->paste_data) | ||
1152 | 337 | + gdk_mir_display_real_convert_selection (display, requestor, selection, target, time); | ||
1153 | 338 | + else if (mir_display->focused_window) | ||
1154 | 339 | + { | ||
1155 | 340 | + surface = gdk_mir_window_get_mir_surface (mir_display->focused_window); | ||
1156 | 341 | + | ||
1157 | 342 | + if (!surface) | ||
1158 | 343 | + return; | ||
1159 | 344 | + | ||
1160 | 345 | + persistent_id = mir_surface_request_persistent_id_sync (surface); | ||
1161 | 346 | + | ||
1162 | 347 | + if (!persistent_id) | ||
1163 | 348 | + return; | ||
1164 | 349 | + | ||
1165 | 350 | + if (mir_persistent_id_is_valid (persistent_id)) | ||
1166 | 351 | + { | ||
1167 | 352 | + info = g_new (ConvertInfo, 1); | ||
1168 | 353 | + info->display = g_object_ref (display); | ||
1169 | 354 | + info->requestor = g_object_ref (requestor); | ||
1170 | 355 | + info->selection = selection; | ||
1171 | 356 | + info->target = target; | ||
1172 | 357 | + info->time = time; | ||
1173 | 358 | + | ||
1174 | 359 | + content_hub_service_call_get_latest_paste_data ( | ||
1175 | 360 | + mir_display->content_service, | ||
1176 | 361 | + mir_persistent_id_as_string (persistent_id), | ||
1177 | 362 | + NULL, | ||
1178 | 363 | + paste_data_ready_cb, | ||
1179 | 364 | + info); | ||
1180 | 365 | + } | ||
1181 | 366 | + | ||
1182 | 367 | + mir_persistent_id_release (persistent_id); | ||
1183 | 368 | + } | ||
1184 | 369 | } | ||
1185 | 370 | |||
1186 | 371 | static gint | ||
1187 | 372 | @@ -569,8 +870,38 @@ gdk_mir_display_text_property_to_utf8_list (GdkDisplay *display, | ||
1188 | 373 | gint length, | ||
1189 | 374 | gchar ***list) | ||
1190 | 375 | { | ||
1191 | 376 | - //g_printerr ("gdk_mir_display_text_property_to_utf8_list\n"); | ||
1192 | 377 | - return 0; | ||
1193 | 378 | + GPtrArray *array; | ||
1194 | 379 | + const gchar *ptr; | ||
1195 | 380 | + gsize chunk_len; | ||
1196 | 381 | + gchar *copy; | ||
1197 | 382 | + guint nitems; | ||
1198 | 383 | + | ||
1199 | 384 | + ptr = (const gchar *) text; | ||
1200 | 385 | + array = g_ptr_array_new (); | ||
1201 | 386 | + | ||
1202 | 387 | + /* split text into utf-8 strings */ | ||
1203 | 388 | + while (ptr < (const gchar *) &text[length]) | ||
1204 | 389 | + { | ||
1205 | 390 | + chunk_len = strlen (ptr); | ||
1206 | 391 | + | ||
1207 | 392 | + if (g_utf8_validate (ptr, chunk_len, NULL)) | ||
1208 | 393 | + { | ||
1209 | 394 | + copy = g_strndup (ptr, chunk_len); | ||
1210 | 395 | + g_ptr_array_add (array, copy); | ||
1211 | 396 | + } | ||
1212 | 397 | + | ||
1213 | 398 | + ptr = &ptr[chunk_len + 1]; | ||
1214 | 399 | + } | ||
1215 | 400 | + | ||
1216 | 401 | + nitems = array->len; | ||
1217 | 402 | + g_ptr_array_add (array, NULL); | ||
1218 | 403 | + | ||
1219 | 404 | + if (list) | ||
1220 | 405 | + *list = (gchar **) g_ptr_array_free (array, FALSE); | ||
1221 | 406 | + else | ||
1222 | 407 | + g_ptr_array_free (array, TRUE); | ||
1223 | 408 | + | ||
1224 | 409 | + return nitems; | ||
1225 | 410 | } | ||
1226 | 411 | |||
1227 | 412 | static gchar * | ||
1228 | 413 | -- | ||
1229 | 414 | 2.10.2 | ||
1230 | 415 | |||
1231 | 0 | 416 | ||
1232 | === added file 'debian/patches/0006-mir-properly-handle-empty-clipboard.patch' | |||
1233 | --- debian/patches/0006-mir-properly-handle-empty-clipboard.patch 1970-01-01 00:00:00 +0000 | |||
1234 | +++ debian/patches/0006-mir-properly-handle-empty-clipboard.patch 2017-02-08 17:37:49 +0000 | |||
1235 | @@ -0,0 +1,37 @@ | |||
1236 | 1 | From 248ef2d6a0f97cbb71d10c0bb37a3183f13ea19f Mon Sep 17 00:00:00 2001 | ||
1237 | 2 | From: William Hua <william.hua@canonical.com> | ||
1238 | 3 | Date: Mon, 9 Jan 2017 12:04:48 -0500 | ||
1239 | 4 | Subject: [PATCH 06/38] mir: properly handle empty clipboard | ||
1240 | 5 | |||
1241 | 6 | https://bugzilla.gnome.org/show_bug.cgi?id=775732 | ||
1242 | 7 | --- | ||
1243 | 8 | gdk/mir/gdkmirdisplay.c | 12 +++++++++--- | ||
1244 | 9 | 1 file changed, 9 insertions(+), 3 deletions(-) | ||
1245 | 10 | |||
1246 | 11 | diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c | ||
1247 | 12 | index 21967ac..62f36ee 100644 | ||
1248 | 13 | --- a/gdk/mir/gdkmirdisplay.c | ||
1249 | 14 | +++ b/gdk/mir/gdkmirdisplay.c | ||
1250 | 15 | @@ -703,10 +703,16 @@ gdk_mir_display_real_convert_selection (GdkDisplay *display, | ||
1251 | 16 | |||
1252 | 17 | paste_data = g_variant_get_fixed_array (mir_display->paste_data, &paste_size, sizeof (guchar)); | ||
1253 | 18 | paste_header = (const gint *) paste_data; | ||
1254 | 19 | - paste_formats = g_ptr_array_new_full (paste_header[0], g_free); | ||
1255 | 20 | |||
1256 | 21 | - for (i = 0; i < paste_header[0]; i++) | ||
1257 | 22 | - g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 * i])); | ||
1258 | 23 | + if (paste_data) | ||
1259 | 24 | + { | ||
1260 | 25 | + paste_formats = g_ptr_array_new_full (paste_header[0], g_free); | ||
1261 | 26 | + | ||
1262 | 27 | + for (i = 0; i < paste_header[0]; i++) | ||
1263 | 28 | + g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 * i])); | ||
1264 | 29 | + } | ||
1265 | 30 | + else | ||
1266 | 31 | + paste_formats = g_ptr_array_new_with_free_func (g_free); | ||
1267 | 32 | |||
1268 | 33 | if (target == gdk_atom_intern_static_string ("TARGETS")) | ||
1269 | 34 | { | ||
1270 | 35 | -- | ||
1271 | 36 | 2.10.2 | ||
1272 | 37 | |||
1273 | 0 | 38 | ||
1274 | === added file 'debian/patches/0031-mir-fix-compile-time-warnings.patch' | |||
1275 | --- debian/patches/0031-mir-fix-compile-time-warnings.patch 1970-01-01 00:00:00 +0000 | |||
1276 | +++ debian/patches/0031-mir-fix-compile-time-warnings.patch 2017-02-08 17:37:49 +0000 | |||
1277 | @@ -0,0 +1,77 @@ | |||
1278 | 1 | From a95feb498409b42d7b7dd08b2c89c98b70b0a9fe Mon Sep 17 00:00:00 2001 | ||
1279 | 2 | From: William Hua <william.hua@canonical.com> | ||
1280 | 3 | Date: Mon, 9 Jan 2017 17:54:37 -0500 | ||
1281 | 4 | Subject: [PATCH 31/38] mir: fix compile-time warnings | ||
1282 | 5 | |||
1283 | 6 | --- | ||
1284 | 7 | gdk/mir/gdkmir-debug.c | 10 ++++++++++ | ||
1285 | 8 | gdk/mir/gdkmireventsource.c | 2 ++ | ||
1286 | 9 | gdk/mir/gdkmirscreen.c | 4 ++++ | ||
1287 | 10 | 3 files changed, 16 insertions(+) | ||
1288 | 11 | |||
1289 | 12 | diff --git a/gdk/mir/gdkmir-debug.c b/gdk/mir/gdkmir-debug.c | ||
1290 | 13 | index 7dd54d5..b0ff929 100644 | ||
1291 | 14 | --- a/gdk/mir/gdkmir-debug.c | ||
1292 | 15 | +++ b/gdk/mir/gdkmir-debug.c | ||
1293 | 16 | @@ -127,6 +127,7 @@ _gdk_mir_print_touch_event (const MirInputEvent *event) | ||
1294 | 17 | } | ||
1295 | 18 | switch (mir_touch_event_tooltype (touch_event, i)) | ||
1296 | 19 | { | ||
1297 | 20 | + default: | ||
1298 | 21 | case mir_touch_tooltype_unknown: | ||
1299 | 22 | g_printerr (" ? "); | ||
1300 | 23 | break; | ||
1301 | 24 | @@ -200,6 +201,12 @@ _gdk_mir_print_motion_event (const MirInputEvent *event) | ||
1302 | 25 | } | ||
1303 | 26 | |||
1304 | 27 | static void | ||
1305 | 28 | +_gdk_mir_print_input_event (const MirInputEvent *event) | ||
1306 | 29 | +{ | ||
1307 | 30 | + g_printerr ("INPUT\n"); | ||
1308 | 31 | +} | ||
1309 | 32 | + | ||
1310 | 33 | +static void | ||
1311 | 34 | _gdk_mir_print_surface_event (const MirSurfaceEvent *event) | ||
1312 | 35 | { | ||
1313 | 36 | g_printerr ("SURFACE\n"); | ||
1314 | 37 | @@ -260,6 +267,9 @@ _gdk_mir_print_event (const MirEvent *event) | ||
1315 | 38 | case mir_input_event_type_pointer: | ||
1316 | 39 | _gdk_mir_print_motion_event (mir_event_get_input_event (event)); | ||
1317 | 40 | break; | ||
1318 | 41 | + default: | ||
1319 | 42 | + _gdk_mir_print_input_event (mir_event_get_input_event (event)); | ||
1320 | 43 | + break; | ||
1321 | 44 | } | ||
1322 | 45 | break; | ||
1323 | 46 | case mir_event_type_key: | ||
1324 | 47 | diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c | ||
1325 | 48 | index a2a1a12..d3c85b9 100644 | ||
1326 | 49 | --- a/gdk/mir/gdkmireventsource.c | ||
1327 | 50 | +++ b/gdk/mir/gdkmireventsource.c | ||
1328 | 51 | @@ -571,6 +571,8 @@ gdk_mir_event_source_queue_event (GdkDisplay *display, | ||
1329 | 52 | case mir_input_event_type_pointer: | ||
1330 | 53 | handle_motion_event (window, input_event); | ||
1331 | 54 | break; | ||
1332 | 55 | + default: | ||
1333 | 56 | + break; | ||
1334 | 57 | } | ||
1335 | 58 | |||
1336 | 59 | break; | ||
1337 | 60 | diff --git a/gdk/mir/gdkmirscreen.c b/gdk/mir/gdkmirscreen.c | ||
1338 | 61 | index b369b03..979f2ba 100644 | ||
1339 | 62 | --- a/gdk/mir/gdkmirscreen.c | ||
1340 | 63 | +++ b/gdk/mir/gdkmirscreen.c | ||
1341 | 64 | @@ -354,6 +354,10 @@ gdk_mir_screen_get_monitor_plug_name (GdkScreen *screen, | ||
1342 | 65 | return g_strdup_printf ("eDP-%u", output->output_id); | ||
1343 | 66 | case mir_display_output_type_virtual: | ||
1344 | 67 | return g_strdup_printf ("Virtual-%u", output->output_id); | ||
1345 | 68 | + case mir_display_output_type_dsi: | ||
1346 | 69 | + return g_strdup_printf ("DSI-%u", output->output_id); | ||
1347 | 70 | + case mir_display_output_type_dpi: | ||
1348 | 71 | + return g_strdup_printf ("DPI-%u", output->output_id); | ||
1349 | 72 | } | ||
1350 | 73 | } | ||
1351 | 74 | |||
1352 | 75 | -- | ||
1353 | 76 | 2.10.2 | ||
1354 | 77 | |||
1355 | 0 | 78 | ||
1356 | === added file 'debian/patches/0032-mir-use-modal-window-hint.patch' | |||
1357 | --- debian/patches/0032-mir-use-modal-window-hint.patch 1970-01-01 00:00:00 +0000 | |||
1358 | +++ debian/patches/0032-mir-use-modal-window-hint.patch 2017-02-08 17:37:49 +0000 | |||
1359 | @@ -0,0 +1,76 @@ | |||
1360 | 1 | From 5d7db3246e503016462fa28d34b1b3eafe4754d0 Mon Sep 17 00:00:00 2001 | ||
1361 | 2 | From: William Hua <william.hua@canonical.com> | ||
1362 | 3 | Date: Thu, 12 Jan 2017 17:16:27 -0500 | ||
1363 | 4 | Subject: [PATCH 32/38] mir: use modal window hint | ||
1364 | 5 | |||
1365 | 6 | --- | ||
1366 | 7 | gdk/mir/gdkmirwindowimpl.c | 25 +++++++++++++++++++++++-- | ||
1367 | 8 | 1 file changed, 23 insertions(+), 2 deletions(-) | ||
1368 | 9 | |||
1369 | 10 | diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c | ||
1370 | 11 | index 8a15816..1f48dfb 100644 | ||
1371 | 12 | --- a/gdk/mir/gdkmirwindowimpl.c | ||
1372 | 13 | +++ b/gdk/mir/gdkmirwindowimpl.c | ||
1373 | 14 | @@ -88,6 +88,7 @@ struct _GdkMirWindowImpl | ||
1374 | 15 | /* Desired surface attributes */ | ||
1375 | 16 | GdkWindowTypeHint type_hint; | ||
1376 | 17 | MirSurfaceState surface_state; | ||
1377 | 18 | + gboolean modal; | ||
1378 | 19 | |||
1379 | 20 | /* Pattern for background */ | ||
1380 | 21 | cairo_pattern_t *background; | ||
1381 | 22 | @@ -305,6 +306,7 @@ create_window_type_spec (GdkDisplay *display, | ||
1382 | 23 | gint y, | ||
1383 | 24 | gint width, | ||
1384 | 25 | gint height, | ||
1385 | 26 | + gboolean modal, | ||
1386 | 27 | GdkWindowTypeHint type, | ||
1387 | 28 | const MirRectangle *rect, | ||
1388 | 29 | MirEdgeAttachment edge, | ||
1389 | 30 | @@ -358,6 +360,17 @@ create_window_type_spec (GdkDisplay *display, | ||
1390 | 31 | switch (type) | ||
1391 | 32 | { | ||
1392 | 33 | case GDK_WINDOW_TYPE_HINT_DIALOG: | ||
1393 | 34 | + if (modal) | ||
1394 | 35 | + return mir_connection_create_spec_for_modal_dialog (connection, | ||
1395 | 36 | + width, | ||
1396 | 37 | + height, | ||
1397 | 38 | + format, | ||
1398 | 39 | + parent_surface); | ||
1399 | 40 | + else | ||
1400 | 41 | + return mir_connection_create_spec_for_dialog (connection, | ||
1401 | 42 | + width, | ||
1402 | 43 | + height, | ||
1403 | 44 | + format); | ||
1404 | 45 | case GDK_WINDOW_TYPE_HINT_DOCK: | ||
1405 | 46 | return mir_connection_create_spec_for_dialog (connection, | ||
1406 | 47 | width, | ||
1407 | 48 | @@ -430,6 +443,7 @@ create_spec (GdkWindow *window, GdkMirWindowImpl *impl) | ||
1408 | 49 | impl->transient_for, | ||
1409 | 50 | impl->transient_x, impl->transient_y, | ||
1410 | 51 | window->width, window->height, | ||
1411 | 52 | + impl->modal, | ||
1412 | 53 | impl->type_hint, | ||
1413 | 54 | impl->has_rect ? &impl->rect : NULL, | ||
1414 | 55 | impl->has_rect ? impl->edge : mir_edge_attachment_any, | ||
1415 | 56 | @@ -1133,8 +1147,15 @@ void | ||
1416 | 57 | gdk_mir_window_impl_set_modal_hint (GdkWindow *window, | ||
1417 | 58 | gboolean modal) | ||
1418 | 59 | { | ||
1419 | 60 | - //g_printerr ("gdk_mir_window_impl_set_modal_hint window=%p\n", window); | ||
1420 | 61 | - /* Mir doesn't support modal windows */ | ||
1421 | 62 | + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
1422 | 63 | + | ||
1423 | 64 | + if (modal != impl->modal) | ||
1424 | 65 | + { | ||
1425 | 66 | + impl->modal = modal; | ||
1426 | 67 | + | ||
1427 | 68 | + if (impl->surface && !impl->pending_spec_update) | ||
1428 | 69 | + update_surface_spec (window); | ||
1429 | 70 | + } | ||
1430 | 71 | } | ||
1431 | 72 | |||
1432 | 73 | static void | ||
1433 | 74 | -- | ||
1434 | 75 | 2.10.2 | ||
1435 | 76 | |||
1436 | 0 | 77 | ||
1437 | === added file 'debian/patches/0036-mir-use-mir_surface_spec_set_placement-for-menus.patch' | |||
1438 | --- debian/patches/0036-mir-use-mir_surface_spec_set_placement-for-menus.patch 1970-01-01 00:00:00 +0000 | |||
1439 | +++ debian/patches/0036-mir-use-mir_surface_spec_set_placement-for-menus.patch 2017-02-08 17:37:49 +0000 | |||
1440 | @@ -0,0 +1,334 @@ | |||
1441 | 1 | From 14c8e25cb2063ff3a91b59328b7f45bcbc4cd875 Mon Sep 17 00:00:00 2001 | ||
1442 | 2 | From: William Hua <william.hua@canonical.com> | ||
1443 | 3 | Date: Fri, 27 Jan 2017 14:46:10 -0500 | ||
1444 | 4 | Subject: [PATCH 36/38] mir: use mir_surface_spec_set_placement for menus | ||
1445 | 5 | |||
1446 | 6 | This API was added to Mir for GTK menus, combo boxes, etc. | ||
1447 | 7 | --- | ||
1448 | 8 | gdk/mir/gdkmirwindowimpl.c | 240 ++++++++++++++++++++++++++++++--------------- | ||
1449 | 9 | 1 file changed, 159 insertions(+), 81 deletions(-) | ||
1450 | 10 | |||
1451 | 11 | diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c | ||
1452 | 12 | index 1f48dfb..6fe0b3c 100644 | ||
1453 | 13 | --- a/gdk/mir/gdkmirwindowimpl.c | ||
1454 | 14 | +++ b/gdk/mir/gdkmirwindowimpl.c | ||
1455 | 15 | @@ -80,10 +80,15 @@ struct _GdkMirWindowImpl | ||
1456 | 16 | gint transient_x; | ||
1457 | 17 | gint transient_y; | ||
1458 | 18 | |||
1459 | 19 | - /* Anchor rectangle */ | ||
1460 | 20 | - gboolean has_rect; | ||
1461 | 21 | - MirRectangle rect; | ||
1462 | 22 | - MirEdgeAttachment edge; | ||
1463 | 23 | + /* gdk_window_move_to_rect */ | ||
1464 | 24 | + gboolean has_rect; | ||
1465 | 25 | + GdkRectangle rect; | ||
1466 | 26 | + MirRectangle mir_rect; | ||
1467 | 27 | + MirPlacementGravity rect_anchor; | ||
1468 | 28 | + MirPlacementGravity window_anchor; | ||
1469 | 29 | + MirPlacementHints anchor_hints; | ||
1470 | 30 | + gint rect_anchor_dx; | ||
1471 | 31 | + gint rect_anchor_dy; | ||
1472 | 32 | |||
1473 | 33 | /* Desired surface attributes */ | ||
1474 | 34 | GdkWindowTypeHint type_hint; | ||
1475 | 35 | @@ -308,16 +313,12 @@ create_window_type_spec (GdkDisplay *display, | ||
1476 | 36 | gint height, | ||
1477 | 37 | gboolean modal, | ||
1478 | 38 | GdkWindowTypeHint type, | ||
1479 | 39 | - const MirRectangle *rect, | ||
1480 | 40 | - MirEdgeAttachment edge, | ||
1481 | 41 | MirBufferUsage buffer_usage) | ||
1482 | 42 | { | ||
1483 | 43 | - MirPixelFormat format; | ||
1484 | 44 | - MirSurface *parent_surface = NULL; | ||
1485 | 45 | MirConnection *connection = gdk_mir_display_get_mir_connection (display); | ||
1486 | 46 | - MirRectangle real_rect; | ||
1487 | 47 | - | ||
1488 | 48 | - format = _gdk_mir_display_get_pixel_format (display, buffer_usage); | ||
1489 | 49 | + MirSurface *parent_surface = NULL; | ||
1490 | 50 | + MirPixelFormat format; | ||
1491 | 51 | + MirRectangle rect; | ||
1492 | 52 | |||
1493 | 53 | if (parent && parent->impl) | ||
1494 | 54 | { | ||
1495 | 55 | @@ -338,24 +339,12 @@ create_window_type_spec (GdkDisplay *display, | ||
1496 | 56 | } | ||
1497 | 57 | } | ||
1498 | 58 | |||
1499 | 59 | - if (rect) | ||
1500 | 60 | - { | ||
1501 | 61 | - real_rect = *rect; | ||
1502 | 62 | + format = _gdk_mir_display_get_pixel_format (display, buffer_usage); | ||
1503 | 63 | |||
1504 | 64 | - while (parent && !gdk_window_has_native (parent) && gdk_window_get_effective_parent (parent)) | ||
1505 | 65 | - { | ||
1506 | 66 | - real_rect.left += parent->x; | ||
1507 | 67 | - real_rect.top += parent->y; | ||
1508 | 68 | - parent = gdk_window_get_effective_parent (parent); | ||
1509 | 69 | - } | ||
1510 | 70 | - } | ||
1511 | 71 | - else | ||
1512 | 72 | - { | ||
1513 | 73 | - real_rect.left = x; | ||
1514 | 74 | - real_rect.top = y; | ||
1515 | 75 | - real_rect.width = 1; | ||
1516 | 76 | - real_rect.height = 1; | ||
1517 | 77 | - } | ||
1518 | 78 | + rect.left = x; | ||
1519 | 79 | + rect.top = y; | ||
1520 | 80 | + rect.width = 1; | ||
1521 | 81 | + rect.height = 1; | ||
1522 | 82 | |||
1523 | 83 | switch (type) | ||
1524 | 84 | { | ||
1525 | 85 | @@ -389,9 +378,8 @@ create_window_type_spec (GdkDisplay *display, | ||
1526 | 86 | height, | ||
1527 | 87 | format, | ||
1528 | 88 | parent_surface, | ||
1529 | 89 | - &real_rect, | ||
1530 | 90 | - edge); | ||
1531 | 91 | - break; | ||
1532 | 92 | + &rect, | ||
1533 | 93 | + 0); | ||
1534 | 94 | case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: | ||
1535 | 95 | case GDK_WINDOW_TYPE_HINT_UTILITY: | ||
1536 | 96 | return mir_connection_create_spec_for_modal_dialog (connection, | ||
1537 | 97 | @@ -438,15 +426,16 @@ static MirSurfaceSpec* | ||
1538 | 98 | create_spec (GdkWindow *window, GdkMirWindowImpl *impl) | ||
1539 | 99 | { | ||
1540 | 100 | MirSurfaceSpec *spec = NULL; | ||
1541 | 101 | + GdkWindow *parent; | ||
1542 | 102 | |||
1543 | 103 | spec = create_window_type_spec (impl->display, | ||
1544 | 104 | impl->transient_for, | ||
1545 | 105 | - impl->transient_x, impl->transient_y, | ||
1546 | 106 | - window->width, window->height, | ||
1547 | 107 | + impl->transient_x, | ||
1548 | 108 | + impl->transient_y, | ||
1549 | 109 | + window->width, | ||
1550 | 110 | + window->height, | ||
1551 | 111 | impl->modal, | ||
1552 | 112 | impl->type_hint, | ||
1553 | 113 | - impl->has_rect ? &impl->rect : NULL, | ||
1554 | 114 | - impl->has_rect ? impl->edge : mir_edge_attachment_any, | ||
1555 | 115 | impl->buffer_usage); | ||
1556 | 116 | |||
1557 | 117 | mir_surface_spec_set_name (spec, impl->title); | ||
1558 | 118 | @@ -454,6 +443,32 @@ create_spec (GdkWindow *window, GdkMirWindowImpl *impl) | ||
1559 | 119 | |||
1560 | 120 | apply_geometry_hints (spec, impl); | ||
1561 | 121 | |||
1562 | 122 | + if (impl->has_rect) | ||
1563 | 123 | + { | ||
1564 | 124 | + impl->mir_rect.left = impl->rect.x; | ||
1565 | 125 | + impl->mir_rect.top = impl->rect.y; | ||
1566 | 126 | + impl->mir_rect.width = impl->rect.width; | ||
1567 | 127 | + impl->mir_rect.height = impl->rect.height; | ||
1568 | 128 | + | ||
1569 | 129 | + parent = impl->transient_for; | ||
1570 | 130 | + | ||
1571 | 131 | + while (parent && !gdk_window_has_native (parent)) | ||
1572 | 132 | + { | ||
1573 | 133 | + impl->mir_rect.left += parent->x; | ||
1574 | 134 | + impl->mir_rect.top += parent->y; | ||
1575 | 135 | + | ||
1576 | 136 | + parent = gdk_window_get_parent (parent); | ||
1577 | 137 | + } | ||
1578 | 138 | + | ||
1579 | 139 | + mir_surface_spec_set_placement (spec, | ||
1580 | 140 | + &impl->mir_rect, | ||
1581 | 141 | + impl->rect_anchor, | ||
1582 | 142 | + impl->window_anchor, | ||
1583 | 143 | + impl->anchor_hints, | ||
1584 | 144 | + impl->rect_anchor_dx, | ||
1585 | 145 | + impl->rect_anchor_dy); | ||
1586 | 146 | + } | ||
1587 | 147 | + | ||
1588 | 148 | return spec; | ||
1589 | 149 | } | ||
1590 | 150 | |||
1591 | 151 | @@ -861,52 +876,117 @@ gdk_mir_window_impl_move_resize (GdkWindow *window, | ||
1592 | 152 | } | ||
1593 | 153 | } | ||
1594 | 154 | |||
1595 | 155 | -static MirEdgeAttachment | ||
1596 | 156 | -get_edge_for_anchors (GdkGravity rect_anchor, | ||
1597 | 157 | - GdkGravity window_anchor, | ||
1598 | 158 | - GdkAnchorHints anchor_hints) | ||
1599 | 159 | +static MirPlacementGravity | ||
1600 | 160 | +get_mir_placement_gravity (GdkGravity gravity) | ||
1601 | 161 | { | ||
1602 | 162 | - MirEdgeAttachment edge = 0; | ||
1603 | 163 | + switch (gravity) | ||
1604 | 164 | + { | ||
1605 | 165 | + case GDK_GRAVITY_STATIC: | ||
1606 | 166 | + case GDK_GRAVITY_NORTH_WEST: | ||
1607 | 167 | + return mir_placement_gravity_northwest; | ||
1608 | 168 | + case GDK_GRAVITY_NORTH: | ||
1609 | 169 | + return mir_placement_gravity_north; | ||
1610 | 170 | + case GDK_GRAVITY_NORTH_EAST: | ||
1611 | 171 | + return mir_placement_gravity_northeast; | ||
1612 | 172 | + case GDK_GRAVITY_WEST: | ||
1613 | 173 | + return mir_placement_gravity_west; | ||
1614 | 174 | + case GDK_GRAVITY_CENTER: | ||
1615 | 175 | + return mir_placement_gravity_center; | ||
1616 | 176 | + case GDK_GRAVITY_EAST: | ||
1617 | 177 | + return mir_placement_gravity_east; | ||
1618 | 178 | + case GDK_GRAVITY_SOUTH_WEST: | ||
1619 | 179 | + return mir_placement_gravity_southwest; | ||
1620 | 180 | + case GDK_GRAVITY_SOUTH: | ||
1621 | 181 | + return mir_placement_gravity_south; | ||
1622 | 182 | + case GDK_GRAVITY_SOUTH_EAST: | ||
1623 | 183 | + return mir_placement_gravity_southeast; | ||
1624 | 184 | + } | ||
1625 | 185 | |||
1626 | 186 | - if (anchor_hints & GDK_ANCHOR_FLIP_X) | ||
1627 | 187 | - edge |= mir_edge_attachment_vertical; | ||
1628 | 188 | + g_warn_if_reached (); | ||
1629 | 189 | |||
1630 | 190 | - if (anchor_hints & GDK_ANCHOR_FLIP_Y) | ||
1631 | 191 | - edge |= mir_edge_attachment_horizontal; | ||
1632 | 192 | + return mir_placement_gravity_center; | ||
1633 | 193 | +} | ||
1634 | 194 | + | ||
1635 | 195 | +static MirPlacementHints | ||
1636 | 196 | +get_mir_placement_hints (GdkAnchorHints hints) | ||
1637 | 197 | +{ | ||
1638 | 198 | + MirPlacementHints mir_hints = 0; | ||
1639 | 199 | + | ||
1640 | 200 | + if (hints & GDK_ANCHOR_FLIP_X) | ||
1641 | 201 | + mir_hints |= mir_placement_hints_flip_x; | ||
1642 | 202 | + | ||
1643 | 203 | + if (hints & GDK_ANCHOR_FLIP_Y) | ||
1644 | 204 | + mir_hints |= mir_placement_hints_flip_y; | ||
1645 | 205 | + | ||
1646 | 206 | + if (hints & GDK_ANCHOR_SLIDE_X) | ||
1647 | 207 | + mir_hints |= mir_placement_hints_slide_x; | ||
1648 | 208 | + | ||
1649 | 209 | + if (hints & GDK_ANCHOR_SLIDE_Y) | ||
1650 | 210 | + mir_hints |= mir_placement_hints_slide_y; | ||
1651 | 211 | |||
1652 | 212 | - return edge; | ||
1653 | 213 | + if (hints & GDK_ANCHOR_RESIZE_X) | ||
1654 | 214 | + mir_hints |= mir_placement_hints_resize_x; | ||
1655 | 215 | + | ||
1656 | 216 | + if (hints & GDK_ANCHOR_RESIZE_Y) | ||
1657 | 217 | + mir_hints |= mir_placement_hints_resize_y; | ||
1658 | 218 | + | ||
1659 | 219 | + return mir_hints; | ||
1660 | 220 | } | ||
1661 | 221 | |||
1662 | 222 | -static void | ||
1663 | 223 | -get_rect_for_edge (MirRectangle *out_rect, | ||
1664 | 224 | - const GdkRectangle *in_rect, | ||
1665 | 225 | - MirEdgeAttachment edge, | ||
1666 | 226 | - GdkWindow *window) | ||
1667 | 227 | +static gint | ||
1668 | 228 | +get_window_shadow_dx (GdkWindow *window, | ||
1669 | 229 | + GdkGravity window_anchor) | ||
1670 | 230 | { | ||
1671 | 231 | - out_rect->left = in_rect->x; | ||
1672 | 232 | - out_rect->top = in_rect->y; | ||
1673 | 233 | - out_rect->width = in_rect->width; | ||
1674 | 234 | - out_rect->height = in_rect->height; | ||
1675 | 235 | + switch (window_anchor) | ||
1676 | 236 | + { | ||
1677 | 237 | + case GDK_GRAVITY_STATIC: | ||
1678 | 238 | + case GDK_GRAVITY_NORTH_WEST: | ||
1679 | 239 | + case GDK_GRAVITY_WEST: | ||
1680 | 240 | + case GDK_GRAVITY_SOUTH_WEST: | ||
1681 | 241 | + return -window->shadow_left; | ||
1682 | 242 | + | ||
1683 | 243 | + case GDK_GRAVITY_NORTH: | ||
1684 | 244 | + case GDK_GRAVITY_CENTER: | ||
1685 | 245 | + case GDK_GRAVITY_SOUTH: | ||
1686 | 246 | + return (window->shadow_right - window->shadow_left) / 2; | ||
1687 | 247 | + | ||
1688 | 248 | + case GDK_GRAVITY_NORTH_EAST: | ||
1689 | 249 | + case GDK_GRAVITY_EAST: | ||
1690 | 250 | + case GDK_GRAVITY_SOUTH_EAST: | ||
1691 | 251 | + return window->shadow_right; | ||
1692 | 252 | + } | ||
1693 | 253 | |||
1694 | 254 | - switch (edge) | ||
1695 | 255 | + g_warn_if_reached (); | ||
1696 | 256 | + | ||
1697 | 257 | + return 0; | ||
1698 | 258 | +} | ||
1699 | 259 | + | ||
1700 | 260 | +static gint | ||
1701 | 261 | +get_window_shadow_dy (GdkWindow *window, | ||
1702 | 262 | + GdkGravity window_anchor) | ||
1703 | 263 | +{ | ||
1704 | 264 | + switch (window_anchor) | ||
1705 | 265 | { | ||
1706 | 266 | - case mir_edge_attachment_vertical: | ||
1707 | 267 | - out_rect->left += window->shadow_right; | ||
1708 | 268 | - out_rect->top -= window->shadow_top; | ||
1709 | 269 | - out_rect->width -= window->shadow_left + window->shadow_right; | ||
1710 | 270 | - out_rect->height += window->shadow_top + window->shadow_bottom; | ||
1711 | 271 | - break; | ||
1712 | 272 | - | ||
1713 | 273 | - case mir_edge_attachment_horizontal: | ||
1714 | 274 | - out_rect->left -= window->shadow_left; | ||
1715 | 275 | - out_rect->top += window->shadow_bottom; | ||
1716 | 276 | - out_rect->width += window->shadow_left + window->shadow_right; | ||
1717 | 277 | - out_rect->height -= window->shadow_top + window->shadow_bottom; | ||
1718 | 278 | - break; | ||
1719 | 279 | - | ||
1720 | 280 | - default: | ||
1721 | 281 | - break; | ||
1722 | 282 | + case GDK_GRAVITY_STATIC: | ||
1723 | 283 | + case GDK_GRAVITY_NORTH_WEST: | ||
1724 | 284 | + case GDK_GRAVITY_NORTH: | ||
1725 | 285 | + case GDK_GRAVITY_NORTH_EAST: | ||
1726 | 286 | + return -window->shadow_top; | ||
1727 | 287 | + | ||
1728 | 288 | + case GDK_GRAVITY_WEST: | ||
1729 | 289 | + case GDK_GRAVITY_CENTER: | ||
1730 | 290 | + case GDK_GRAVITY_EAST: | ||
1731 | 291 | + return (window->shadow_bottom - window->shadow_top) / 2; | ||
1732 | 292 | + | ||
1733 | 293 | + case GDK_GRAVITY_SOUTH_WEST: | ||
1734 | 294 | + case GDK_GRAVITY_SOUTH: | ||
1735 | 295 | + case GDK_GRAVITY_SOUTH_EAST: | ||
1736 | 296 | + return window->shadow_bottom; | ||
1737 | 297 | } | ||
1738 | 298 | + | ||
1739 | 299 | + g_warn_if_reached (); | ||
1740 | 300 | + | ||
1741 | 301 | + return 0; | ||
1742 | 302 | } | ||
1743 | 303 | |||
1744 | 304 | static void | ||
1745 | 305 | @@ -920,18 +1000,16 @@ gdk_mir_window_impl_move_to_rect (GdkWindow *window, | ||
1746 | 306 | { | ||
1747 | 307 | GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
1748 | 308 | |||
1749 | 309 | - impl->edge = get_edge_for_anchors (rect_anchor, window_anchor, anchor_hints); | ||
1750 | 310 | - get_rect_for_edge (&impl->rect, rect, impl->edge, window); | ||
1751 | 311 | impl->has_rect = TRUE; | ||
1752 | 312 | + impl->rect = *rect; | ||
1753 | 313 | + impl->rect_anchor = get_mir_placement_gravity (rect_anchor); | ||
1754 | 314 | + impl->window_anchor = get_mir_placement_gravity (window_anchor); | ||
1755 | 315 | + impl->anchor_hints = get_mir_placement_hints (anchor_hints); | ||
1756 | 316 | + impl->rect_anchor_dx = rect_anchor_dx + get_window_shadow_dx (window, window_anchor); | ||
1757 | 317 | + impl->rect_anchor_dy = rect_anchor_dy + get_window_shadow_dy (window, window_anchor); | ||
1758 | 318 | |||
1759 | 319 | - ensure_no_surface (window); | ||
1760 | 320 | - | ||
1761 | 321 | - g_signal_emit_by_name (window, | ||
1762 | 322 | - "moved-to-rect", | ||
1763 | 323 | - NULL, | ||
1764 | 324 | - NULL, | ||
1765 | 325 | - FALSE, | ||
1766 | 326 | - FALSE); | ||
1767 | 327 | + if (impl->surface && !impl->pending_spec_update) | ||
1768 | 328 | + update_surface_spec (window); | ||
1769 | 329 | } | ||
1770 | 330 | |||
1771 | 331 | static void | ||
1772 | 332 | -- | ||
1773 | 333 | 2.10.2 | ||
1774 | 334 | |||
1775 | 0 | 335 | ||
1776 | === added file 'debian/patches/0037-mir-handle-surface-placement-events.patch' | |||
1777 | --- debian/patches/0037-mir-handle-surface-placement-events.patch 1970-01-01 00:00:00 +0000 | |||
1778 | +++ debian/patches/0037-mir-handle-surface-placement-events.patch 2017-02-08 17:37:49 +0000 | |||
1779 | @@ -0,0 +1,287 @@ | |||
1780 | 1 | From d9947b671a2c605ef64cb720d2a9c6c80b39e7af Mon Sep 17 00:00:00 2001 | ||
1781 | 2 | From: William Hua <william.hua@canonical.com> | ||
1782 | 3 | Date: Sun, 29 Jan 2017 11:24:43 -0500 | ||
1783 | 4 | Subject: [PATCH 37/38] mir: handle surface placement events | ||
1784 | 5 | |||
1785 | 6 | This allows the Mir backend to properly emit "moved-to-rect." | ||
1786 | 7 | --- | ||
1787 | 8 | gdk/mir/gdkmir-private.h | 2 + | ||
1788 | 9 | gdk/mir/gdkmir.h | 1 + | ||
1789 | 10 | gdk/mir/gdkmireventsource.c | 10 +++ | ||
1790 | 11 | gdk/mir/gdkmirwindowimpl.c | 207 ++++++++++++++++++++++++++++++++++++++++++++ | ||
1791 | 12 | 4 files changed, 220 insertions(+) | ||
1792 | 13 | |||
1793 | 14 | diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h | ||
1794 | 15 | index a677dec..4595dc5 100644 | ||
1795 | 16 | --- a/gdk/mir/gdkmir-private.h | ||
1796 | 17 | +++ b/gdk/mir/gdkmir-private.h | ||
1797 | 18 | @@ -91,6 +91,8 @@ void _gdk_mir_window_impl_set_surface_type (GdkMirWindowImpl *impl, MirSurfaceTy | ||
1798 | 19 | |||
1799 | 20 | void _gdk_mir_window_set_surface_output (GdkWindow *window, gdouble scale); | ||
1800 | 21 | |||
1801 | 22 | +void _gdk_mir_window_set_final_rect (GdkWindow *window, MirRectangle rect); | ||
1802 | 23 | + | ||
1803 | 24 | void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, gdouble y, gboolean cursor_inside, guint button_state); | ||
1804 | 25 | |||
1805 | 26 | void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean *cursor_inside, guint *button_state); | ||
1806 | 27 | diff --git a/gdk/mir/gdkmir.h b/gdk/mir/gdkmir.h | ||
1807 | 28 | index 38cc80c..6e92fcf 100644 | ||
1808 | 29 | --- a/gdk/mir/gdkmir.h | ||
1809 | 30 | +++ b/gdk/mir/gdkmir.h | ||
1810 | 31 | @@ -20,6 +20,7 @@ | ||
1811 | 32 | |||
1812 | 33 | #include <gdk/gdk.h> | ||
1813 | 34 | #include <mir_toolkit/mir_client_library.h> | ||
1814 | 35 | +#include <mir_toolkit/events/surface_placement.h> | ||
1815 | 36 | |||
1816 | 37 | G_BEGIN_DECLS | ||
1817 | 38 | |||
1818 | 39 | diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c | ||
1819 | 40 | index d3c85b9..3ebf156 100644 | ||
1820 | 41 | --- a/gdk/mir/gdkmireventsource.c | ||
1821 | 42 | +++ b/gdk/mir/gdkmireventsource.c | ||
1822 | 43 | @@ -541,6 +541,13 @@ handle_surface_output_event (GdkWindow *window, | ||
1823 | 44 | _gdk_mir_window_set_surface_output (window, mir_surface_output_event_get_scale (event)); | ||
1824 | 45 | } | ||
1825 | 46 | |||
1826 | 47 | +static void | ||
1827 | 48 | +handle_surface_placement_event (GdkWindow *window, | ||
1828 | 49 | + const MirSurfacePlacementEvent *event) | ||
1829 | 50 | +{ | ||
1830 | 51 | + _gdk_mir_window_set_final_rect (window, mir_surface_placement_get_relative_position (event)); | ||
1831 | 52 | +} | ||
1832 | 53 | + | ||
1833 | 54 | typedef struct | ||
1834 | 55 | { | ||
1835 | 56 | GdkWindow *window; | ||
1836 | 57 | @@ -600,6 +607,9 @@ gdk_mir_event_source_queue_event (GdkDisplay *display, | ||
1837 | 58 | case mir_event_type_surface_output: | ||
1838 | 59 | handle_surface_output_event (window, mir_event_get_surface_output_event (event)); | ||
1839 | 60 | break; | ||
1840 | 61 | + case mir_event_type_surface_placement: | ||
1841 | 62 | + handle_surface_placement_event (window, mir_event_get_surface_placement_event (event)); | ||
1842 | 63 | + break; | ||
1843 | 64 | default: | ||
1844 | 65 | g_warning ("Ignoring unknown Mir event %d", mir_event_get_type (event)); | ||
1845 | 66 | // FIXME? | ||
1846 | 67 | diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c | ||
1847 | 68 | index 6fe0b3c..1b016ec 100644 | ||
1848 | 69 | --- a/gdk/mir/gdkmirwindowimpl.c | ||
1849 | 70 | +++ b/gdk/mir/gdkmirwindowimpl.c | ||
1850 | 71 | @@ -1012,6 +1012,213 @@ gdk_mir_window_impl_move_to_rect (GdkWindow *window, | ||
1851 | 72 | update_surface_spec (window); | ||
1852 | 73 | } | ||
1853 | 74 | |||
1854 | 75 | +static gint | ||
1855 | 76 | +get_mir_placement_gravity_x (MirPlacementGravity gravity) | ||
1856 | 77 | +{ | ||
1857 | 78 | + switch (gravity) | ||
1858 | 79 | + { | ||
1859 | 80 | + case mir_placement_gravity_west: | ||
1860 | 81 | + case mir_placement_gravity_northwest: | ||
1861 | 82 | + case mir_placement_gravity_southwest: | ||
1862 | 83 | + return 0; | ||
1863 | 84 | + | ||
1864 | 85 | + case mir_placement_gravity_center: | ||
1865 | 86 | + case mir_placement_gravity_north: | ||
1866 | 87 | + case mir_placement_gravity_south: | ||
1867 | 88 | + return 1; | ||
1868 | 89 | + | ||
1869 | 90 | + case mir_placement_gravity_east: | ||
1870 | 91 | + case mir_placement_gravity_northeast: | ||
1871 | 92 | + case mir_placement_gravity_southeast: | ||
1872 | 93 | + return 2; | ||
1873 | 94 | + } | ||
1874 | 95 | + | ||
1875 | 96 | + g_warn_if_reached (); | ||
1876 | 97 | + | ||
1877 | 98 | + return 1; | ||
1878 | 99 | +} | ||
1879 | 100 | + | ||
1880 | 101 | +static gint | ||
1881 | 102 | +get_mir_placement_gravity_y (MirPlacementGravity gravity) | ||
1882 | 103 | +{ | ||
1883 | 104 | + switch (gravity) | ||
1884 | 105 | + { | ||
1885 | 106 | + case mir_placement_gravity_north: | ||
1886 | 107 | + case mir_placement_gravity_northwest: | ||
1887 | 108 | + case mir_placement_gravity_northeast: | ||
1888 | 109 | + return 0; | ||
1889 | 110 | + | ||
1890 | 111 | + case mir_placement_gravity_center: | ||
1891 | 112 | + case mir_placement_gravity_west: | ||
1892 | 113 | + case mir_placement_gravity_east: | ||
1893 | 114 | + return 1; | ||
1894 | 115 | + | ||
1895 | 116 | + case mir_placement_gravity_south: | ||
1896 | 117 | + case mir_placement_gravity_southwest: | ||
1897 | 118 | + case mir_placement_gravity_southeast: | ||
1898 | 119 | + return 2; | ||
1899 | 120 | + } | ||
1900 | 121 | + | ||
1901 | 122 | + g_warn_if_reached (); | ||
1902 | 123 | + | ||
1903 | 124 | + return 1; | ||
1904 | 125 | +} | ||
1905 | 126 | + | ||
1906 | 127 | +static GdkRectangle | ||
1907 | 128 | +get_unflipped_rect (const GdkRectangle *rect, | ||
1908 | 129 | + gint width, | ||
1909 | 130 | + gint height, | ||
1910 | 131 | + MirPlacementGravity rect_anchor, | ||
1911 | 132 | + MirPlacementGravity window_anchor, | ||
1912 | 133 | + gint rect_anchor_dx, | ||
1913 | 134 | + gint rect_anchor_dy) | ||
1914 | 135 | +{ | ||
1915 | 136 | + GdkRectangle unflipped_rect; | ||
1916 | 137 | + | ||
1917 | 138 | + unflipped_rect.x = rect->x; | ||
1918 | 139 | + unflipped_rect.x += rect->width * get_mir_placement_gravity_x (rect_anchor) / 2; | ||
1919 | 140 | + unflipped_rect.x -= width * get_mir_placement_gravity_x (window_anchor) / 2; | ||
1920 | 141 | + unflipped_rect.x += rect_anchor_dx; | ||
1921 | 142 | + unflipped_rect.y = rect->y; | ||
1922 | 143 | + unflipped_rect.y += rect->height * get_mir_placement_gravity_y (rect_anchor) / 2; | ||
1923 | 144 | + unflipped_rect.y -= height * get_mir_placement_gravity_y (window_anchor) / 2; | ||
1924 | 145 | + unflipped_rect.y += rect_anchor_dy; | ||
1925 | 146 | + unflipped_rect.width = width; | ||
1926 | 147 | + unflipped_rect.height = height; | ||
1927 | 148 | + | ||
1928 | 149 | + return unflipped_rect; | ||
1929 | 150 | +} | ||
1930 | 151 | + | ||
1931 | 152 | +static MirPlacementGravity | ||
1932 | 153 | +get_opposite_mir_placement_gravity (MirPlacementGravity gravity) | ||
1933 | 154 | +{ | ||
1934 | 155 | + switch (gravity) | ||
1935 | 156 | + { | ||
1936 | 157 | + case mir_placement_gravity_center: | ||
1937 | 158 | + return mir_placement_gravity_center; | ||
1938 | 159 | + case mir_placement_gravity_west: | ||
1939 | 160 | + return mir_placement_gravity_east; | ||
1940 | 161 | + case mir_placement_gravity_east: | ||
1941 | 162 | + return mir_placement_gravity_west; | ||
1942 | 163 | + case mir_placement_gravity_north: | ||
1943 | 164 | + return mir_placement_gravity_south; | ||
1944 | 165 | + case mir_placement_gravity_south: | ||
1945 | 166 | + return mir_placement_gravity_north; | ||
1946 | 167 | + case mir_placement_gravity_northwest: | ||
1947 | 168 | + return mir_placement_gravity_southeast; | ||
1948 | 169 | + case mir_placement_gravity_northeast: | ||
1949 | 170 | + return mir_placement_gravity_southwest; | ||
1950 | 171 | + case mir_placement_gravity_southwest: | ||
1951 | 172 | + return mir_placement_gravity_northeast; | ||
1952 | 173 | + case mir_placement_gravity_southeast: | ||
1953 | 174 | + return mir_placement_gravity_northwest; | ||
1954 | 175 | + } | ||
1955 | 176 | + | ||
1956 | 177 | + g_warn_if_reached (); | ||
1957 | 178 | + | ||
1958 | 179 | + return gravity; | ||
1959 | 180 | +} | ||
1960 | 181 | + | ||
1961 | 182 | +static gint | ||
1962 | 183 | +get_anchor_x (const GdkRectangle *rect, | ||
1963 | 184 | + MirPlacementGravity anchor) | ||
1964 | 185 | +{ | ||
1965 | 186 | + return rect->x + rect->width * get_mir_placement_gravity_x (anchor) / 2; | ||
1966 | 187 | +} | ||
1967 | 188 | + | ||
1968 | 189 | +static gint | ||
1969 | 190 | +get_anchor_y (const GdkRectangle *rect, | ||
1970 | 191 | + MirPlacementGravity anchor) | ||
1971 | 192 | +{ | ||
1972 | 193 | + return rect->y + rect->height * get_mir_placement_gravity_y (anchor) / 2; | ||
1973 | 194 | +} | ||
1974 | 195 | + | ||
1975 | 196 | +void | ||
1976 | 197 | +_gdk_mir_window_set_final_rect (GdkWindow *window, | ||
1977 | 198 | + MirRectangle rect) | ||
1978 | 199 | +{ | ||
1979 | 200 | + GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); | ||
1980 | 201 | + GdkRectangle best_rect; | ||
1981 | 202 | + GdkRectangle worst_rect; | ||
1982 | 203 | + GdkRectangle flipped_rect; | ||
1983 | 204 | + GdkRectangle final_rect; | ||
1984 | 205 | + gboolean flipped_x = FALSE; | ||
1985 | 206 | + gboolean flipped_y = FALSE; | ||
1986 | 207 | + gint test_position; | ||
1987 | 208 | + gint final_position; | ||
1988 | 209 | + gint unflipped_offset; | ||
1989 | 210 | + gint flipped_offset; | ||
1990 | 211 | + | ||
1991 | 212 | + g_return_if_fail (impl->has_rect); | ||
1992 | 213 | + | ||
1993 | 214 | + best_rect = get_unflipped_rect (&impl->rect, | ||
1994 | 215 | + window->width, | ||
1995 | 216 | + window->height, | ||
1996 | 217 | + impl->rect_anchor, | ||
1997 | 218 | + impl->window_anchor, | ||
1998 | 219 | + impl->rect_anchor_dx, | ||
1999 | 220 | + impl->rect_anchor_dy); | ||
2000 | 221 | + | ||
2001 | 222 | + worst_rect = get_unflipped_rect (&impl->rect, | ||
2002 | 223 | + window->width, | ||
2003 | 224 | + window->height, | ||
2004 | 225 | + get_opposite_mir_placement_gravity (impl->rect_anchor), | ||
2005 | 226 | + get_opposite_mir_placement_gravity (impl->window_anchor), | ||
2006 | 227 | + -impl->rect_anchor_dx, | ||
2007 | 228 | + -impl->rect_anchor_dy); | ||
2008 | 229 | + | ||
2009 | 230 | + flipped_rect.x = best_rect.x; | ||
2010 | 231 | + flipped_rect.y = best_rect.y; | ||
2011 | 232 | + flipped_rect.width = window->width; | ||
2012 | 233 | + flipped_rect.height = window->height; | ||
2013 | 234 | + | ||
2014 | 235 | + final_rect.x = rect.left - (impl->mir_rect.left - impl->rect.x); | ||
2015 | 236 | + final_rect.y = rect.top - (impl->mir_rect.top - impl->rect.y); | ||
2016 | 237 | + final_rect.width = rect.width; | ||
2017 | 238 | + final_rect.height = rect.height; | ||
2018 | 239 | + | ||
2019 | 240 | + if (impl->anchor_hints & mir_placement_hints_flip_x) | ||
2020 | 241 | + { | ||
2021 | 242 | + test_position = get_anchor_x (&best_rect, impl->window_anchor); | ||
2022 | 243 | + final_position = get_anchor_x (&final_rect, impl->window_anchor); | ||
2023 | 244 | + unflipped_offset = final_position - test_position; | ||
2024 | 245 | + | ||
2025 | 246 | + test_position = get_anchor_x (&worst_rect, get_opposite_mir_placement_gravity (impl->window_anchor)); | ||
2026 | 247 | + final_position = get_anchor_x (&final_rect, get_opposite_mir_placement_gravity (impl->window_anchor)); | ||
2027 | 248 | + flipped_offset = final_position - test_position; | ||
2028 | 249 | + | ||
2029 | 250 | + if (ABS (flipped_offset) < ABS (unflipped_offset)) | ||
2030 | 251 | + { | ||
2031 | 252 | + flipped_rect.x = worst_rect.x; | ||
2032 | 253 | + flipped_x = TRUE; | ||
2033 | 254 | + } | ||
2034 | 255 | + } | ||
2035 | 256 | + | ||
2036 | 257 | + if (impl->anchor_hints & mir_placement_hints_flip_y) | ||
2037 | 258 | + { | ||
2038 | 259 | + test_position = get_anchor_y (&best_rect, impl->window_anchor); | ||
2039 | 260 | + final_position = get_anchor_y (&final_rect, impl->window_anchor); | ||
2040 | 261 | + unflipped_offset = final_position - test_position; | ||
2041 | 262 | + | ||
2042 | 263 | + test_position = get_anchor_y (&worst_rect, get_opposite_mir_placement_gravity (impl->window_anchor)); | ||
2043 | 264 | + final_position = get_anchor_y (&final_rect, get_opposite_mir_placement_gravity (impl->window_anchor)); | ||
2044 | 265 | + flipped_offset = final_position - test_position; | ||
2045 | 266 | + | ||
2046 | 267 | + if (ABS (flipped_offset) < ABS (unflipped_offset)) | ||
2047 | 268 | + { | ||
2048 | 269 | + flipped_rect.y = worst_rect.y; | ||
2049 | 270 | + flipped_y = TRUE; | ||
2050 | 271 | + } | ||
2051 | 272 | + } | ||
2052 | 273 | + | ||
2053 | 274 | + g_signal_emit_by_name (window, | ||
2054 | 275 | + "moved-to-rect", | ||
2055 | 276 | + &flipped_rect, | ||
2056 | 277 | + &final_rect, | ||
2057 | 278 | + flipped_x, | ||
2058 | 279 | + flipped_y); | ||
2059 | 280 | +} | ||
2060 | 281 | + | ||
2061 | 282 | static void | ||
2062 | 283 | gdk_mir_window_impl_set_background (GdkWindow *window, | ||
2063 | 284 | cairo_pattern_t *pattern) | ||
2064 | 285 | -- | ||
2065 | 286 | 2.10.2 | ||
2066 | 287 | |||
2067 | 0 | 288 | ||
2068 | === modified file 'debian/patches/series' | |||
2069 | --- debian/patches/series 2017-01-23 14:44:24 +0000 | |||
2070 | +++ debian/patches/series 2017-02-08 17:37:49 +0000 | |||
2071 | @@ -24,3 +24,14 @@ | |||
2072 | 24 | unity-border-radius.patch | 24 | unity-border-radius.patch |
2073 | 25 | unity-headerbar-maximized-mode.patch | 25 | unity-headerbar-maximized-mode.patch |
2074 | 26 | gtksocket-unscale-before-sending-configurenotify.patch | 26 | gtksocket-unscale-before-sending-configurenotify.patch |
2075 | 27 | |||
2076 | 28 | 0001-mir-implement-window-properties.patch | ||
2077 | 29 | 0002-mir-track-focused-window.patch | ||
2078 | 30 | 0003-mir-connect-to-content-hub.patch | ||
2079 | 31 | 0004-mir-copy-clipboard-data-to-content-hub.patch | ||
2080 | 32 | 0005-mir-paste-clipboard-data-from-content-hub.patch | ||
2081 | 33 | 0006-mir-properly-handle-empty-clipboard.patch | ||
2082 | 34 | 0031-mir-fix-compile-time-warnings.patch | ||
2083 | 35 | 0032-mir-use-modal-window-hint.patch | ||
2084 | 36 | 0036-mir-use-mir_surface_spec_set_placement-for-menus.patch | ||
2085 | 37 | 0037-mir-handle-surface-placement-events.patch |
Thanks!