Merge lp:~donadigo/pantheon-greeter/fix-black-bars into lp:~elementary-pantheon/pantheon-greeter/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Danielle Foré
Approved revision: 459
Merged at revision: 458
Proposed branch: lp:~donadigo/pantheon-greeter/fix-black-bars
Merge into: lp:~elementary-pantheon/pantheon-greeter/trunk
Diff against target: 83 lines (+18/-37)
1 file modified
src/Wallpaper.vala (+18/-37)
To merge this branch: bzr merge lp:~donadigo/pantheon-greeter/fix-black-bars
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+297404@code.launchpad.net

Commit message

* Fix black bars appearing to users on login screen.

Description of the change

Fixes black bars appearing to users on login screen.

This branch uses the Ubuntu's Unity Greeter algorithm that is easier to understand and also fixes the problem with black bars.

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Looks good! Thanks :D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Wallpaper.vala'
--- src/Wallpaper.vala 2016-06-14 12:38:50 +0000
+++ src/Wallpaper.vala 2016-06-14 21:40:30 +0000
@@ -98,15 +98,17 @@
98 cache_path += path;98 cache_path += path;
99 cache_pixbuf += buf;99 cache_pixbuf += buf;
100 background_pixbuf = buf;100 background_pixbuf = buf;
101 } else {
102 buf = validate_pixbuf (buf);
101 }103 }
102 //check if the currently loaded wallpaper is the one we loaded in this method104
105 // check if the currently loaded wallpaper is the one we loaded in this method
103 if (last_loaded != path) {106 if (last_loaded != path) {
104 return; //if not, abort107 return; //if not, abort
105 }108 }
106109
107 var new_wallpaper = make_image ();110 var new_wallpaper = make_image ();
108 new_wallpaper.pixbuf = buf;111 new_wallpaper.pixbuf = buf;
109 resize (new_wallpaper);
110 stack.add (new_wallpaper);112 stack.add (new_wallpaper);
111 stack.show_all ();113 stack.show_all ();
112 stack.visible_child = new_wallpaper;114 stack.visible_child = new_wallpaper;
@@ -178,45 +180,24 @@
178 * screen size to save memory.180 * screen size to save memory.
179 */181 */
180 Gdk.Pixbuf validate_pixbuf (Gdk.Pixbuf pixbuf) {182 Gdk.Pixbuf validate_pixbuf (Gdk.Pixbuf pixbuf) {
181 var result = scale_to_rect (pixbuf, gpu_limit, gpu_limit);183 return scale_to_rect (pixbuf, screen_width, screen_height);
182 result = scale_to_rect (pixbuf, screen_width, screen_height);
183 return result;
184 }184 }
185185
186 Gdk.Pixbuf scale_to_rect (Gdk.Pixbuf pixbuf, int rect_width, int rect_height) {186 Gdk.Pixbuf scale_to_rect (Gdk.Pixbuf pixbuf, int rect_width, int rect_height) {
187 int height = pixbuf.height;187 double target_aspect = (double) rect_width / rect_height;
188 int width = pixbuf.width;188 double aspect = (double) pixbuf.width / pixbuf.height;
189189 double scale, offset_x = 0, offset_y = 0;
190 if (height > rect_height || width > rect_width) {190 if (aspect > target_aspect) {
191 float hw = (float)height / width * rect_width;191 scale = (double) rect_height / pixbuf.height;
192 float wh = (float)width / height * rect_height;192 offset_x = (pixbuf.width * scale - rect_width) / 2;
193 if (height < width) {
194 return pixbuf.scale_simple (rect_width, (int) (hw), Gdk.InterpType.BILINEAR);
195 } else {
196 return pixbuf.scale_simple ((int) (wh), rect_height, Gdk.InterpType.BILINEAR);
197 }
198 }
199 return pixbuf;
200 }
201
202 void resize (Gtk.Image image) {
203 int w, h;
204
205 w = image.width_request;
206 h = image.height_request;
207
208
209 if (width > (w * height) / h) {
210 image.width_request = (int) width;
211 image.height_request = (int) (h * width / w);
212
213 if (height > image.height_request) {
214 image.height_request = (int) height;
215 image.width_request = (int) (w * height / h);
216 }
217 } else {193 } else {
218 image.height_request = (int) height;194 scale = (double) rect_width / pixbuf.width;
219 image.width_request = (int) (w * height / h);195 offset_y = (pixbuf.height * scale - rect_height) / 2;
220 }196 }
197
198 var scaled_pixbuf = new Gdk.Pixbuf (pixbuf.colorspace, pixbuf.has_alpha, pixbuf.bits_per_sample, rect_width, rect_height);
199 pixbuf.scale (scaled_pixbuf, 0, 0, rect_width, rect_height, -offset_x, -offset_y, scale, scale, Gdk.InterpType.BILINEAR);
200
201 return scaled_pixbuf;
221 }202 }
222}203}

Subscribers

People subscribed via source and target branches