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
19 changes: 11 additions & 8 deletions src/AppSystem/Background/BackgroundItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class Dock.BackgroundItem : BaseIconGroup {
public BackgroundMonitor monitor { private get; construct; }
public bool has_apps { get { return monitor.background_apps.get_n_items () > 0; } }

private Gtk.Popover popover;

public BackgroundItem () {
var background_monitor = new BackgroundMonitor ();
Object (
Expand Down Expand Up @@ -40,26 +38,31 @@ public class Dock.BackgroundItem : BaseIconGroup {
box.append (new Gtk.Separator (HORIZONTAL));
box.append (list_box);

popover = new Gtk.Popover () {
popover_menu = new Gtk.Popover () {
position = TOP,
child = box
};
// We need to set offset because dock window's height is 1px larger than its visible area
// If we don't do that, the struts prevent popover from showing
popover.set_offset (0, -1);
popover.add_css_class (Granite.STYLE_CLASS_MENU);
popover.set_parent (this);
popover_menu.set_offset (0, -1);
popover_menu.add_css_class (Granite.STYLE_CLASS_MENU);
popover_menu.set_parent (this);

tooltip_text = "%s\n%s".printf (
header_label.label,
Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (header_label.secondary_text)
);

monitor.background_apps.items_changed.connect ((pos, n_removed, n_added) => {
if (monitor.background_apps.get_n_items () == 0) {
popover.popdown ();
popover_menu.popdown ();
removed ();
} else if (n_removed == 0 && n_added != 0 && n_added == monitor.background_apps.get_n_items ()) {
apps_appeared ();
}
});

gesture_click.released.connect (popover.popup);
gesture_click.released.connect (popover_menu.popup);
}

private Gtk.Widget create_widget_func (Object obj) {
Expand Down
10 changes: 0 additions & 10 deletions src/AppSystem/Launcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class Dock.Launcher : BaseItem {
private Adw.TimedAnimation bounce_up;
private Adw.TimedAnimation bounce_down;
private Adw.TimedAnimation shake;
private Gtk.PopoverMenu popover_menu;

private Gtk.Image? second_running_indicator;
private bool multiple_windows_open {
Expand Down Expand Up @@ -243,15 +242,6 @@ public class Dock.Launcher : BaseItem {
});
add_controller (long_press);

var motion_controller = new Gtk.EventControllerMotion ();
motion_controller.enter.connect (() => {
if (!popover_menu.visible) {
popover_tooltip.popup ();
}
});

add_controller (motion_controller);

var scroll_controller = new Gtk.EventControllerScroll (VERTICAL);
add_controller (scroll_controller);
scroll_controller.scroll.connect ((dx, dy) => {
Expand Down
6 changes: 6 additions & 0 deletions src/BaseItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class Dock.BaseItem : Gtk.Box {

// Motion events have to be handled in children because of popover menu
protected Gtk.Popover popover_tooltip;
Copy link
Member

@leolost2605 leolost2605 Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this private then? (And remove the comment)

protected Gtk.Popover popover_menu;

private int drag_offset_x = 0;
private int drag_offset_y = 0;
Expand Down Expand Up @@ -148,6 +149,11 @@ public class Dock.BaseItem : Gtk.Box {
};

var motion_controller = new Gtk.EventControllerMotion ();
motion_controller.enter.connect (() => {
if (!popover_menu.visible && tooltip_text != null) {
popover_tooltip.popup ();
}
});
motion_controller.leave.connect (popover_tooltip.popdown);

add_controller (motion_controller);
Expand Down
9 changes: 0 additions & 9 deletions src/ContainerItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,5 @@ public abstract class Dock.ContainerItem : BaseItem {
remove_css_class ("running");
}
});

var motion_controller = new Gtk.EventControllerMotion ();
motion_controller.enter.connect (() => {
if (tooltip_text != null) {
popover_tooltip.popup ();
}
});

add_controller (motion_controller);
}
}