Skip to content

Commit d16513a

Browse files
committed
It's working!
1 parent a2c78e0 commit d16513a

File tree

4 files changed

+42
-46
lines changed

4 files changed

+42
-46
lines changed

src/BaseItem.vala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public class Dock.BaseItem : Gtk.Box {
107107

108108
append (bin);
109109
append (running_revealer);
110+
append (new BottomMargin ());
110111

111112
icon_size = dock_settings.get_int ("icon-size");
112113
dock_settings.changed["icon-size"].connect (() => {

src/BottomMargin.vala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0
3+
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
4+
*/
5+
6+
public class BottomMargin : Gtk.Widget {
7+
private static GLib.List<unowned BottomMargin> instances = new GLib.List<unowned BottomMargin> ();
8+
9+
class construct {
10+
set_css_name ("bottom-margin");
11+
}
12+
13+
construct {
14+
instances.append (this);
15+
}
16+
17+
~BottomMargin () {
18+
instances.remove (this);
19+
}
20+
21+
public new static int get_size () {
22+
foreach (var instance in instances) {
23+
if (instance.get_realized ()) {
24+
return instance.get_height ();
25+
}
26+
}
27+
28+
return 0;
29+
}
30+
}

src/MainWindow.vala

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,12 @@
55

66
public class Dock.MainWindow : Gtk.ApplicationWindow {
77
private class Container : Gtk.Widget {
8-
private Settings settings = new Settings ("io.elementary.dock");
9-
108
class construct {
119
set_css_name ("dock");
1210
}
1311

1412
construct {
15-
height_request = ItemManager.get_launcher_size ();
16-
settings.changed["icon-size"].connect (() => {
17-
height_request = ItemManager.get_launcher_size ();
18-
});
19-
}
20-
}
21-
22-
private class BottomMargin : Gtk.Widget {
23-
private static BottomMargin? first_instance;
24-
25-
class construct {
26-
set_css_name ("bottom-margin");
27-
}
28-
29-
construct {
30-
if (first_instance == null) {
31-
first_instance = this;
32-
}
33-
}
34-
35-
public new static int get_size () {
36-
if (first_instance == null) {
37-
return 0;
38-
}
39-
40-
Graphene.Rect bounds;
41-
first_instance.compute_bounds (first_instance, out bounds);
42-
43-
return (int) bounds.get_height ();
44-
}
45-
}
46-
47-
private class DockBox : Gtk.Box {
48-
construct {
49-
orientation = VERTICAL;
50-
append (new Container ());
51-
append (new BottomMargin ());
13+
vexpand = true;
5214
}
5315
}
5416

@@ -64,27 +26,32 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
6426

6527
private WindowDragManager window_drag_manager;
6628
private bool initialized_blur = false;
67-
private DockBox dock_box;
6829

6930
class construct {
7031
set_css_name ("dock-window");
7132
}
7233

7334
construct {
74-
var launcher_manager = ItemManager.get_default ();
75-
7635
overflow = VISIBLE;
7736
resizable = false;
7837
titlebar = new Gtk.Label ("") { visible = false };
7938

80-
dock_box = new DockBox ();
39+
var dock_box = new Gtk.Box (VERTICAL, 0);
40+
dock_box.append (new Container ());
41+
dock_box.append (new BottomMargin ());
42+
43+
unowned var launcher_manager = ItemManager.get_default ();
8144

8245
// Don't clip launchers to dock background https://github.com/elementary/dock/issues/275
8346
var overlay = new Gtk.Overlay () {
8447
child = dock_box
8548
};
8649
overlay.add_overlay (launcher_manager);
8750

51+
var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH);
52+
size_group.add_widget (dock_box);
53+
size_group.add_widget (launcher_manager);
54+
8855
child = overlay;
8956

9057
remove_css_class ("background");
@@ -155,9 +122,6 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
155122
unowned var item_manager = ItemManager.get_default ();
156123
var item_manager_width = item_manager.get_width ();
157124

158-
dock_box.width_request = item_manager_width;
159-
item_manager.height_request = dock_box.get_height ();
160-
161125
// manually set input region since container's shadow are is the content of the window
162126
// and it still gets window events
163127
var shadow_size = (width - item_manager_width) / 2;

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ sources = [
22
'Application.vala',
33
'BaseIconGroup.vala',
44
'BaseItem.vala',
5+
'BottomMargin.vala',
56
'ItemManager.vala',
67
'MainWindow.vala',
78
'AppSystem' / 'App.vala',

0 commit comments

Comments
 (0)