From fb68fe8930c92b798fdd02058d42f2d58dcbd2c4 Mon Sep 17 00:00:00 2001 From: Smirnov Egor Date: Mon, 24 May 2021 16:39:02 +0300 Subject: [PATCH] bring back bounds check and switch to floor --- modules/highgui/src/window_gtk.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/highgui/src/window_gtk.cpp b/modules/highgui/src/window_gtk.cpp index ad50db30a8..9bc6257f98 100644 --- a/modules/highgui/src/window_gtk.cpp +++ b/modules/highgui/src/window_gtk.cpp @@ -1787,8 +1787,8 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da GdkEventMotion* event_motion = (GdkEventMotion*)event; cv_event = CV_EVENT_MOUSEMOVE; - pt32f.x = cvRound(event_motion->x); - pt32f.y = cvRound(event_motion->y); + pt32f.x = cvFloor(event_motion->x); + pt32f.y = cvFloor(event_motion->y); state = event_motion->state; } else if( event->type == GDK_BUTTON_PRESS || @@ -1796,8 +1796,8 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da event->type == GDK_2BUTTON_PRESS ) { GdkEventButton* event_button = (GdkEventButton*)event; - pt32f.x = cvRound(event_button->x); - pt32f.y = cvRound(event_button->y); + pt32f.x = cvFloor(event_button->x); + pt32f.y = cvFloor(event_button->y); if( event_button->type == GDK_BUTTON_PRESS ) @@ -1874,8 +1874,8 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da pt = cvPointFrom32f( pt32f ); } -// if((unsigned)pt.x < (unsigned)(image_widget->original_image->width) && -// (unsigned)pt.y < (unsigned)(image_widget->original_image->height) ) + if((unsigned)pt.x < (unsigned)(image_widget->original_image->width) && + (unsigned)pt.y < (unsigned)(image_widget->original_image->height) ) { flags |= BIT_MAP(state, GDK_SHIFT_MASK, CV_EVENT_FLAG_SHIFTKEY) | BIT_MAP(state, GDK_CONTROL_MASK, CV_EVENT_FLAG_CTRLKEY) |