[gtk/wip/chergert/fix-macos-surface-under-pointer] macos: fix discovery of surface under pointer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/fix-macos-surface-under-pointer] macos: fix discovery of surface under pointer
- Date: Mon, 19 Oct 2020 19:41:24 +0000 (UTC)
commit eb82b2a9ca3c498b6a34f3e2313a48e4e31a17e3
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 19 11:24:34 2020 -0700
macos: fix discovery of surface under pointer
gdk/macos/gdkmacosdisplay-translate.c | 39 +++++++++++++++++------------------
1 file changed, 19 insertions(+), 20 deletions(-)
---
diff --git a/gdk/macos/gdkmacosdisplay-translate.c b/gdk/macos/gdkmacosdisplay-translate.c
index a828f127d9..849d433634 100644
--- a/gdk/macos/gdkmacosdisplay-translate.c
+++ b/gdk/macos/gdkmacosdisplay-translate.c
@@ -713,44 +713,43 @@ find_surface_under_pointer (GdkMacosDisplay *self,
int *y)
{
GdkPointerSurfaceInfo *info;
- GdkMacosSurface *found;
- GdkSurface *surface = NULL;
+ GdkMacosSurface *surface;
+ GdkDevice *pointer;
GdkSeat *seat;
int x_tmp, y_tmp;
seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
- info = _gdk_display_get_pointer_info (GDK_DISPLAY (self),
- gdk_seat_get_pointer (seat));
-
- if ((found = _gdk_macos_display_get_surface_at_display_coords (self,
- screen_point.x,
- screen_point.y,
- &x_tmp,
- &y_tmp)))
- {
- g_set_object (&info->surface_under_pointer, surface);
- surface = GDK_SURFACE (found);
- }
+ pointer = gdk_seat_get_pointer (seat);
+ info = _gdk_display_get_pointer_info (GDK_DISPLAY (self), pointer);
+
+ surface = _gdk_macos_display_get_surface_at_display_coords (self,
+ screen_point.x,
+ screen_point.y,
+ &x_tmp,
+ &y_tmp);
- if (surface)
+ if (surface != NULL)
{
_gdk_macos_display_from_display_coords (self,
screen_point.x,
screen_point.y,
&x_tmp, &y_tmp);
- *x = x_tmp - GDK_MACOS_SURFACE (surface)->root_x;
- *y = y_tmp - GDK_MACOS_SURFACE (surface)->root_y;
+ *x = x_tmp - surface->root_x;
+ *y = y_tmp - surface->root_y;
/* If the coordinates are out of window bounds, this surface is not
* under the pointer and we thus return NULL. This can occur when
* surface under pointer has not yet been updated due to a very recent
* window resize. Alternatively, we should no longer be relying on
* the surface_under_pointer value which is maintained in gdkwindow.c.
*/
- if (*x < 0 || *y < 0 || *x >= surface->width || *y >= surface->height)
- return NULL;
+ if (*x < 0 ||
+ *y < 0 ||
+ *x >= GDK_SURFACE (surface)->width ||
+ *y >= GDK_SURFACE (surface)->height)
+ surface = NULL;
}
- return surface;
+ return GDK_SURFACE (surface);
}
static GdkSurface *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]