Merge lp:~elementary-dev-community/wingpanel/bug-fix-1007630 into lp:~elementary-pantheon/wingpanel/old-trunk

Proposed by Albert
Status: Merged
Approved by: Daniel Fore
Approved revision: 151
Merged at revision: 155
Proposed branch: lp:~elementary-dev-community/wingpanel/bug-fix-1007630
Merge into: lp:~elementary-pantheon/wingpanel/old-trunk
Diff against target: 168 lines (+74/-48)
1 file modified
src/Indicator/IndicatorObjectEntry.vala (+74/-48)
To merge this branch: bzr merge lp:~elementary-dev-community/wingpanel/bug-fix-1007630
Reviewer Review Type Date Requested Status
Daniel Fore Approve
David Gomes (community) Approve
Review via email: mp+181999@code.launchpad.net

Commit message

Fixed the arrow not well positioned after changing the contents of the indicator, adding a repaint after "configure_event" signal.

Description of the change

Fixed the arrow not well positioned after changing the contents of the indicator, adding a repaint after "configure_event" signal.

This is how it looks on released version of elementary OS Luna:

https://www.dropbox.com/s/66jmohecrhwy5vs/luna_released_bug.mp4

This is how it looks with this fix:

https://www.dropbox.com/s/g63yurmg2izuxyq/luna_proposed_fix.mp4

To post a comment you must log in.
151. By Albert

Fixed conflicts

Revision history for this message
Erasmo Marín (erasmo-marin) wrote :

It segfaults to me (stable luna)

wingpanel
[_LOG_LEVEL_INFO 20:57:38.238671] Application.vala:77: Wingpanel version: 0.2.4
[_LOG_LEVEL_INFO 20:57:38.238845] Application.vala:79: Kernel version: 3.8.0-27-generic
[_LOG_LEVEL_WARN 20:57:38.424913] IndicatorFileModel.vala:60: SKIP LOADING: libappmenu.so
[_LOG_LEVEL_FATAL 20:57:38.428324] [GLib-GObject] g_object_set: assertion `G_IS_OBJECT (object)' failed
[_LOG_LEVEL_FATAL 20:57:38.428367] Wingpanel will not function properly.
[_LOG_LEVEL_FATAL 20:57:38.439736] IndicatorFileModel.vala:91: Unable to load /usr/lib/indicators3/7/libindicator-terminal.so
[_LOG_LEVEL_FATAL 20:57:38.439786] Wingpanel will not function properly.
[_LOG_LEVEL_WARN 20:57:38.439863] [GLib-GObject] invalid unclassed pointer in cast to `GObject'
[_LOG_LEVEL_FATAL 20:57:38.439930] [GLib-GObject] g_object_steal_data: assertion `G_IS_OBJECT (object)' failed
[_LOG_LEVEL_FATAL 20:57:38.439962] Wingpanel will not function properly.
[_LOG_LEVEL_WARN 20:57:38.439997] [GLib-GObject] invalid unclassed pointer in cast to `GObject'
[_LOG_LEVEL_FATAL 20:57:38.440030] [GLib-GObject] g_object_steal_data: assertion `G_IS_OBJECT (object)' failed
[_LOG_LEVEL_FATAL 20:57:38.440062] Wingpanel will not function properly.
[_LOG_LEVEL_FATAL 20:57:38.440623] IndicatorFileModel.vala:91: Unable to load /usr/lib/indicators3/7/libapplication.so
[_LOG_LEVEL_FATAL 20:57:38.440662] Wingpanel will not function properly.
[_LOG_LEVEL_FATAL 20:57:38.443748] IndicatorFileModel.vala:91: Unable to load /usr/lib/indicators3/7/libdatetime.so
[_LOG_LEVEL_FATAL 20:57:38.443820] Wingpanel will not function properly.
[_LOG_LEVEL_WARN 20:57:38.444045] [Gtk] A floating object was finalized. This means that someonecalled g_object_unref() on an object that had only a floatingreference; the initial floating reference is not owned by anyoneand must be removed with g_object_ref_sink().
[_LOG_LEVEL_WARN 20:57:38.454013] [libindicator] IndicatorObject class does not create a menu. We need one of those.
Violación de segmento

Revision history for this message
Cody Garver (codygarver) wrote :

Compile with valac-0.16 only

Sent from my iPhone

On Aug 25, 2013, at 8:01 PM, "Erasmo Marín" <email address hidden> wrote:

> It segfaults to me (stable luna)
>
> wingpanel
> [_LOG_LEVEL_INFO 20:57:38.238671] Application.vala:77: Wingpanel version: 0.2.4
> [_LOG_LEVEL_INFO 20:57:38.238845] Application.vala:79: Kernel version: 3.8.0-27-generic
> [_LOG_LEVEL_WARN 20:57:38.424913] IndicatorFileModel.vala:60: SKIP LOADING: libappmenu.so
> [_LOG_LEVEL_FATAL 20:57:38.428324] [GLib-GObject] g_object_set: assertion `G_IS_OBJECT (object)' failed
> [_LOG_LEVEL_FATAL 20:57:38.428367] Wingpanel will not function properly.
> [_LOG_LEVEL_FATAL 20:57:38.439736] IndicatorFileModel.vala:91: Unable to load /usr/lib/indicators3/7/libindicator-terminal.so
> [_LOG_LEVEL_FATAL 20:57:38.439786] Wingpanel will not function properly.
> [_LOG_LEVEL_WARN 20:57:38.439863] [GLib-GObject] invalid unclassed pointer in cast to `GObject'
> [_LOG_LEVEL_FATAL 20:57:38.439930] [GLib-GObject] g_object_steal_data: assertion `G_IS_OBJECT (object)' failed
> [_LOG_LEVEL_FATAL 20:57:38.439962] Wingpanel will not function properly.
> [_LOG_LEVEL_WARN 20:57:38.439997] [GLib-GObject] invalid unclassed pointer in cast to `GObject'
> [_LOG_LEVEL_FATAL 20:57:38.440030] [GLib-GObject] g_object_steal_data: assertion `G_IS_OBJECT (object)' failed
> [_LOG_LEVEL_FATAL 20:57:38.440062] Wingpanel will not function properly.
> [_LOG_LEVEL_FATAL 20:57:38.440623] IndicatorFileModel.vala:91: Unable to load /usr/lib/indicators3/7/libapplication.so
> [_LOG_LEVEL_FATAL 20:57:38.440662] Wingpanel will not function properly.
> [_LOG_LEVEL_FATAL 20:57:38.443748] IndicatorFileModel.vala:91: Unable to load /usr/lib/indicators3/7/libdatetime.so
> [_LOG_LEVEL_FATAL 20:57:38.443820] Wingpanel will not function properly.
> [_LOG_LEVEL_WARN 20:57:38.444045] [Gtk] A floating object was finalized. This means that someonecalled g_object_unref() on an object that had only a floatingreference; the initial floating reference is not owned by anyoneand must be removed with g_object_ref_sink().
> [_LOG_LEVEL_WARN 20:57:38.454013] [libindicator] IndicatorObject class does not create a menu. We need one of those.
> Violación de segmento
>
> --
> https://code.launchpad.net/~elementary-dev-community/wingpanel/bug-fix-1007630/+merge/181999
> Your team elementary Pantheon team is requested to review the proposed merge of lp:~elementary-dev-community/wingpanel/bug-fix-1007630 into lp:wingpanel.

Revision history for this message
Cameron Norman (cameronnemo) wrote :

Same as above for me.

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

How, o how many times shall I tell you to use elementary-test-merge for reproducible builds and testing, instead of doing everything manually? Are you not bored to do the download-compile-run cycles manually yet?

sudo apt-get install elementary-testing-scripts
elementary-test-merge https://code.launchpad.net/~elementary-dev-community/wingpanel/bug-fix-1007630/+merge/181999

And it compiles and installs. Please don't bother doing all this manually.

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

It does fix the bug for me.

Revision history for this message
Albert (optimisme) wrote :

I don't even know what "elementary-testing-scripts" are, can you document it properly at the developers website?

Revision history for this message
David Gomes (davidgomes) wrote :

So, tigrang's branch was Needs Fixing because designers don't want the arrows on the edge of the indicators. Therefore, this branch needs ~elementary-design input too. Personally, I think it's better to have them there than to have a buggy indicators experience. Still, it's up to them, since I approve the code (had already approved tigrang's).

review: Approve
Revision history for this message
David Gomes (davidgomes) wrote :

bazaar.launchpad.net/~elementary-dev-community/wingpanel/bug-fix-1007630/revision/150

I mean, I approved what tigrang did and now I also approve that.

Revision history for this message
Daniel Fore (danrabbit) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Indicator/IndicatorObjectEntry.vala'
2--- src/Indicator/IndicatorObjectEntry.vala 2013-08-19 19:12:24 +0000
3+++ src/Indicator/IndicatorObjectEntry.vala 2013-08-25 14:51:25 +0000
4@@ -27,8 +27,6 @@
5 // used for drawing
6 private Gtk.Window menu;
7 private Granite.Drawing.BufferSurface buffer;
8- private int w = -1;
9- private int h = -1;
10 private int arrow_height = 10;
11 private int arrow_width = 20;
12 private double x = 10.5;
13@@ -75,6 +73,9 @@
14
15 entry.menu.get_children ().foreach (setup_margin);
16 entry.menu.insert.connect (setup_margin);
17+
18+ entry.menu.set_redraw_on_allocate (true);
19+ entry.menu.configure_event.connect (entry_menu_configure_event_callback);
20 }
21
22 public IndicatorIface get_indicator () {
23@@ -113,39 +114,50 @@
24 menu_parent.app_paintable = true;
25 menu_parent.set_visual (Gdk.Screen.get_default ().get_rgba_visual ());
26
27+ menu_parent.set_redraw_on_allocate (true);
28+ menu_parent.configure_event.connect (entry_menu_parent_configure_event_callback);
29 menu_parent.draw.connect (entry_menu_parent_draw_callback);
30 }
31
32+ private bool entry_menu_configure_event_callback (Gdk.EventConfigure event) {
33+ entry.menu.queue_draw ();
34+ return false;
35+ }
36+
37+ private bool entry_menu_parent_configure_event_callback (Gdk.EventConfigure event) {
38+ var menu_parent = entry.menu.get_parent ();
39+ menu_parent.queue_draw ();
40+ return false;
41+ }
42+
43 private bool entry_menu_parent_draw_callback (Cairo.Context ctx) {
44- var new_w = entry.menu.get_parent ().get_allocated_width ();
45- var new_h = entry.menu.get_parent ().get_allocated_height ();
46-
47- if (new_w != w || new_h != h) {
48- w = new_w;
49- h = new_h;
50-
51- buffer = new Granite.Drawing.BufferSurface (w, h);
52- cairo_popover (w, h);
53-
54- var cr = buffer.context;
55-
56- // shadow
57- cr.set_source_rgba (0, 0, 0, 0.5);
58- cr.fill_preserve ();
59- buffer.exponential_blur (6);
60- cr.clip ();
61-
62- // background
63- menu.get_style_context ().render_background (cr, 0, 0, w, h);
64- cr.reset_clip ();
65-
66- // border
67- cairo_popover (w, h);
68- cr.set_operator (Cairo.Operator.SOURCE);
69- cr.set_line_width (1);
70- Gdk.cairo_set_source_rgba (cr, menu.get_style_context ().get_border_color (Gtk.StateFlags.NORMAL));
71- cr.stroke ();
72- }
73+ var menu_parent = entry.menu.get_parent ();
74+ int menu_width = menu_parent.get_allocated_width ();
75+ int menu_height = menu_parent.get_allocated_height ();
76+ int indicator_width = get_allocated_width ();
77+ int indicator_height = get_allocated_height ();
78+
79+ buffer = new Granite.Drawing.BufferSurface (menu_width, menu_height);
80+ cairo_popover (menu_width, menu_height, indicator_width, indicator_height);
81+
82+ var cr = buffer.context;
83+
84+ // shadow
85+ cr.set_source_rgba (0, 0, 0, 0.5);
86+ cr.fill_preserve ();
87+ buffer.exponential_blur (6);
88+ cr.clip ();
89+
90+ // background
91+ menu.get_style_context ().render_background (cr, 0, 0, menu_width, menu_height);
92+ cr.reset_clip ();
93+
94+ // border
95+ cairo_popover (menu_width, menu_height, indicator_width, indicator_height);
96+ cr.set_operator (Cairo.Operator.SOURCE);
97+ cr.set_line_width (1);
98+ Gdk.cairo_set_source_rgba (cr, menu.get_style_context ().get_border_color (Gtk.StateFlags.NORMAL));
99+ cr.stroke ();
100
101 // clear surface to transparent
102 ctx.set_operator (Cairo.Operator.SOURCE);
103@@ -159,34 +171,48 @@
104 return false;
105 }
106
107- private void cairo_popover (int w, int h) {
108- w = w - 20;
109- h = h - 20;
110-
111+ private void cairo_popover (int menu_width, int menu_height, int indicator_width, int indicator_height) {
112 // Get some nice pos for the arrow
113 var offs = 30;
114 int p_x;
115 int w_x;
116+ bool draw_tr_arc = true;
117+ bool draw_tl_arc = true;
118 Gtk.Allocation alloc;
119- this.get_window ().get_origin (out p_x, null);
120- this.get_allocation (out alloc);
121
122+ get_window ().get_origin (out p_x, null);
123+ get_allocation (out alloc);
124 entry.menu.get_window ().get_origin (out w_x, null);
125
126- offs = (p_x + alloc.x) - w_x + this.get_allocated_width () / 4;
127- if (offs + 50 > (w + 20))
128- offs = (w + 20) - 15 - arrow_width;
129- if (offs < 17)
130- offs = 17;
131-
132- buffer.context.arc (x + radius, y + arrow_height + radius, radius, Math.PI, Math.PI * 1.5);
133+ offs = (p_x + alloc.x) - w_x + (indicator_width / 2) - (arrow_width / 2);
134+
135+ if (offs > menu_width - 10 - arrow_width) {
136+ offs = menu_width - 10 - arrow_width;
137+ draw_tr_arc = false;
138+ }
139+
140+ if (offs < 10) {
141+ offs = 10;
142+ draw_tl_arc = false;
143+ }
144+
145+ menu_width -= 20;
146+ menu_height -= 20;
147+
148+ // Don't draw top left arc if arrow needs to be placed there
149+ if (draw_tl_arc)
150+ buffer.context.arc (x + radius, y + arrow_height + radius, radius, Math.PI, Math.PI * 1.5);
151+
152 buffer.context.line_to (offs, y + arrow_height);
153 buffer.context.rel_line_to (arrow_width / 2.0, -arrow_height);
154 buffer.context.rel_line_to (arrow_width / 2.0, arrow_height);
155- buffer.context.arc (x + w - radius, y + arrow_height + radius, radius, Math.PI * 1.5, Math.PI * 2.0);
156-
157- buffer.context.arc (x + w - radius, y + h - radius, radius, 0, Math.PI * 0.5);
158- buffer.context.arc (x + radius, y + h - radius, radius, Math.PI * 0.5, Math.PI);
159+
160+ // Don't draw top right arc if arrow needs to be placed there
161+ if (draw_tr_arc)
162+ buffer.context.arc (x + menu_width - radius, y + arrow_height + radius, radius, Math.PI * 1.5, Math.PI * 2.0);
163+
164+ buffer.context.arc (x + menu_width - radius, y + menu_height - radius, radius, 0, Math.PI * 0.5);
165+ buffer.context.arc (x + radius, y + menu_height - radius, radius, Math.PI * 0.5, Math.PI);
166
167 buffer.context.close_path ();
168 }

Subscribers

People subscribed via source and target branches