Skip to content

Commit 36e88cc

Browse files
committed
Workaround for crashing when many tooltips are shown consecutively
Fixes #559
1 parent 01d3ae8 commit 36e88cc

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

src/AppSystem/Launcher.vala

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class Dock.Launcher : BaseItem {
5858
private uint queue_dnd_cycle_id = 0;
5959

6060
private bool flagged_for_removal = false;
61+
private bool waiting_to_open_tooltip = false;
6162

6263
public Launcher (App app) {
6364
Object (app: app, group: Group.LAUNCHER);
@@ -246,11 +247,12 @@ public class Dock.Launcher : BaseItem {
246247

247248
var motion_controller = new Gtk.EventControllerMotion ();
248249
motion_controller.enter.connect (() => {
249-
if (!popover_menu.visible) {
250-
popover_tooltip.popup ();
251-
}
250+
this.wait_and_show_tooltip (100);
251+
});
252+
motion_controller.leave.connect (() => {
253+
this.waiting_to_open_tooltip = false;
254+
if (popover_tooltip.visible) popover_tooltip.popdown ();
252255
});
253-
254256
add_controller (motion_controller);
255257

256258
var scroll_controller = new Gtk.EventControllerScroll (VERTICAL);
@@ -486,4 +488,23 @@ public class Dock.Launcher : BaseItem {
486488
multiple_windows_open = app.windows.length > 1;
487489
}
488490
}
491+
492+
private void wait_and_show_tooltip (uint delay_ms) {
493+
if (!popover_menu.visible) {
494+
// Add timeout to avoid "Error 71 (Protocol error) dispatching to Wayland display".
495+
// This error is probably caused by a bug in GTK caused by the Nvidia driver at least up to v580.
496+
// Documented in issue #559 on the Github project.
497+
waiting_to_open_tooltip = true;
498+
GLib.Timeout.add (delay_ms, () => {
499+
if (waiting_to_open_tooltip) {
500+
waiting_to_open_tooltip = false;
501+
if (!popover_menu.visible) {
502+
popover_tooltip.popup ();
503+
}
504+
}
505+
506+
return false;
507+
});
508+
}
509+
}
489510
}

0 commit comments

Comments
 (0)