summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2020-05-20 09:22:41 +0200
committerTimm Bäder <mail@baedert.org>2020-05-20 17:06:54 +0200
commita5e7e72dd8484f9bfcfb8b2d1400c314ed6f1482 (patch)
treea7287f3943479305d45edc5a74820f06e12a2050
parent8e8e869853dafbf881d2859ef2c859d55efab4a0 (diff)
downloadgtk+-a5e7e72dd8484f9bfcfb8b2d1400c314ed6f1482.tar.gz
inspector: Fix overlay coordinates
Get the native transform only once, for all overlays. Unfortunately we have to undo this for the updates overlay since that one gets values in surface coordinates.
-rw-r--r--gtk/inspector/focusoverlay.c5
-rw-r--r--gtk/inspector/updatesoverlay.c11
-rw-r--r--gtk/inspector/window.c5
3 files changed, 14 insertions, 7 deletions
diff --git a/gtk/inspector/focusoverlay.c b/gtk/inspector/focusoverlay.c
index d96181c19f..54231f5820 100644
--- a/gtk/inspector/focusoverlay.c
+++ b/gtk/inspector/focusoverlay.c
@@ -49,7 +49,6 @@ gtk_focus_overlay_snapshot (GtkInspectorOverlay *overlay,
GtkFocusOverlay *self = GTK_FOCUS_OVERLAY (overlay);
GtkWidget *focus;
graphene_rect_t bounds;
- double nx, ny;
if (!GTK_IS_NATIVE (widget))
return;
@@ -67,10 +66,6 @@ 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/updatesoverlay.c b/gtk/inspector/updatesoverlay.c
index 46e1661b81..18f1087c16 100644
--- a/gtk/inspector/updatesoverlay.c
+++ b/gtk/inspector/updatesoverlay.c
@@ -172,6 +172,14 @@ gtk_updates_overlay_snapshot (GtkInspectorOverlay *overlay,
GtkUpdate *draw;
gint64 now;
GList *l;
+ double native_x, native_y;
+
+ if (!GTK_IS_NATIVE (widget))
+ return;
+
+ /* The coordinates we're getting from GdkSurface API are in GdkSurface coordinate spaces,
+ * but we're snapshotting in widget space, so we need to transform */
+ gtk_native_get_surface_transform (GTK_NATIVE (widget), &native_x, &native_y);
updates = gtk_update_overlay_lookup_for_widget (self, widget, TRUE);
now = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
@@ -226,7 +234,8 @@ gtk_updates_overlay_snapshot (GtkInspectorOverlay *overlay,
cairo_region_get_rectangle (draw->region, i, &rect);
gtk_snapshot_append_color (snapshot,
&(GdkRGBA) { 1, 0, 0, 0.4 * (1 - progress) },
- &GRAPHENE_RECT_INIT(rect.x, rect.y, rect.width, rect.height));
+ &GRAPHENE_RECT_INIT(rect.x - native_x, rect.y - native_y,
+ rect.width, rect.height));
}
}
}
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index a06454407f..16431a7657 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -605,12 +605,15 @@ gtk_inspector_prepare_render (GtkWidget *widget,
{
GtkSnapshot *snapshot;
GList *l;
+ double native_x, native_y;
snapshot = gtk_snapshot_new ();
gtk_snapshot_append_node (snapshot, node);
+ gtk_native_get_surface_transform (GTK_NATIVE (widget), &native_x, &native_y);
+
gtk_snapshot_save (snapshot);
- gtk_snapshot_transform (snapshot, gtk_widget_get_transform (widget));
+ gtk_snapshot_translate (snapshot, &(graphene_point_t) { native_x, native_y });
for (l = iw->overlays; l; l = l->next)
{