@@ -953,18 +953,17 @@ static void _thumbs_show_overlays(dt_thumbnail_t *thumb)
953953 }
954954}
955955
956- static gboolean _event_main_motion (GtkWidget * widget ,
957- GdkEventMotion * event ,
958- gpointer user_data )
956+ static void _event_main_motion (GtkEventControllerMotion * controller ,
957+ double x ,
958+ double y ,
959+ dt_thumbnail_t * thumb )
959960{
960- if (!user_data ) return TRUE;
961- dt_thumbnail_t * thumb = (dt_thumbnail_t * )user_data ;
961+ if (!thumb ) return ;
962962 // first, we hide the block overlays after a delay if the mouse hasn't move
963963 _thumbs_show_overlays (thumb );
964964
965965 if (!thumb -> mouse_over && !thumb -> disable_mouseover )
966966 dt_control_set_mouse_over_id (thumb -> imgid );
967- return FALSE;
968967}
969968
970969static gboolean _event_rating_press (GtkWidget * widget ,
@@ -1244,20 +1243,24 @@ static gboolean _event_box_enter_leave(GtkWidget *widget,
12441243 return FALSE;
12451244}
12461245
1247- static gboolean _event_image_enter_leave (GtkWidget * widget ,
1248- GdkEventCrossing * event ,
1249- gpointer user_data )
1246+ static void _event_image_leave (GtkEventControllerMotion * controller ,
1247+ dt_thumbnail_t * thumb )
12501248{
1251- dt_thumbnail_t * thumb = (dt_thumbnail_t * )user_data ;
1252-
12531249 // we ensure that the image has mouse over
1254- if (!thumb -> mouse_over && event -> type == GDK_ENTER_NOTIFY
1250+ if (!thumb -> mouse_over && controller == NULL
12551251 && !thumb -> disable_mouseover )
12561252 dt_control_set_mouse_over_id (thumb -> imgid );
12571253
12581254 _set_flag (thumb -> w_image_box , GTK_STATE_FLAG_PRELIGHT ,
1259- (event -> type == GDK_ENTER_NOTIFY ));
1260- return FALSE;
1255+ (controller == NULL ));
1256+ }
1257+
1258+ static void _event_image_enter (GtkEventControllerMotion * controller ,
1259+ double x ,
1260+ double y ,
1261+ dt_thumbnail_t * thumb )
1262+ {
1263+ _event_image_leave (NULL , thumb );
12611264}
12621265
12631266static gboolean _event_btn_enter_leave (GtkWidget * widget ,
@@ -1331,13 +1334,12 @@ static gboolean _event_star_leave(GtkWidget *widget,
13311334 return TRUE;
13321335}
13331336
1334- static gboolean _event_main_leave (GtkWidget * widget ,
1335- GdkEventCrossing * event ,
1336- gpointer user_data )
1337+ static void _event_main_leave (GtkEventControllerMotion * controller ,
1338+ dt_thumbnail_t * user_data )
13371339{
1340+ GdkEventCrossing * event = (GdkEventCrossing * )gtk_get_current_event ();
13381341 // if we leave for ancestor, that means we leave for blank thumbtable area
13391342 if (event -> detail == GDK_NOTIFY_ANCESTOR ) dt_control_set_mouse_over_id (NO_IMGID );
1340- return FALSE;
13411343}
13421344
13431345// we only want to specify that the mouse is hovereing the thumbnail
@@ -1348,7 +1350,7 @@ static gboolean _event_main_drag_motion(GtkWidget *widget,
13481350 const guint time ,
13491351 gpointer user_data )
13501352{
1351- _event_main_motion (widget , NULL , user_data );
1353+ _event_main_motion (NULL , .0f , .0f , user_data );
13521354 return TRUE;
13531355}
13541356
@@ -1403,16 +1405,9 @@ GtkWidget *dt_thumbnail_create_widget(dt_thumbnail_t *thumb,
14031405
14041406 // the background
14051407 thumb -> w_back = gtk_event_box_new ();
1406- gtk_widget_set_events (thumb -> w_back ,
1407- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
1408- | GDK_STRUCTURE_MASK
1409- | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK
1410- | GDK_POINTER_MOTION_MASK );
1408+ gtk_widget_set_events (thumb -> w_back , GDK_STRUCTURE_MASK ); // TODO: Needed?
14111409 gtk_widget_set_name (thumb -> w_back , "thumb-back" );
1412- g_signal_connect (G_OBJECT (thumb -> w_back ), "motion-notify-event" ,
1413- G_CALLBACK (_event_main_motion ), thumb );
1414- g_signal_connect (G_OBJECT (thumb -> w_back ), "leave-notify-event" ,
1415- G_CALLBACK (_event_main_leave ), thumb );
1410+ dt_gui_connect_motion (thumb -> w_back , _event_main_motion , NULL , _event_main_leave , thumb );
14161411 gtk_widget_show (thumb -> w_back );
14171412 gtk_container_add (GTK_CONTAINER (thumb -> w_main ), thumb -> w_back );
14181413
@@ -1442,12 +1437,7 @@ GtkWidget *dt_thumbnail_create_widget(dt_thumbnail_t *thumb,
14421437 | GDK_STRUCTURE_MASK
14431438 | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK
14441439 | GDK_POINTER_MOTION_MASK );
1445- g_signal_connect (G_OBJECT (evt_image ), "motion-notify-event" ,
1446- G_CALLBACK (_event_main_motion ), thumb );
1447- g_signal_connect (G_OBJECT (evt_image ), "enter-notify-event" ,
1448- G_CALLBACK (_event_image_enter_leave ), thumb );
1449- g_signal_connect (G_OBJECT (evt_image ), "leave-notify-event" ,
1450- G_CALLBACK (_event_image_enter_leave ), thumb );
1440+ dt_gui_connect_motion (evt_image , _event_main_motion , _event_image_enter , _event_image_leave , thumb );
14511441 gtk_widget_show (evt_image );
14521442 gtk_overlay_add_overlay (GTK_OVERLAY (thumb -> w_image_box ), evt_image );
14531443 thumb -> w_image = gtk_drawing_area_new ();
@@ -1461,12 +1451,7 @@ GtkWidget *dt_thumbnail_create_widget(dt_thumbnail_t *thumb,
14611451 | GDK_POINTER_MOTION_MASK );
14621452 g_signal_connect (G_OBJECT (thumb -> w_image ), "draw" ,
14631453 G_CALLBACK (_event_image_draw ), thumb );
1464- g_signal_connect (G_OBJECT (thumb -> w_image ), "motion-notify-event" ,
1465- G_CALLBACK (_event_main_motion ), thumb );
1466- g_signal_connect (G_OBJECT (thumb -> w_image ), "enter-notify-event" ,
1467- G_CALLBACK (_event_image_enter_leave ), thumb );
1468- g_signal_connect (G_OBJECT (thumb -> w_image ), "leave-notify-event" ,
1469- G_CALLBACK (_event_image_enter_leave ), thumb );
1454+ dt_gui_connect_motion (thumb -> w_image , _event_main_motion , _event_image_enter , _event_image_leave , thumb );
14701455 g_signal_connect (G_OBJECT (thumb -> w_image ), "style-updated" ,
14711456 G_CALLBACK (_event_image_style_updated ), thumb );
14721457 gtk_widget_show (thumb -> w_image );
0 commit comments