From f71a2002ba307f48d2e06984a80e4048189ef140 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 17 May 2023 13:53:49 -0700 Subject: [PATCH] display-picture: use compute_point() The gtk_widget_translate_coordinates() API is now deprecated, so use the compute_point() API and ensure that we can translate to the target widget. --- lib/mks-display-picture.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/mks-display-picture.c b/lib/mks-display-picture.c index 5f115b5..f4154f5 100644 --- a/lib/mks-display-picture.c +++ b/lib/mks-display-picture.c @@ -218,17 +218,20 @@ mks_display_picture_legacy_event_cb (MksDisplayPicture *self, if (gdk_event_get_position (event, &x, &y)) { + graphene_point_t translated; double guest_x, guest_y; x -= translate_x; y -= translate_y; - gtk_widget_translate_coordinates (GTK_WIDGET (native), - GTK_WIDGET (self), - x, y, &x, &y); + if (!gtk_widget_compute_point (GTK_WIDGET (native), + GTK_WIDGET (self), + &GRAPHENE_POINT_INIT (x, y), + &translated)) + break; - guest_x = floor (x) / area.size.width * guest_width; - guest_y = floor (y) / area.size.height * guest_height; + guest_x = floor (translated.x) / area.size.width * guest_width; + guest_y = floor (translated.y) / area.size.height * guest_height; guest_x = CLAMP (guest_x, 0, guest_width); guest_y = CLAMP (guest_y, 0, guest_width);