@@ -31,7 +31,6 @@ public abstract class Gala.AbstractSwitcher : CanvasActor {
3131 style_manager = Drawing . StyleManager . get_instance ();
3232
3333 container = new Clutter .Actor () {
34- reactive = true ,
3534#if HAS_MUTTER46
3635 layout_manager = new Clutter .FlowLayout (Clutter . Orientation . HORIZONTAL )
3736#else
@@ -89,24 +88,35 @@ public abstract class Gala.AbstractSwitcher : CanvasActor {
8988 caption. margin_bottom = margin;
9089 }
9190
92- protected override void get_preferred_width (float for_height , out float min_width , out float natural_width ) {
93- min_width = 0 ;
94-
95- float preferred_nat_width;
96- base . get_preferred_width (for_height, null , out preferred_nat_width);
97-
91+ public override void allocate (Clutter .ActorBox box ) {
9892 unowned var display = wm. get_display ();
9993 var geom = display. get_monitor_geometry (display. get_current_monitor ());
10094
101- float container_nat_width ;
102- container. get_preferred_size ( null , null , out container_nat_width, null );
95+ float nat_container_width ;
96+ container. get_preferred_width ( - 1 , null , out nat_container_width );
10397
104- var max_width = float . min (
105- geom. width - Utils . scale_to_int (MIN_OFFSET * 2 , monitor_scale), // Don't overflow the monitor
106- container_nat_width // Ellipsize the label if it's longer than the icons
107- );
98+ var max_width = geom. width - Utils . scale_to_int (MIN_OFFSET * 2 , monitor_scale);
99+ var real_width = (int ) float . min (nat_container_width, max_width);
100+
101+ float nat_container_height;
102+ container. get_preferred_height (real_width, null , out nat_container_height);
103+
104+ float nat_caption_height;
105+ caption. get_preferred_height (real_width, null , out nat_caption_height);
106+
107+ var horizontal_margin = (geom. width - real_width) / 2 ;
108+
109+ var children_height = nat_container_height + nat_caption_height;
110+ var vertical_margin = (geom. height - children_height) / 2 ;
111+
112+ box = {
113+ geom. x + horizontal_margin,
114+ geom. y + vertical_margin,
115+ geom. width - horizontal_margin,
116+ geom. height - vertical_margin
117+ };
108118
109- natural_width = float . min (max_width, preferred_nat_width );
119+ base . allocate (box );
110120 }
111121
112122 protected override void draw (Cairo .Context ctx , int width , int height ) {
0 commit comments