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
1=== modified file 'plugins/unityshell/src/PanelView.cpp'
2--- plugins/unityshell/src/PanelView.cpp 2011-10-07 13:26:30 +0000
3+++ plugins/unityshell/src/PanelView.cpp 2011-10-11 15:07:25 +0000
4@@ -136,6 +136,7 @@
5 {
6 if (_track_menu_pointer_id)
7 g_source_remove(_track_menu_pointer_id);
8+
9 _style->UnReference();
10 UBusServer *ubus = ubus_server_get_default();
11 ubus_server_unregister_interest(ubus, _handle_bg_color_update);
12@@ -143,6 +144,9 @@
13 ubus_server_unregister_interest(ubus, _handle_dash_shown);
14 _on_indicator_updated_connections.clear();
15
16+ indicator::EntryLocationMap locations;
17+ _remote->SyncGeometries(GetName() + boost::lexical_cast<std::string>(_monitor), locations);
18+
19 delete _bg_layer;
20 }
21
22@@ -272,7 +276,7 @@
23
24 GfxContext.PopClippingRectangle();
25
26- if (_needs_geo_sync && _menu_view->GetControlsActive())
27+ if (_needs_geo_sync)
28 {
29 SyncGeometries();
30 _needs_geo_sync = false;
31@@ -622,9 +626,13 @@
32 PanelView::SyncGeometries()
33 {
34 indicator::EntryLocationMap locations;
35- _menu_view->GetGeometryForSync(locations);
36+ std::string panel_id = GetName() + boost::lexical_cast<std::string>(_monitor);
37+
38+ if (_menu_view->GetControlsActive())
39+ _menu_view->GetGeometryForSync(locations);
40+
41 _indicators->GetGeometryForSync(locations);
42- _remote->SyncGeometries(GetName(), locations);
43+ _remote->SyncGeometries(panel_id, locations);
44 }
45
46 void
47
48=== modified file 'services/panel-service.c'
49--- services/panel-service.c 2011-09-28 15:26:17 +0000
50+++ services/panel-service.c 2011-10-11 15:07:25 +0000
51@@ -49,7 +49,7 @@
52 {
53 GSList *indicators;
54 GHashTable *entry2indicator_hash;
55- GHashTable *entry2geometry_hash;
56+ GHashTable *panel2entries_hash;
57
58 guint initial_sync_id;
59 gint32 timeouts[N_TIMEOUT_SLOTS];
60@@ -134,7 +134,7 @@
61 gint i;
62
63 g_hash_table_destroy (priv->entry2indicator_hash);
64- g_hash_table_destroy (priv->entry2geometry_hash);
65+ g_hash_table_destroy (priv->panel2entries_hash);
66
67 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object);
68
69@@ -300,19 +300,25 @@
70 static IndicatorObjectEntry *
71 get_entry_at (PanelService *self, gint x, gint y)
72 {
73- GHashTableIter iter;
74- gpointer key, value;
75+ GHashTableIter panel_iter, entries_iter;
76+ gpointer key, value, k, v;
77
78- g_hash_table_iter_init (&iter, self->priv->entry2geometry_hash);
79- while (g_hash_table_iter_next (&iter, &key, &value))
80+ g_hash_table_iter_init (&panel_iter, self->priv->panel2entries_hash);
81+ while (g_hash_table_iter_next (&panel_iter, &key, &value))
82 {
83- IndicatorObjectEntry *entry = key;
84- GdkRectangle *geo = value;
85+ GHashTable *entry2geometry_hash = value;
86+ g_hash_table_iter_init (&entries_iter, entry2geometry_hash);
87
88- if (x >= geo->x && x <= (geo->x + geo->width) &&
89- y >= geo->y && y <= (geo->y + geo->height))
90+ while (g_hash_table_iter_next (&entries_iter, &k, &v))
91 {
92- return entry;
93+ IndicatorObjectEntry *entry = k;
94+ GdkRectangle *geo = v;
95+
96+ if (x >= geo->x && x <= (geo->x + geo->width) &&
97+ y >= geo->y && y <= (geo->y + geo->height))
98+ {
99+ return entry;
100+ }
101 }
102 }
103
104@@ -350,8 +356,9 @@
105 gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self);
106
107 priv->entry2indicator_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
108- priv->entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
109- NULL, g_free);
110+ priv->panel2entries_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
111+ g_free,
112+ (GDestroyNotify) g_hash_table_destroy);
113
114 suppress_signals = TRUE;
115 load_indicators (self);
116@@ -388,7 +395,19 @@
117 for (l = entries; l; l = l->next)
118 {
119 g_hash_table_remove (self->priv->entry2indicator_hash, l->data);
120- g_hash_table_remove (self->priv->entry2geometry_hash, l->data);
121+
122+ GHashTableIter iter;
123+ gpointer key, value;
124+ g_hash_table_iter_init (&iter, self->priv->panel2entries_hash);
125+ while (g_hash_table_iter_next (&iter, &key, &value))
126+ {
127+ GHashTable *entry2geometry_hash = value;
128+
129+ if (g_hash_table_size (entry2geometry_hash) > 1)
130+ g_hash_table_remove (entry2geometry_hash, l->data);
131+ else
132+ g_hash_table_iter_remove (&iter);
133+ }
134 }
135
136 g_list_free (entries);
137@@ -649,7 +668,7 @@
138 priv = self->priv;
139
140 g_hash_table_remove (priv->entry2indicator_hash, entry);
141- /* Don't remove here the value from priv->entry2geometry_hash, this should
142+ /* Don't remove here the value from priv->panel2entries_hash, this should
143 * be done in during the sync, to avoid false positive.
144 * FIXME this in libappmenu.so to avoid to send an "entry-removed" signal
145 * when switching the focus from a window to one of its dialog children */
146@@ -1033,6 +1052,7 @@
147 priv->last_top = 0;
148 priv->last_bottom = 0;
149
150+ priv->use_event = FALSE;
151 priv->pressed_entry = NULL;
152
153 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, "");
154@@ -1105,12 +1125,12 @@
155
156 void
157 panel_service_sync_geometry (PanelService *self,
158- const gchar *indicator_id,
159- const gchar *entry_id,
160- gint x,
161- gint y,
162- gint width,
163- gint height)
164+ const gchar *panel_id,
165+ const gchar *entry_id,
166+ gint x,
167+ gint y,
168+ gint width,
169+ gint height)
170 {
171 PanelServicePrivate *priv = self->priv;
172 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);
173@@ -1118,18 +1138,42 @@
174
175 if (entry)
176 {
177+ GHashTable *entry2geometry_hash = g_hash_table_lookup (priv->panel2entries_hash, panel_id);
178+
179 if (width < 0 || height < 0)
180 {
181- g_hash_table_remove (priv->entry2geometry_hash, entry);
182+ if (entry2geometry_hash)
183+ {
184+ if (g_hash_table_size (entry2geometry_hash) > 1)
185+ {
186+ g_hash_table_remove (entry2geometry_hash, entry);
187+ }
188+ else
189+ {
190+ g_hash_table_remove (priv->panel2entries_hash, panel_id);
191+ }
192+ }
193 }
194 else
195 {
196- GdkRectangle *geo = g_hash_table_lookup (priv->entry2geometry_hash, entry);
197+ GdkRectangle *geo = NULL;
198+
199+ if (entry2geometry_hash == NULL)
200+ {
201+ entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
202+ g_free, g_free);
203+ g_hash_table_insert (priv->panel2entries_hash, g_strdup (panel_id),
204+ entry2geometry_hash);
205+ }
206+ else
207+ {
208+ geo = g_hash_table_lookup (entry2geometry_hash, entry);
209+ }
210
211 if (geo == NULL)
212 {
213 geo = g_new (GdkRectangle, 1);
214- g_hash_table_insert (priv->entry2geometry_hash, entry, geo);
215+ g_hash_table_insert (entry2geometry_hash, entry, geo);
216 }
217
218 geo->x = x;

Subscribers

People subscribed via source and target branches