bring back bounds check and switch to floor
authorSmirnov Egor <s.e.a.98@yandex.ru>
Mon, 24 May 2021 13:39:02 +0000 (16:39 +0300)
committerrogday <rogday@test.com>
Mon, 31 May 2021 16:03:50 +0000 (19:03 +0300)
modules/highgui/src/window_gtk.cpp

index ad50db30a812c9f3f424fe30bfac8c1db11c3c84..9bc6257f98bbf2e1ab533507625801ed614df168 100644 (file)
@@ -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)  |