Skip to content

Commit 3323bb0

Browse files
authored
Use shadow width instead of custom size (#437)
1 parent c1d7671 commit 3323bb0

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/MainWindow.vala

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
2626
private Pantheon.Desktop.Panel? panel;
2727

2828
private Gtk.Box main_box;
29-
private int height = 0;
3029

3130
class construct {
3231
set_css_name ("dock-window");
@@ -102,6 +101,16 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
102101

103102
private static Wl.RegistryListener registry_listener;
104103
private void init_panel () {
104+
((Gdk.Toplevel) get_surface ()).compute_size.connect ((size) => {
105+
// manually set shadow width since the additional margin we add to avoid icons clipping when
106+
// bouncing isn't added by default and instead counts to the frame
107+
unowned var surface = get_surface ();
108+
var item_manager_width = ItemManager.get_default ().get_width ();
109+
var shadow_size = (surface.width - item_manager_width) / 2;
110+
var top_margin = TOP_MARGIN + shadow_size - 1;
111+
size.set_shadow_width (shadow_size, shadow_size, top_margin, shadow_size);
112+
});
113+
105114
get_surface ().layout.connect_after (() => {
106115
// manually set input region since container's shadow are is the content of the window
107116
// and it still gets window events
@@ -115,19 +124,6 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
115124
item_manager_width,
116125
surface.height - top_margin
117126
}));
118-
119-
var new_height = main_box.get_height ();
120-
if (new_height == height) {
121-
return;
122-
}
123-
124-
height = new_height;
125-
126-
if (panel != null) {
127-
panel.set_size (-1, height);
128-
} else {
129-
update_panel_x11 ();
130-
}
131127
});
132128

133129
registry_listener.global = registry_handle_global;
@@ -157,7 +153,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
157153

158154
var prop = xdisplay.intern_atom ("_MUTTER_HINTS", false);
159155

160-
var value = "anchor=8:hide-mode=%d:size=-1,%d:restore-previous-region=1".printf (settings.get_enum ("autohide-mode"), height);
156+
var value = "anchor=8:hide-mode=%d:restore-previous-region=1".printf (settings.get_enum ("autohide-mode"));
161157

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

0 commit comments

Comments
 (0)