Skip to content

Commit 30d6eb7

Browse files
authored
Merge branch 'main' into leolost/gesture-controller-test-finalize
2 parents 7d40b08 + 6549b02 commit 30d6eb7

3 files changed

Lines changed: 24 additions & 26 deletions

File tree

lib/Widgets/AbstractSwitcher.vala

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

src/Widgets/WindowSwitcher/WindowSwitcher.vala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ public class Gala.WindowSwitcher : AbstractSwitcher, GestureTarget, RootTarget {
243243
return;
244244
}
245245

246-
//Although we are setting visible via the opacity notify handler anyway
247-
//we have to set it here manually otherwise the size gotten via get_preferred_size is wrong
248-
visible = true;
249-
250246
float width, height;
251247
get_preferred_size (null, null, out width, out height);
252248

src/WindowManager.vala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,14 +1351,6 @@ namespace Gala {
13511351
yield builder.run ();
13521352
break;
13531353

1354-
case Meta.WindowType.MENU:
1355-
case Meta.WindowType.DROPDOWN_MENU:
1356-
case Meta.WindowType.POPUP_MENU:
1357-
var builder = new TransitionBuilder (actor, AnimationDuration.MENU_MAP, EASE_OUT_QUAD);
1358-
builder.add_property_with_from ("opacity", 0U, 255U);
1359-
yield builder.run ();
1360-
break;
1361-
13621354
case Meta.WindowType.MODAL_DIALOG:
13631355
case Meta.WindowType.DIALOG:
13641356
dim_parent_window (window);

0 commit comments

Comments
 (0)