Merge lp:~marcus-lundgren/granite/fix-1015042 into lp:~elementary-pantheon/granite/granite

Proposed by Marcus Lundgren
Status: Merged
Merged at revision: 278
Proposed branch: lp:~marcus-lundgren/granite/fix-1015042
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 132 lines (+28/-51)
1 file modified
lib/Widgets/PopOver.vala (+28/-51)
To merge this branch: bzr merge lp:~marcus-lundgren/granite/fix-1015042
Reviewer Review Type Date Requested Status
Andrea Basso (community) Approve
Tom Beckmann (community) Approve
Review via email: mp+111110@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tom Beckmann (tombeckmann) wrote :

As we discussed, dropping that check is fine, although it may hurt those people who don't use a composited environment. Hopefully there'll be a better fix at some point, but that's fine for now. Thanks :)

review: Approve
Revision history for this message
Andrea Basso (voluntatefaber) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/PopOver.vala'
2--- lib/Widgets/PopOver.vala 2012-06-16 14:07:32 +0000
3+++ lib/Widgets/PopOver.vala 2012-06-19 21:50:33 +0000
4@@ -46,7 +46,6 @@
5 protected Gtk.Border PADDINGS;
6 double offset = 15.0;
7 const int MARGIN = 12;
8- new bool is_composited;
9 Gtk.Widget menu;
10 static Gtk.CssProvider style_provider;
11 Gtk.Box hbox;
12@@ -104,26 +103,21 @@
13 }
14
15 construct {
16-
17- /* Are we composited? */
18- is_composited = Gdk.Screen.get_default ().is_composited ();
19-
20- if(is_composited) {
21- // Set up css provider
22- style_provider = new Gtk.CssProvider ();
23- try {
24- style_provider.load_from_data (POPOVER_STYLESHEET, -1);
25- } catch (Error e) {
26- warning ("GranitePopOver: %s. The widget will not look as intended.", e.message);
27- }
28-
29- // Window properties
30- set_visual (get_screen ().get_rgba_visual());
31-
32- get_style_context ().add_class ("popover");
33- get_style_context ().add_class ("composited");
34- get_style_context ().add_provider_for_screen (get_screen(), style_provider, 600);
35+ // Set up css provider
36+ style_provider = new Gtk.CssProvider ();
37+ try {
38+ style_provider.load_from_data (POPOVER_STYLESHEET, -1);
39+ } catch (Error e) {
40+ warning ("GranitePopOver: %s. The widget will not look as intended.", e.message);
41 }
42+
43+ // Window properties
44+ set_visual (get_screen ().get_rgba_visual());
45+
46+ get_style_context ().add_class ("popover");
47+ get_style_context ().add_class ("composited");
48+ get_style_context ().add_provider_for_screen (get_screen(), style_provider, 600);
49+
50 app_paintable = true;
51 decorated = false;
52 resizable = false;
53@@ -147,9 +141,7 @@
54 style_get ("border-radius", out BORDER_RADIUS, "border-width", out BORDER_WIDTH,
55 "shadow-size", out SHADOW_SIZE, "arrow-height", out ARROW_HEIGHT,
56 "arrow_width", out ARROW_WIDTH, null);
57- if (!is_composited) {
58- SHADOW_SIZE = 0; /* we don't need an extra space for the shadow since we won't show it */
59- }
60+
61 PADDINGS = get_style_context ().get_margin (Gtk.StateFlags.NORMAL);
62 hbox.set_margin_top(PADDINGS.top + ARROW_HEIGHT + SHADOW_SIZE + 5);
63 hbox.set_margin_left(PADDINGS.left + SHADOW_SIZE + 5);
64@@ -269,15 +261,13 @@
65 if(old_pos != pos) {
66 compute_shadow (get_allocated_width (), get_allocated_height ());
67 }
68- if(is_composited) {
69- var w = get_allocated_width ();
70- var h = get_allocated_height ();
71- h -= 2* (PADDINGS.top + SHADOW_SIZE) + ARROW_HEIGHT;
72- w -= 2*(PADDINGS.right + SHADOW_SIZE);
73- get_window ().input_shape_combine_region (new Cairo.Region.rectangle({0, 0, w, h}),
74- PADDINGS.right + SHADOW_SIZE,
75- PADDINGS.top + SHADOW_SIZE + (arrow_up ? ARROW_HEIGHT : 0));
76- }
77+ var w = get_allocated_width ();
78+ var h = get_allocated_height ();
79+ h -= 2* (PADDINGS.top + SHADOW_SIZE) + ARROW_HEIGHT;
80+ w -= 2*(PADDINGS.right + SHADOW_SIZE);
81+ get_window ().input_shape_combine_region (new Cairo.Region.rectangle({0, 0, w, h}),
82+ PADDINGS.right + SHADOW_SIZE,
83+ PADDINGS.top + SHADOW_SIZE + (arrow_up ? ARROW_HEIGHT : 0));
84 }
85
86 int win_x;
87@@ -390,9 +380,6 @@
88 int old_h = 0;
89
90 void compute_shadow (int w, int h) {
91- if(!is_composited) {
92- return;
93- }
94 main_buffer = new Granite.Drawing.BufferSurface (w, h);
95
96 // Shadow first
97@@ -405,12 +392,10 @@
98 // Background
99 main_buffer.context.clip ();
100 Gtk.render_background (menu.get_style_context (), main_buffer.context, 0, 0, w, h);
101- if(is_composited) {
102- if(get_window () != null)
103- get_window ().input_shape_combine_region (new Cairo.Region.rectangle({0, 0, w - 2*(PADDINGS.right + SHADOW_SIZE), h - 2*(PADDINGS.top + SHADOW_SIZE) - ARROW_HEIGHT}),
104- PADDINGS.right + SHADOW_SIZE,
105- PADDINGS.top + SHADOW_SIZE + (arrow_up ? ARROW_HEIGHT : 0));
106- }
107+ if(get_window () != null)
108+ get_window ().input_shape_combine_region (new Cairo.Region.rectangle({0, 0, w - 2*(PADDINGS.right + SHADOW_SIZE), h - 2*(PADDINGS.top + SHADOW_SIZE) - ARROW_HEIGHT}),
109+ PADDINGS.right + SHADOW_SIZE,
110+ PADDINGS.top + SHADOW_SIZE + (arrow_up ? ARROW_HEIGHT : 0));
111
112 // Outer border
113 main_buffer.context.reset_clip ();
114@@ -437,16 +422,8 @@
115
116 public override bool draw(Cairo.Context cr)
117 {
118- if (is_composited) {
119- cr.set_source_surface(main_buffer.surface, 0, 0);
120- cr.paint_with_alpha(1.0);
121- }
122- else {
123- cr.rectangle (BORDER_WIDTH / 2.0, BORDER_WIDTH / 2.0, get_allocated_width () - BORDER_WIDTH, get_allocated_height () - BORDER_WIDTH);
124- Gdk.cairo_set_source_rgba (cr, get_style_context ().get_border_color (Gtk.StateFlags.NORMAL));
125- cr.set_line_width (BORDER_WIDTH);
126- cr.stroke ();
127- }
128+ cr.set_source_surface(main_buffer.surface, 0, 0);
129+ cr.paint_with_alpha(1.0);
130 return base.draw(cr);
131 }
132 }

Subscribers

People subscribed via source and target branches