Merge lp:~3v1n0/unity/fix-multiscreen-indicators-geometries into lp:unity/4.0

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merge reported by: Neil J. Patel
Merged at revision: not available
Proposed branch: lp:~3v1n0/unity/fix-multiscreen-indicators-geometries
Merge into: lp:unity/4.0
Diff against target: 218 lines (+79/-27)
2 files modified
plugins/unityshell/src/PanelView.cpp (+11/-3)
services/panel-service.c (+68/-24)
To merge this branch: bzr merge lp:~3v1n0/unity/fix-multiscreen-indicators-geometries
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+78941@code.launchpad.net

Description of the change

Add support to multi-geometries indicator entries in unity-panel-service to fix bug #869196

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Excellent work.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/PanelView.cpp'
--- plugins/unityshell/src/PanelView.cpp 2011-10-07 13:26:30 +0000
+++ plugins/unityshell/src/PanelView.cpp 2011-10-11 15:07:25 +0000
@@ -136,6 +136,7 @@
136{136{
137 if (_track_menu_pointer_id)137 if (_track_menu_pointer_id)
138 g_source_remove(_track_menu_pointer_id);138 g_source_remove(_track_menu_pointer_id);
139
139 _style->UnReference();140 _style->UnReference();
140 UBusServer *ubus = ubus_server_get_default();141 UBusServer *ubus = ubus_server_get_default();
141 ubus_server_unregister_interest(ubus, _handle_bg_color_update);142 ubus_server_unregister_interest(ubus, _handle_bg_color_update);
@@ -143,6 +144,9 @@
143 ubus_server_unregister_interest(ubus, _handle_dash_shown);144 ubus_server_unregister_interest(ubus, _handle_dash_shown);
144 _on_indicator_updated_connections.clear();145 _on_indicator_updated_connections.clear();
145146
147 indicator::EntryLocationMap locations;
148 _remote->SyncGeometries(GetName() + boost::lexical_cast<std::string>(_monitor), locations);
149
146 delete _bg_layer;150 delete _bg_layer;
147}151}
148152
@@ -272,7 +276,7 @@
272276
273 GfxContext.PopClippingRectangle();277 GfxContext.PopClippingRectangle();
274278
275 if (_needs_geo_sync && _menu_view->GetControlsActive())279 if (_needs_geo_sync)
276 {280 {
277 SyncGeometries();281 SyncGeometries();
278 _needs_geo_sync = false;282 _needs_geo_sync = false;
@@ -622,9 +626,13 @@
622PanelView::SyncGeometries()626PanelView::SyncGeometries()
623{627{
624 indicator::EntryLocationMap locations;628 indicator::EntryLocationMap locations;
625 _menu_view->GetGeometryForSync(locations);629 std::string panel_id = GetName() + boost::lexical_cast<std::string>(_monitor);
630
631 if (_menu_view->GetControlsActive())
632 _menu_view->GetGeometryForSync(locations);
633
626 _indicators->GetGeometryForSync(locations);634 _indicators->GetGeometryForSync(locations);
627 _remote->SyncGeometries(GetName(), locations);635 _remote->SyncGeometries(panel_id, locations);
628}636}
629637
630void638void
631639
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2011-09-28 15:26:17 +0000
+++ services/panel-service.c 2011-10-11 15:07:25 +0000
@@ -49,7 +49,7 @@
49{49{
50 GSList *indicators;50 GSList *indicators;
51 GHashTable *entry2indicator_hash;51 GHashTable *entry2indicator_hash;
52 GHashTable *entry2geometry_hash;52 GHashTable *panel2entries_hash;
5353
54 guint initial_sync_id;54 guint initial_sync_id;
55 gint32 timeouts[N_TIMEOUT_SLOTS];55 gint32 timeouts[N_TIMEOUT_SLOTS];
@@ -134,7 +134,7 @@
134 gint i;134 gint i;
135135
136 g_hash_table_destroy (priv->entry2indicator_hash);136 g_hash_table_destroy (priv->entry2indicator_hash);
137 g_hash_table_destroy (priv->entry2geometry_hash);137 g_hash_table_destroy (priv->panel2entries_hash);
138138
139 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object);139 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object);
140140
@@ -300,19 +300,25 @@
300static IndicatorObjectEntry *300static IndicatorObjectEntry *
301get_entry_at (PanelService *self, gint x, gint y)301get_entry_at (PanelService *self, gint x, gint y)
302{302{
303 GHashTableIter iter;303 GHashTableIter panel_iter, entries_iter;
304 gpointer key, value;304 gpointer key, value, k, v;
305305
306 g_hash_table_iter_init (&iter, self->priv->entry2geometry_hash);306 g_hash_table_iter_init (&panel_iter, self->priv->panel2entries_hash);
307 while (g_hash_table_iter_next (&iter, &key, &value)) 307 while (g_hash_table_iter_next (&panel_iter, &key, &value))
308 {308 {
309 IndicatorObjectEntry *entry = key;309 GHashTable *entry2geometry_hash = value;
310 GdkRectangle *geo = value;310 g_hash_table_iter_init (&entries_iter, entry2geometry_hash);
311311
312 if (x >= geo->x && x <= (geo->x + geo->width) &&312 while (g_hash_table_iter_next (&entries_iter, &k, &v))
313 y >= geo->y && y <= (geo->y + geo->height))
314 {313 {
315 return entry;314 IndicatorObjectEntry *entry = k;
315 GdkRectangle *geo = v;
316
317 if (x >= geo->x && x <= (geo->x + geo->width) &&
318 y >= geo->y && y <= (geo->y + geo->height))
319 {
320 return entry;
321 }
316 }322 }
317 }323 }
318324
@@ -350,8 +356,9 @@
350 gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self);356 gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self);
351357
352 priv->entry2indicator_hash = g_hash_table_new (g_direct_hash, g_direct_equal);358 priv->entry2indicator_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
353 priv->entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,359 priv->panel2entries_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
354 NULL, g_free);360 g_free,
361 (GDestroyNotify) g_hash_table_destroy);
355362
356 suppress_signals = TRUE;363 suppress_signals = TRUE;
357 load_indicators (self);364 load_indicators (self);
@@ -388,7 +395,19 @@
388 for (l = entries; l; l = l->next)395 for (l = entries; l; l = l->next)
389 {396 {
390 g_hash_table_remove (self->priv->entry2indicator_hash, l->data);397 g_hash_table_remove (self->priv->entry2indicator_hash, l->data);
391 g_hash_table_remove (self->priv->entry2geometry_hash, l->data);398
399 GHashTableIter iter;
400 gpointer key, value;
401 g_hash_table_iter_init (&iter, self->priv->panel2entries_hash);
402 while (g_hash_table_iter_next (&iter, &key, &value))
403 {
404 GHashTable *entry2geometry_hash = value;
405
406 if (g_hash_table_size (entry2geometry_hash) > 1)
407 g_hash_table_remove (entry2geometry_hash, l->data);
408 else
409 g_hash_table_iter_remove (&iter);
410 }
392 }411 }
393412
394 g_list_free (entries);413 g_list_free (entries);
@@ -649,7 +668,7 @@
649 priv = self->priv;668 priv = self->priv;
650669
651 g_hash_table_remove (priv->entry2indicator_hash, entry);670 g_hash_table_remove (priv->entry2indicator_hash, entry);
652 /* Don't remove here the value from priv->entry2geometry_hash, this should671 /* Don't remove here the value from priv->panel2entries_hash, this should
653 * be done in during the sync, to avoid false positive.672 * be done in during the sync, to avoid false positive.
654 * FIXME this in libappmenu.so to avoid to send an "entry-removed" signal673 * FIXME this in libappmenu.so to avoid to send an "entry-removed" signal
655 * when switching the focus from a window to one of its dialog children */674 * when switching the focus from a window to one of its dialog children */
@@ -1033,6 +1052,7 @@
1033 priv->last_top = 0;1052 priv->last_top = 0;
1034 priv->last_bottom = 0;1053 priv->last_bottom = 0;
10351054
1055 priv->use_event = FALSE;
1036 priv->pressed_entry = NULL;1056 priv->pressed_entry = NULL;
10371057
1038 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, "");1058 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, "");
@@ -1105,12 +1125,12 @@
11051125
1106void1126void
1107panel_service_sync_geometry (PanelService *self,1127panel_service_sync_geometry (PanelService *self,
1108 const gchar *indicator_id,1128 const gchar *panel_id,
1109 const gchar *entry_id,1129 const gchar *entry_id,
1110 gint x,1130 gint x,
1111 gint y,1131 gint y,
1112 gint width,1132 gint width,
1113 gint height)1133 gint height)
1114{1134{
1115 PanelServicePrivate *priv = self->priv;1135 PanelServicePrivate *priv = self->priv;
1116 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);1136 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);
@@ -1118,18 +1138,42 @@
11181138
1119 if (entry)1139 if (entry)
1120 {1140 {
1141 GHashTable *entry2geometry_hash = g_hash_table_lookup (priv->panel2entries_hash, panel_id);
1142
1121 if (width < 0 || height < 0)1143 if (width < 0 || height < 0)
1122 {1144 {
1123 g_hash_table_remove (priv->entry2geometry_hash, entry);1145 if (entry2geometry_hash)
1146 {
1147 if (g_hash_table_size (entry2geometry_hash) > 1)
1148 {
1149 g_hash_table_remove (entry2geometry_hash, entry);
1150 }
1151 else
1152 {
1153 g_hash_table_remove (priv->panel2entries_hash, panel_id);
1154 }
1155 }
1124 }1156 }
1125 else1157 else
1126 {1158 {
1127 GdkRectangle *geo = g_hash_table_lookup (priv->entry2geometry_hash, entry);1159 GdkRectangle *geo = NULL;
1160
1161 if (entry2geometry_hash == NULL)
1162 {
1163 entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
1164 g_free, g_free);
1165 g_hash_table_insert (priv->panel2entries_hash, g_strdup (panel_id),
1166 entry2geometry_hash);
1167 }
1168 else
1169 {
1170 geo = g_hash_table_lookup (entry2geometry_hash, entry);
1171 }
11281172
1129 if (geo == NULL)1173 if (geo == NULL)
1130 {1174 {
1131 geo = g_new (GdkRectangle, 1);1175 geo = g_new (GdkRectangle, 1);
1132 g_hash_table_insert (priv->entry2geometry_hash, entry, geo);1176 g_hash_table_insert (entry2geometry_hash, entry, geo);
1133 }1177 }
11341178
1135 geo->x = x;1179 geo->x = x;

Subscribers

People subscribed via source and target branches