From: Matthias Clasen Date: Sun, 17 May 2020 06:10:56 +0000 (-0400) Subject: inspector: Take surface transform into account X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~17^2~24^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=38af49d4fd9a341d557e50a0f4136d43b5d4c3da;p=gtk4.git inspector: Take surface transform into account --- diff --git a/gtk/inspector/focusoverlay.c b/gtk/inspector/focusoverlay.c index 1ed260d077..3df045936f 100644 --- a/gtk/inspector/focusoverlay.c +++ b/gtk/inspector/focusoverlay.c @@ -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); } diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c index 5af4176418..e03584ea8f 100644 --- a/gtk/inspector/inspect-button.c +++ b/gtk/inspector/inspect-button.c @@ -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); } diff --git a/gtk/inspector/layoutoverlay.c b/gtk/inspector/layoutoverlay.c index f1afa20acb..67cef77ef7 100644 --- a/gtk/inspector/layoutoverlay.c +++ b/gtk/inspector/layoutoverlay.c @@ -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