From be2e07637f0f31a3957bdc215e4ad23eb6de79a5 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 1 Feb 2022 13:35:32 +0100 Subject: [PATCH] gtk-stats: Fix mouse motion detected outside strip chart graph area Cherry-picked from 3a38543f65670b2d754838c5b08a556df1485a01 --- .../src/gtk-stats/gtkStatsStripChart.cxx | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx index 117ef96576..1015c7989a 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx @@ -402,20 +402,23 @@ set_drag_mode(GtkStatsGraph::DragMode drag_mode) { gboolean GtkStatsStripChart:: handle_button_press(GtkWidget *widget, int graph_x, int graph_y, bool double_click) { - if (double_click) { - // Double-clicking on a color bar in the graph is the same as double- - // clicking on the corresponding label. - clicked_label(get_collector_under_pixel(graph_x, graph_y)); - return TRUE; + if (graph_x >= 0 && graph_y >= 0 && graph_x < get_xsize() && graph_y < get_ysize()) { + if (double_click) { + // Double-clicking on a color bar in the graph is the same as double- + // clicking on the corresponding label. + clicked_label(get_collector_under_pixel(graph_x, graph_y)); + return TRUE; + } + + if (_potential_drag_mode == DM_none) { + set_drag_mode(DM_scale); + _drag_scale_start = pixel_to_height(graph_y); + // SetCapture(_graph_window); + return TRUE; + } } - if (_potential_drag_mode == DM_none) { - set_drag_mode(DM_scale); - _drag_scale_start = pixel_to_height(graph_y); - // SetCapture(_graph_window); - return TRUE; - - } else if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) { + if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) { set_drag_mode(DM_guide_bar); _drag_start_y = graph_y; // SetCapture(_graph_window); @@ -455,7 +458,8 @@ handle_button_release(GtkWidget *widget, int graph_x, int graph_y) { */ gboolean GtkStatsStripChart:: handle_motion(GtkWidget *widget, int graph_x, int graph_y) { - if (_drag_mode == DM_none && _potential_drag_mode == DM_none) { + if (_drag_mode == DM_none && _potential_drag_mode == DM_none && + graph_x >= 0 && graph_y >= 0 && graph_x < get_xsize() && graph_y < get_ysize()) { // When the mouse is over a color bar, highlight it. _label_stack.highlight_label(get_collector_under_pixel(graph_x, graph_y));