From f323658dc1f3e2efadc6170103ca46d44904cb5f Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 12 Aug 2026 19:44:57 +0300 Subject: [PATCH 1/5] Change the way we deal with icon clipping --- data/Application.css | 7 ++++--- src/BaseItem.vala | 5 +++-- src/BottomMargin.vala | 4 ++-- src/ItemManager.vala | 15 +++++++++------ src/MainWindow.vala | 10 ++++------ src/TopMargin.vala | 12 ++++++++++++ src/meson.build | 1 + 7 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 src/TopMargin.vala diff --git a/data/Application.css b/data/Application.css index bfd5c8a1..c19dff33 100644 --- a/data/Application.css +++ b/data/Application.css @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2023-2025 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2023-2026 elementary, Inc. (https://elementary.io) */ dock { @@ -32,8 +32,9 @@ dock-window:not(.reduce-transparency) separator.vertical { border-right-color: alpha(@highlight_color, 0.15); } -dock-window { - margin-top: 64px; /* Keep enough room so that icons don't clip when bouncing */ +/* Keep enough room so that icons don't clip when bouncing */ +top-margin { + min-height: 64px; } bottom-margin { diff --git a/src/BaseItem.vala b/src/BaseItem.vala index d27f212d..ce909373 100644 --- a/src/BaseItem.vala +++ b/src/BaseItem.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2025-2026 elementary, Inc. (https://elementary.io) */ public class Dock.BaseItem : Gtk.Box { @@ -94,6 +94,7 @@ public class Dock.BaseItem : Gtk.Box { child = overlay }; + append (new TopMargin ()); append (bin); append (new BottomMargin ()); @@ -137,7 +138,7 @@ public class Dock.BaseItem : Gtk.Box { Granite.TRANSITION_DURATION_OPEN, new Adw.CallbackAnimationTarget ((val) => { bin.allocate (icon_size, icon_size, -1, - new Gsk.Transform ().translate (Graphene.Point () { y = (float) val } + new Gsk.Transform ().translate (Graphene.Point () { y = TopMargin.SIZE + (float) val } )); }) ); diff --git a/src/BottomMargin.vala b/src/BottomMargin.vala index bf326ea0..89ed6f9a 100644 --- a/src/BottomMargin.vala +++ b/src/BottomMargin.vala @@ -1,9 +1,9 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2025-2026 elementary, Inc. (https://elementary.io) */ -public class BottomMargin : Gtk.Widget { +public class Dock.BottomMargin : Gtk.Widget { private static GLib.List instances = new GLib.List (); class construct { diff --git a/src/ItemManager.vala b/src/ItemManager.vala index 56408603..98c9fde5 100644 --- a/src/ItemManager.vala +++ b/src/ItemManager.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2023-2025 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2023-2026 elementary, Inc. (https://elementary.io) */ public class Dock.ItemManager : Gtk.Box { @@ -8,10 +8,9 @@ public Launcher? added_launcher { get; set; default = null; } - private DynamicWorkspaceIcon dynamic_workspace_item; - #if WORKSPACE_SWITCHER private Gtk.Separator separator; + private DynamicWorkspaceIcon dynamic_workspace_item; #endif static construct { @@ -25,19 +24,23 @@ var background_group = new ItemGroup (background_item.group_model, (obj) => (BackgroundItem) obj); #if WORKSPACE_SWITCHER - dynamic_workspace_item = new DynamicWorkspaceIcon (); - separator = new Gtk.Separator (VERTICAL) { valign = START, margin_top = Launcher.PADDING, }; settings.bind ("icon-size", separator, "height-request", GET); + + var separator_box = new Gtk.Box (VERTICAL, 0); + separator_box.append (new TopMargin ()); + separator_box.append (separator); + + dynamic_workspace_item = new DynamicWorkspaceIcon (); #endif append (app_group); append (background_group); #if WORKSPACE_SWITCHER - append (separator); + append (separator_box); append (new ItemGroup (WorkspaceSystem.get_default ().workspaces, (obj) => new WorkspaceIconGroup ((Workspace) obj))); append (dynamic_workspace_item); #endif diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 6642a679..f54a6dcc 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2022-2025 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2022-2026 elementary, Inc. (https://elementary.io) */ public class Dock.MainWindow : Gtk.ApplicationWindow { @@ -14,9 +14,6 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { } } - // Matches top margin in Launcher.css - private const int TOP_MARGIN = 64; - private Settings transparency_settings; private static Settings settings = new Settings ("io.elementary.dock"); @@ -38,6 +35,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { titlebar = new Gtk.Label ("") { visible = false }; var dock_box = new Gtk.Box (VERTICAL, 0); + dock_box.append (new TopMargin ()); dock_box.append (new Container ()); dock_box.append (new BottomMargin ()); @@ -115,7 +113,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { // bouncing isn't added by default and instead counts to the frame var item_manager_width = item_manager.get_width (); var shadow_size = (surface.width - item_manager_width) / 2; - var top_margin = TOP_MARGIN + shadow_size - 1; + var top_margin = TopMargin.SIZE + shadow_size - 1; size.set_shadow_width (shadow_size, shadow_size, top_margin, shadow_size); }); @@ -124,7 +122,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { // and it still gets window events var item_manager_width = item_manager.get_width (); var shadow_size = (width - item_manager_width) / 2; - var top_margin = TOP_MARGIN + shadow_size; + var top_margin = TopMargin.SIZE + shadow_size; surface.set_input_region (new Cairo.Region.rectangle ({ shadow_size, top_margin, diff --git a/src/TopMargin.vala b/src/TopMargin.vala new file mode 100644 index 00000000..451502e8 --- /dev/null +++ b/src/TopMargin.vala @@ -0,0 +1,12 @@ +/* + * SPDX-License-Identifier: GPL-3.0 + * SPDX-FileCopyrightText: 2026 elementary, Inc. (https://elementary.io) + */ + +public class Dock.TopMargin : Gtk.Widget { + public const int SIZE = 64; + + construct { + height_request = SIZE; + } +} diff --git a/src/meson.build b/src/meson.build index 4e860dee..bc8ad9de 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,6 +8,7 @@ sources = [ 'ItemManager.vala', 'MainWindow.vala', 'RenderNodeWalker.vala', + 'TopMargin.vala', 'AppSystem' / 'App.vala', 'AppSystem' / 'AppSystem.vala', 'AppSystem' / 'Launcher.vala', From 7304394f981ac93e4ced61f8f2f3897cf30ba8e0 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 12 Aug 2026 19:50:20 +0300 Subject: [PATCH 2/5] Revert CSS changes --- data/Application.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/data/Application.css b/data/Application.css index c19dff33..62210c65 100644 --- a/data/Application.css +++ b/data/Application.css @@ -32,11 +32,6 @@ dock-window:not(.reduce-transparency) separator.vertical { border-right-color: alpha(@highlight_color, 0.15); } -/* Keep enough room so that icons don't clip when bouncing */ -top-margin { - min-height: 64px; -} - bottom-margin { min-height: 9px; } From 695225b8f8a64466f8f6235653b8141900950743 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 12 Aug 2026 21:27:37 +0300 Subject: [PATCH 3/5] Fix DnD --- src/AppSystem/Launcher.vala | 2 +- src/BaseItem.vala | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/AppSystem/Launcher.vala b/src/AppSystem/Launcher.vala index 24a27004..b749e4a7 100644 --- a/src/AppSystem/Launcher.vala +++ b/src/AppSystem/Launcher.vala @@ -146,7 +146,7 @@ public class Dock.Launcher : BaseItem { valign = END }; - insert_child_after (running_revealer, bin); + actionable_box.insert_child_after (running_revealer, bin); // We have to destroy the progressbar when it is not needed otherwise it will // cause continuous layouting of the surface see https://github.com/elementary/dock/issues/279 diff --git a/src/BaseItem.vala b/src/BaseItem.vala index ce909373..95437092 100644 --- a/src/BaseItem.vala +++ b/src/BaseItem.vala @@ -65,6 +65,11 @@ public class Dock.BaseItem : Gtk.Box { } } + /** + * A box that handles dnd and some other stuff. + * It's needed because top margin messes with dnd offsets and gsk transform. + */ + protected Gtk.Box actionable_box; protected Gtk.Overlay overlay; protected Gtk.GestureClick gesture_click; @@ -94,9 +99,12 @@ public class Dock.BaseItem : Gtk.Box { child = overlay }; + actionable_box = new Gtk.Box (VERTICAL, 0); + actionable_box.append (bin); + actionable_box.append (new BottomMargin ()); + append (new TopMargin ()); - append (bin); - append (new BottomMargin ()); + append (actionable_box); var tooltip_label = new Gtk.Label (null) { use_markup = true @@ -138,7 +146,7 @@ public class Dock.BaseItem : Gtk.Box { Granite.TRANSITION_DURATION_OPEN, new Adw.CallbackAnimationTarget ((val) => { bin.allocate (icon_size, icon_size, -1, - new Gsk.Transform ().translate (Graphene.Point () { y = TopMargin.SIZE + (float) val } + new Gsk.Transform ().translate (Graphene.Point () { y = (float) val } )); }) ); @@ -194,7 +202,7 @@ public class Dock.BaseItem : Gtk.Box { var drag_source = new Gtk.DragSource () { actions = MOVE }; - add_controller (drag_source); + actionable_box.add_controller (drag_source); drag_source.prepare.connect (on_drag_prepare); drag_source.drag_begin.connect (on_drag_begin); drag_source.drag_cancel.connect (on_drag_cancel); From f69d839b1e6184c0e6435ef0a743366005d5ccd7 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 12 Aug 2026 21:29:57 +0300 Subject: [PATCH 4/5] Remove `valign = START` --- src/ItemManager.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ItemManager.vala b/src/ItemManager.vala index 98c9fde5..f48074d4 100644 --- a/src/ItemManager.vala +++ b/src/ItemManager.vala @@ -25,8 +25,7 @@ #if WORKSPACE_SWITCHER separator = new Gtk.Separator (VERTICAL) { - valign = START, - margin_top = Launcher.PADDING, + margin_top = Launcher.PADDING }; settings.bind ("icon-size", separator, "height-request", GET); From d0494c0f6b30f8806fb4f2f6732ad5dca462cb4f Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 12 Aug 2026 21:33:12 +0300 Subject: [PATCH 5/5] Update copyright --- src/AppSystem/Launcher.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppSystem/Launcher.vala b/src/AppSystem/Launcher.vala index b749e4a7..05c93ae3 100644 --- a/src/AppSystem/Launcher.vala +++ b/src/AppSystem/Launcher.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2022-2025 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2022-2026 elementary, Inc. (https://elementary.io) */ public class Dock.Launcher : BaseItem {