From 4a283a79c563469c62d6ea05d8c0d2b748e1cd5a Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 25 Aug 2023 13:36:19 -0700 Subject: [PATCH] sysprof: use hand cursor to indicate flamegraph interactivity You can click on flamegraph items (and soon) we will update the graph to show you that node. Set the hand cursor when doing that so the user knows that is an option. --- src/sysprof/sysprof-flame-graph.c | 43 ++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/sysprof/sysprof-flame-graph.c b/src/sysprof/sysprof-flame-graph.c index 0feff195..caf874ff 100644 --- a/src/sysprof/sysprof-flame-graph.c +++ b/src/sysprof/sysprof-flame-graph.c @@ -47,6 +47,7 @@ struct _SysprofFlameGraph GskRenderNode *rendered; GArray *nodes; SysprofCallgraphNode *root; + FlameRectangle *under_pointer; double motion_x; double motion_y; @@ -239,6 +240,30 @@ sysprof_flame_graph_measure (GtkWidget *widget, } } +static void +sysprof_flame_graph_set_motion (SysprofFlameGraph *self, + double x, + double y) +{ + FlameRectangle *rect; + + g_assert (SYSPROF_IS_FLAME_GRAPH (self)); + + self->motion_x = x; + self->motion_y = y; + + rect = find_node_at_coord (self, x, y); + + if (rect != self->under_pointer) + { + self->under_pointer = rect; + + gtk_widget_set_cursor_from_name (GTK_WIDGET (self), rect ? "hand" : NULL); + } + + gtk_widget_queue_draw (GTK_WIDGET (self)); +} + static void sysprof_flame_graph_motion_enter_cb (SysprofFlameGraph *self, double x, @@ -248,10 +273,7 @@ sysprof_flame_graph_motion_enter_cb (SysprofFlameGraph *self, g_assert (SYSPROF_IS_FLAME_GRAPH (self)); g_assert (GTK_IS_EVENT_CONTROLLER_MOTION (motion)); - self->motion_x = x; - self->motion_y = y; - - gtk_widget_queue_draw (GTK_WIDGET (self)); + sysprof_flame_graph_set_motion (self, x, y); } static void @@ -263,10 +285,7 @@ sysprof_flame_graph_motion_motion_cb (SysprofFlameGraph *self, g_assert (SYSPROF_IS_FLAME_GRAPH (self)); g_assert (GTK_IS_EVENT_CONTROLLER_MOTION (motion)); - self->motion_x = x; - self->motion_y = y; - - gtk_widget_queue_draw (GTK_WIDGET (self)); + sysprof_flame_graph_set_motion (self, x, y); } static void @@ -276,10 +295,7 @@ sysprof_flame_graph_motion_leave_cb (SysprofFlameGraph *self, g_assert (SYSPROF_IS_FLAME_GRAPH (self)); g_assert (GTK_IS_EVENT_CONTROLLER_MOTION (motion)); - self->motion_x = 0; - self->motion_y = 0; - - gtk_widget_queue_draw (GTK_WIDGET (self)); + sysprof_flame_graph_set_motion (self, 0, 0); } static void @@ -619,6 +635,9 @@ sysprof_flame_graph_set_callgraph (SysprofFlameGraph *self, g_clear_pointer (&self->nodes, g_array_unref); self->root = NULL; + self->under_pointer = NULL; + + gtk_widget_set_cursor_from_name (GTK_WIDGET (self), NULL); if (callgraph != NULL) {