inspector: Take surface transform into account
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user