gtk/gtktooltip.c: check result of event position get operation
authorMaxim Zakharov <zakhma@muli.com.au>
Tue, 30 Aug 2022 05:45:52 +0000 (15:45 +1000)
committerMaxim Zakharov <zakhma@muli.com.au>
Tue, 30 Aug 2022 05:54:52 +0000 (15:54 +1000)
Do not perform coordinates transformation when gdk_event_get_position()
returns FALSE as it returns NaNs in that case and these coordinates
are not used anyway in further processing (closes #5134).

gtk/gtktooltip.c

index 9f0fa15cca7dcb4571171b1126272f1c7c68d52d..54708a14aa7026366d260fb461716a81e51d887a 100644 (file)
@@ -925,16 +925,18 @@ _gtk_tooltip_handle_event (GtkWidget *target,
     return;
 
   event_type = gdk_event_get_event_type (event);
-  surface = gdk_event_get_surface (event);
-  gdk_event_get_position (event, &x, &y);
 
   /* ignore synthetic motion events */
   if (event_type == GDK_MOTION_NOTIFY &&
       gdk_event_get_time (event) == GDK_CURRENT_TIME)
     return;
 
-  gtk_native_get_surface_transform (native, &nx, &ny);
-  gtk_widget_translate_coordinates (GTK_WIDGET (native), target, x - nx, y - ny, &x, &y);
+  surface = gdk_event_get_surface (event);
+  if (gdk_event_get_position (event, &x, &y))
+    {
+      gtk_native_get_surface_transform (native, &nx, &ny);
+      gtk_widget_translate_coordinates (GTK_WIDGET (native), target, x - nx, y - ny, &x, &y);
+    }
   gtk_tooltip_handle_event_internal (event_type, surface, target, x, y);
 }