@@ -8,16 +8,23 @@ public class Gala.CloseButton : Clutter.Actor {
88 private static Gee . HashMap<int, Gdk . Pixbuf ? > close_pixbufs;
99
1010 public signal void triggered (uint32 timestamp );
11- public float scale { get ; construct set ; }
11+
12+ private float _monitor_scale = 1.0f ;
13+ public float monitor_scale {
14+ get {
15+ return _monitor_scale;
16+ }
17+ set {
18+ _monitor_scale = value ;
19+
20+ load_pixbuf ();
21+ }
22+ }
1223
1324 // used to avoid changing hitbox of the button
1425 private Clutter . Actor pixbuf_actor;
1526 private bool is_pressed = false ;
1627
17- public CloseButton (float scale) {
18- Object (scale: scale);
19- }
20-
2128 static construct {
2229 close_pixbufs = new Gee .HashMap<int, Gdk . Pixbuf ?> ();
2330 }
@@ -30,23 +37,23 @@ public class Gala.CloseButton : Clutter.Actor {
3037 };
3138 add_child (pixbuf_actor);
3239
33- var pixbuf = get_close_button_pixbuf (scale);
40+ load_pixbuf ();
41+ }
42+
43+ private void load_pixbuf () {
44+ var pixbuf = get_close_button_pixbuf (monitor_scale);
3445 if (pixbuf != null ) {
35- try {
36- var image = new Gala .Image .from_pixbuf (pixbuf);
37- pixbuf_actor. set_content (image);
38- pixbuf_actor. set_size (pixbuf. width, pixbuf. height);
39- set_size (pixbuf. width, pixbuf. height);
40- } catch (Error e) {
41- create_error_texture ();
42- }
46+ var image = new Gala .Image .from_pixbuf (pixbuf);
47+ pixbuf_actor. set_content (image);
48+ pixbuf_actor. set_size (pixbuf. width, pixbuf. height);
49+ set_size (pixbuf. width, pixbuf. height);
4350 } else {
4451 create_error_texture ();
4552 }
4653 }
4754
48- private static Gdk . Pixbuf ? get_close_button_pixbuf (float scale ) {
49- var height = Utils . scale_to_int (36 , scale );
55+ private static Gdk .Pixbuf ? get_close_button_pixbuf (float monitor_scale ) {
56+ var height = Utils . scale_to_int (36 , monitor_scale );
5057
5158 if (close_pixbufs[height] == null ) {
5259 try {
@@ -71,7 +78,7 @@ public class Gala.CloseButton : Clutter.Actor {
7178 // works as good as some weird fallback-image-failed-to-load pixbuf
7279 critical (" Could not create close button" );
7380
74- var size = Utils . scale_to_int (36 , scale );
81+ var size = Utils . scale_to_int (36 , monitor_scale );
7582 pixbuf_actor. set_size (size, size);
7683 pixbuf_actor. background_color = { 255 , 0 , 0 , 255 };
7784 }
0 commit comments