inspector: Take surface transform into account
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 06:10:56 +0000 (02:10 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 06:10:56 +0000 (02:10 -0400)
gtk/inspector/focusoverlay.c
gtk/inspector/inspect-button.c
gtk/inspector/layoutoverlay.c

index 1ed260d07762261f948fd7b3d23f9389d9560568..3df045936f2e47b824eb8213d277040e8fb3cd4f 100644 (file)
@@ -24,7 +24,7 @@
 #include "gtkintl.h"
 #include "gtkwidget.h"
 #include "gtkroot.h"
-#include "gtknative.h"
+#include "gtknativeprivate.h"
 
 struct _GtkFocusOverlay
 {
@@ -49,6 +49,7 @@ gtk_focus_overlay_snapshot (GtkInspectorOverlay *overlay,
   GtkFocusOverlay *self = GTK_FOCUS_OVERLAY (overlay);
   GtkWidget *focus;
   graphene_rect_t bounds;
+  int nx, ny;
 
   if (!GTK_IS_NATIVE (widget))
     return;
@@ -66,6 +67,10 @@ gtk_focus_overlay_snapshot (GtkInspectorOverlay *overlay,
   if (!gtk_widget_compute_bounds (focus, widget, &bounds))
     return;
 
+  gtk_native_get_surface_transform (GTK_NATIVE (widget), &nx, &ny);
+  bounds.origin.x += nx;
+  bounds.origin.y += ny;
+
   gtk_snapshot_append_color (snapshot, &self->color, &bounds);
 }
 
index 5af4176418a93503939b30d6a142055c461fc65a..e03584ea8f5fc45832b891d85df6d181a981a984 100644 (file)
@@ -34,7 +34,7 @@
 #include "gtkwidgetprivate.h"
 #include "gtkeventcontrollermotion.h"
 #include "gtkeventcontrollerkey.h"
-#include "gtknative.h"
+#include "gtknativeprivate.h"
 #include "gtkwindowprivate.h"
 
 static GtkWidget *
@@ -51,9 +51,13 @@ find_widget_at_pointer (GdkDevice *device)
   if (widget)
     {
       double x, y;
+      int nx, ny;
 
       gdk_surface_get_device_position (gtk_native_get_surface (GTK_NATIVE (widget)),
                                        device, &x, &y, NULL);
+      gtk_native_get_surface_transform (GTK_NATIVE (widget), &nx, &ny);
+      x -= nx;
+      y -= ny;
 
       widget = gtk_widget_pick (widget, x, y, GTK_PICK_INSENSITIVE|GTK_PICK_NON_TARGETABLE);
     }
index f1afa20acb8e55d6e642b25eb6ef3b19d86c6fcc..67cef77ef7c9a44999177c1e83c3b5499f4b84bc 100644 (file)
@@ -5,6 +5,7 @@
 #include "gtkcssstyleprivate.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkcssnumbervalueprivate.h"
+#include "gtknativeprivate.h"
 
 struct _GtkLayoutOverlay
 {
@@ -156,7 +157,13 @@ gtk_layout_overlay_snapshot (GtkInspectorOverlay *overlay,
                              GskRenderNode       *node,
                              GtkWidget           *widget)
 {
+  int nx, ny;
+
+  gtk_native_get_surface_transform (GTK_NATIVE (widget), &nx, &ny);
+  gtk_snapshot_save (snapshot);
+  gtk_snapshot_translate (snapshot, &(graphene_point_t){ nx, ny });
   recurse_child_widgets (widget, snapshot);
+  gtk_snapshot_restore (snapshot);
 }
 
 static void