Merge pull request #20240 from alalek:fixup_20149_4.x

This commit is contained in:
Alexander Alekhin 2021-06-08 13:44:24 +00:00
commit 2c796de92b

View File

@ -1913,17 +1913,19 @@ static gboolean icvOnClose( GtkWidget* widget, GdkEvent* /*event*/, gpointer use
static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_data )
{
// TODO move this logic to CvImageWidget
// TODO add try-catch wrappers into all callbacks
CvWindow* window = (CvWindow*)user_data;
if (!window || !widget ||
window->signature != CV_WINDOW_MAGIC_VAL ||
window->widget != widget ||
!window->on_mouse)
return FALSE;
CvPoint2D32f pt32f = {-1., -1.};
CvPoint pt = {-1,-1};
int cv_event = -1, state = 0, flags = 0;
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
if( window->signature != CV_WINDOW_MAGIC_VAL ||
window->widget != widget || !window->widget ||
!window->on_mouse /*|| !image_widget->original_image*/)
return FALSE;
if( event->type == GDK_MOTION_NOTIFY )
{
GdkEventMotion* event_motion = (GdkEventMotion*)event;
@ -2016,8 +2018,10 @@ 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 (!image_widget->original_image/*OpenGL*/ || (
(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) |