gtk-stats: Fix mouse motion detected outside strip chart graph area

Cherry-picked from 3a38543f65670b2d754838c5b08a556df1485a01
This commit is contained in:
rdb 2022-02-01 13:35:32 +01:00
parent bc6502a8fe
commit be2e07637f

View File

@ -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));