Skip to content

Commit 0cbe479

Browse files
committed
Cleanup and support CENTERED
1 parent ef0251e commit 0cbe479

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

background/Background.vala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,21 @@ public interface Gala.Background.Background : Object, Gdk.Paintable {
135135

136136
switch (style) {
137137
case ZOOM:
138-
var x_scale = (float) width / texture.get_width ();
139-
var y_scale = (float) height / texture.get_height ();
138+
var x_scale = (float) width / texture.width;
139+
var y_scale = (float) height / texture.height;
140140
if (x_scale > y_scale) {
141-
snapshot.translate ({0, (float) (height - texture.get_height () * x_scale) / 2});
141+
snapshot.translate ({0, (float) (height - texture.width * x_scale) / 2});
142142
snapshot.scale (x_scale, x_scale);
143143
} else {
144-
snapshot.translate ({(float) (width - (texture.get_width () * y_scale)) / 2, 0});
144+
snapshot.translate ({(float) (width - (texture.width * y_scale)) / 2, 0});
145145
snapshot.scale (y_scale, y_scale);
146146
}
147-
texture.snapshot (snapshot, texture.get_width (), texture.get_height ());
147+
texture.snapshot (snapshot, texture.width, texture.height);
148+
break;
149+
150+
case CENTERED:
151+
snapshot.translate ({(float) (width - texture.width) / 2, (float) (height - texture.height) / 2});
152+
texture.snapshot (snapshot, texture.width, texture.height);
148153
break;
149154

150155
default:

0 commit comments

Comments
 (0)