Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/AppSystem/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public class Dock.App : Object {

notify["pinned"].connect (() => {
check_remove ();
ItemManager.get_default ().sync_pinned ();
});

WindowSystem.get_default ().notify["active-workspace"].connect (() => {
Expand Down
4 changes: 2 additions & 2 deletions src/BaseItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class Dock.BaseItem : Gtk.Box {
reveal.done.connect (set_revealed_finish);

var animation_target = new Adw.CallbackAnimationTarget ((val) => {
ItemManager.get_default ().move (this, val, 0);
((ItemManager) get_ancestor (typeof (ItemManager))).move (this, val, 0);
current_pos = val;
});

Expand Down Expand Up @@ -284,7 +284,7 @@ public class Dock.BaseItem : Gtk.Box {
* @param y pointer y position
*/
public void calculate_dnd_move (BaseItem source, double x, double y) {
var launcher_manager = ItemManager.get_default ();
var launcher_manager = (ItemManager) get_ancestor (typeof (ItemManager));

int target_index = launcher_manager.get_index_for_launcher (this);
int source_index = launcher_manager.get_index_for_launcher (source);
Expand Down
8 changes: 7 additions & 1 deletion src/DBus/ShellKeyGrabber.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public interface ShellKeyGrabber : GLib.Object {

private static HashTable<uint, int> saved_action_ids;

private static Dock.ItemManager item_manager;

public static void init () {
settings = new Settings ("io.elementary.dock.keybindings");
saved_action_ids = new HashTable<uint, int> (null, null);
Expand All @@ -71,6 +73,10 @@ public interface ShellKeyGrabber : GLib.Object {
Bus.watch_name (BusType.SESSION, "org.gnome.Shell", BusNameWatcherFlags.NONE, () => on_watch.begin (), () => instance = null);
}

public static void set_item_manager (Dock.ItemManager manager) {
item_manager = manager;
}

private static async void on_watch () {
try {
instance = yield Bus.get_proxy (SESSION, "org.gnome.Shell", "/org/gnome/Shell");
Expand Down Expand Up @@ -109,7 +115,7 @@ public interface ShellKeyGrabber : GLib.Object {
return;
}

Dock.ItemManager.get_default ().launch (saved_action_ids[action]);
item_manager.launch (saved_action_ids[action]);
}

private static void ungrab_keybindings () requires (instance != null) {
Expand Down
6 changes: 1 addition & 5 deletions src/ItemManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
public class Dock.ItemManager : Gtk.Fixed {
private static Settings settings;

private static GLib.Once<ItemManager> instance;
public static unowned ItemManager get_default () {
return instance.once (() => { return new ItemManager (); });
}

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

private Adw.TimedAnimation resize_animation;
Expand Down Expand Up @@ -227,6 +222,7 @@
if (item is Launcher) {
launchers.add ((Launcher) item);
sync_pinned ();
item.notify["pinned"].connect (sync_pinned);
} else if (item is WorkspaceIconGroup) {
icon_groups.add ((WorkspaceIconGroup) item);
}
Expand Down
19 changes: 11 additions & 8 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
private Settings transparency_settings;
private static Settings settings = new Settings ("io.elementary.dock");

private ItemManager item_manager;

private Pantheon.Desktop.Shell? desktop_shell;
private Pantheon.Desktop.Panel? panel;

Expand All @@ -40,27 +42,26 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
dock_box.append (new Container ());
dock_box.append (new BottomMargin ());

unowned var launcher_manager = ItemManager.get_default ();
item_manager = new ItemManager ();

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

var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH);
size_group.add_widget (dock_box);
size_group.add_widget (launcher_manager);

size_group.add_widget (item_manager);
child = overlay;

remove_css_class ("background");

// Fixes DnD reordering of launchers failing on a very small line between two launchers
var drop_target_launcher = new Gtk.DropTarget (typeof (Launcher), MOVE);
launcher_manager.add_controller (drop_target_launcher);
item_manager.add_controller (drop_target_launcher);

launcher_manager.realize.connect (init_panel);
item_manager.realize.connect (init_panel);

settings.changed["autohide-mode"].connect (() => {
if (panel != null) {
Expand All @@ -78,6 +79,8 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
}

window_drag_manager = new WindowDragManager (this);

ShellKeyGrabber.set_item_manager (item_manager);
}

private void update_transparency () {
Expand Down Expand Up @@ -112,7 +115,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
surface.compute_size.connect ((surface, size) => {
// manually set shadow width since the additional margin we add to avoid icons clipping when
// bouncing isn't added by default and instead counts to the frame
var item_manager_width = ItemManager.get_default ().get_width ();
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;
size.set_shadow_width (shadow_size, shadow_size, top_margin, shadow_size);
Expand All @@ -121,7 +124,7 @@ public class Dock.MainWindow : Gtk.ApplicationWindow {
surface.layout.connect ((surface, width, height) => {
// manually set input region since container's shadow are is the content of the window
// and it still gets window events
var item_manager_width = ItemManager.get_default ().get_width ();
var item_manager_width = item_manager.get_width ();
var shadow_size = (width - item_manager_width) / 2;
var top_margin = TOP_MARGIN + shadow_size;
surface.set_input_region (new Cairo.Region.rectangle ({
Expand Down
3 changes: 2 additions & 1 deletion src/WorkspaceSystem/IconGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class Dock.WorkspaceIconGroup : BaseIconGroup, WorkspaceItem {

private void on_moving_changed () {
if (!moving) {
workspace.reorder (ItemManager.get_default ().get_index_for_launcher (this));
var item_manager = (ItemManager) get_ancestor (typeof (ItemManager));
workspace.reorder (item_manager.get_index_for_launcher (this));
}
}

Expand Down