Skip to content

Commit f323658

Browse files
committed
Change the way we deal with icon clipping
1 parent edf7828 commit f323658

7 files changed

Lines changed: 35 additions & 19 deletions

File tree

data/Application.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0
3-
* SPDX-FileCopyrightText: 2023-2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-FileCopyrightText: 2023-2026 elementary, Inc. (https://elementary.io)
44
*/
55

66
dock {
@@ -32,8 +32,9 @@ dock-window:not(.reduce-transparency) separator.vertical {
3232
border-right-color: alpha(@highlight_color, 0.15);
3333
}
3434

35-
dock-window {
36-
margin-top: 64px; /* Keep enough room so that icons don't clip when bouncing */
35+
/* Keep enough room so that icons don't clip when bouncing */
36+
top-margin {
37+
min-height: 64px;
3738
}
3839

3940
bottom-margin {

src/BaseItem.vala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0
3-
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-FileCopyrightText: 2025-2026 elementary, Inc. (https://elementary.io)
44
*/
55

66
public class Dock.BaseItem : Gtk.Box {
@@ -94,6 +94,7 @@ public class Dock.BaseItem : Gtk.Box {
9494
child = overlay
9595
};
9696

97+
append (new TopMargin ());
9798
append (bin);
9899
append (new BottomMargin ());
99100

@@ -137,7 +138,7 @@ public class Dock.BaseItem : Gtk.Box {
137138
Granite.TRANSITION_DURATION_OPEN,
138139
new Adw.CallbackAnimationTarget ((val) => {
139140
bin.allocate (icon_size, icon_size, -1,
140-
new Gsk.Transform ().translate (Graphene.Point () { y = (float) val }
141+
new Gsk.Transform ().translate (Graphene.Point () { y = TopMargin.SIZE + (float) val }
141142
));
142143
})
143144
);

src/BottomMargin.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0
3-
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-FileCopyrightText: 2025-2026 elementary, Inc. (https://elementary.io)
44
*/
55

6-
public class BottomMargin : Gtk.Widget {
6+
public class Dock.BottomMargin : Gtk.Widget {
77
private static GLib.List<unowned BottomMargin> instances = new GLib.List<unowned BottomMargin> ();
88

99
class construct {

src/ItemManager.vala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0
3-
* SPDX-FileCopyrightText: 2023-2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-FileCopyrightText: 2023-2026 elementary, Inc. (https://elementary.io)
44
*/
55

66
public class Dock.ItemManager : Gtk.Box {
77
private static Settings settings;
88

99
public Launcher? added_launcher { get; set; default = null; }
1010

11-
private DynamicWorkspaceIcon dynamic_workspace_item;
12-
1311
#if WORKSPACE_SWITCHER
1412
private Gtk.Separator separator;
13+
private DynamicWorkspaceIcon dynamic_workspace_item;
1514
#endif
1615

1716
static construct {
@@ -25,19 +24,23 @@
2524
var background_group = new ItemGroup (background_item.group_model, (obj) => (BackgroundItem) obj);
2625

2726
#if WORKSPACE_SWITCHER
28-
dynamic_workspace_item = new DynamicWorkspaceIcon ();
29-
3027
separator = new Gtk.Separator (VERTICAL) {
3128
valign = START,
3229
margin_top = Launcher.PADDING,
3330
};
3431
settings.bind ("icon-size", separator, "height-request", GET);
32+
33+
var separator_box = new Gtk.Box (VERTICAL, 0);
34+
separator_box.append (new TopMargin ());
35+
separator_box.append (separator);
36+
37+
dynamic_workspace_item = new DynamicWorkspaceIcon ();
3538
#endif
3639

3740
append (app_group);
3841
append (background_group);
3942
#if WORKSPACE_SWITCHER
40-
append (separator);
43+
append (separator_box);
4144
append (new ItemGroup (WorkspaceSystem.get_default ().workspaces, (obj) => new WorkspaceIconGroup ((Workspace) obj)));
4245
append (dynamic_workspace_item);
4346
#endif

src/MainWindow.vala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0
3-
* SPDX-FileCopyrightText: 2022-2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-FileCopyrightText: 2022-2026 elementary, Inc. (https://elementary.io)
44
*/
55

66
public class Dock.MainWindow : Gtk.ApplicationWindow {
@@ -14,9 +14,6 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
1414
}
1515
}
1616

17-
// Matches top margin in Launcher.css
18-
private const int TOP_MARGIN = 64;
19-
2017
private Settings transparency_settings;
2118
private static Settings settings = new Settings ("io.elementary.dock");
2219

@@ -38,6 +35,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
3835
titlebar = new Gtk.Label ("") { visible = false };
3936

4037
var dock_box = new Gtk.Box (VERTICAL, 0);
38+
dock_box.append (new TopMargin ());
4139
dock_box.append (new Container ());
4240
dock_box.append (new BottomMargin ());
4341

@@ -115,7 +113,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
115113
// bouncing isn't added by default and instead counts to the frame
116114
var item_manager_width = item_manager.get_width ();
117115
var shadow_size = (surface.width - item_manager_width) / 2;
118-
var top_margin = TOP_MARGIN + shadow_size - 1;
116+
var top_margin = TopMargin.SIZE + shadow_size - 1;
119117
size.set_shadow_width (shadow_size, shadow_size, top_margin, shadow_size);
120118
});
121119

@@ -124,7 +122,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
124122
// and it still gets window events
125123
var item_manager_width = item_manager.get_width ();
126124
var shadow_size = (width - item_manager_width) / 2;
127-
var top_margin = TOP_MARGIN + shadow_size;
125+
var top_margin = TopMargin.SIZE + shadow_size;
128126
surface.set_input_region (new Cairo.Region.rectangle ({
129127
shadow_size,
130128
top_margin,

src/TopMargin.vala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0
3+
* SPDX-FileCopyrightText: 2026 elementary, Inc. (https://elementary.io)
4+
*/
5+
6+
public class Dock.TopMargin : Gtk.Widget {
7+
public const int SIZE = 64;
8+
9+
construct {
10+
height_request = SIZE;
11+
}
12+
}

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sources = [
88
'ItemManager.vala',
99
'MainWindow.vala',
1010
'RenderNodeWalker.vala',
11+
'TopMargin.vala',
1112
'AppSystem' / 'App.vala',
1213
'AppSystem' / 'AppSystem.vala',
1314
'AppSystem' / 'Launcher.vala',

0 commit comments

Comments
 (0)