From 2b9d739cb070a8dcb71c5996daaec2910658833c Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Sat, 17 Oct 2026 11:16:09 +0200 Subject: [PATCH] menus and launching: the time since a submenu opened and the time a program takes to start are measured with the monotonic clock, so setting the clock meanwhile does not shorten or lengthen them --- gdk/x11/gdkapplaunchcontext-x11.c | 4 +++- gtk/gtkmenuitem.c | 2 +- gtk/gtkmenushell.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c index 0d171e5aa..723ff4dcf 100644 --- a/gdk/x11/gdkapplaunchcontext-x11.c +++ b/gdk/x11/gdkapplaunchcontext-x11.c @@ -178,10 +178,12 @@ free_startup_timeout (void *data) g_free (std); } +/* for the time a startup takes: not the wall clock, which may be set + * meanwhile */ static gint64 get_current_time_usec (void) { - return g_get_real_time (); + return g_get_monotonic_time (); } static gboolean diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index efad611ad..294679580 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -1504,7 +1504,7 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget, { gint64 *popup_time = g_slice_new0 (gint64); - *popup_time = g_get_real_time (); + *popup_time = g_get_monotonic_time (); g_object_set_data_full (G_OBJECT (menu_item->submenu), "gtk-menu-exact-popup-time", popup_time, diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index 091586d79..40c9b8805 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -719,7 +719,7 @@ gtk_menu_shell_button_release (GtkWidget *widget, if (popup_time) { - usec_since_popup = g_get_real_time () - *popup_time; + usec_since_popup = g_get_monotonic_time () - *popup_time; g_object_set_data (G_OBJECT (submenu), "gtk-menu-exact-popup-time", NULL);