Skip to content

Commit 662e310

Browse files
authored
Fix icons clipping when bouncing and separate background from window (#328)
1 parent 14d5a95 commit 662e310

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

data/Application.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ dock {
1414
0 0 0 1px alpha(@borders, 0.4),
1515
0 1px 3px alpha(black, 0.10),
1616
0 3px 9px alpha(black, 0.15);
17-
margin: 9px;
18-
margin-top: 0;
17+
padding: 9px;
18+
}
19+
20+
dock-window {
21+
margin-top: 64px; /* Keep enough room so that icons don't clip when bouncing */
22+
}
23+
24+
bottom-margin {
25+
min-height: 9px;
1926
}
2027

2128
launcher {

src/MainWindow.vala

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

66
public class Dock.MainWindow : Gtk.ApplicationWindow {
7+
private class Container : Gtk.Box {
8+
class construct {
9+
set_css_name ("dock");
10+
}
11+
}
12+
13+
private class BottomMargin : Gtk.Widget {
14+
class construct {
15+
set_css_name ("bottom-margin");
16+
}
17+
}
18+
719
private static Settings settings = new Settings ("io.elementary.dock");
820

921
private Pantheon.Desktop.Shell? desktop_shell;
1022
private Pantheon.Desktop.Panel? panel;
1123

24+
private Gtk.Box main_box;
25+
private int height = 0;
26+
1227
class construct {
13-
set_css_name ("dock");
28+
set_css_name ("dock-window");
1429
}
1530

1631
construct {
1732
var launcher_manager = LauncherManager.get_default ();
1833

19-
child = launcher_manager;
2034
overflow = VISIBLE;
2135
resizable = false;
2236
titlebar = new Gtk.Label ("") { visible = false };
2337

38+
// Don't clip launchers to dock background https://github.com/elementary/dock/issues/275
39+
var overlay = new Gtk.Overlay () {
40+
child = new Container ()
41+
};
42+
overlay.add_overlay (launcher_manager);
43+
44+
var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH);
45+
size_group.add_widget (overlay.child);
46+
size_group.add_widget (launcher_manager);
47+
48+
main_box = new Gtk.Box (VERTICAL, 0);
49+
main_box.append (overlay);
50+
main_box.append (new BottomMargin ());
51+
child = main_box;
52+
53+
remove_css_class ("background");
54+
2455
// Fixes DnD reordering of launchers failing on a very small line between two launchers
2556
var drop_target_launcher = new Gtk.DropTarget (typeof (Launcher), MOVE);
2657
launcher_manager.add_controller (drop_target_launcher);
@@ -51,6 +82,21 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
5182

5283
private static Wl.RegistryListener registry_listener;
5384
private void init_panel () {
85+
get_surface ().layout.connect_after (() => {
86+
var new_height = main_box.get_height ();
87+
if (new_height == height) {
88+
return;
89+
}
90+
91+
height = new_height;
92+
93+
if (panel != null) {
94+
panel.set_size (-1, height);
95+
} else {
96+
update_panel_x11 ();
97+
}
98+
});
99+
54100
registry_listener.global = registry_handle_global;
55101
unowned var display = Gdk.Display.get_default ();
56102
if (display is Gdk.Wayland.Display) {
@@ -78,7 +124,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
78124

79125
var prop = xdisplay.intern_atom ("_MUTTER_HINTS", false);
80126

81-
var value = "anchor=8:hide-mode=%d".printf (settings.get_enum ("autohide-mode"));
127+
var value = "anchor=8:hide-mode=%d:size=-1,%d".printf (settings.get_enum ("autohide-mode"), height);
82128

83129
xdisplay.change_property (window, prop, X.XA_STRING, 8, 0, (uchar[]) value, value.length);
84130
}

0 commit comments

Comments
 (0)