[gtk/wip/chergert/quartz4u] macos: locate surface at pointer position
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/quartz4u] macos: locate surface at pointer position
- Date: Mon, 4 May 2020 19:28:21 +0000 (UTC)
commit 6ce3c33793f7ff0bd6bc6cdaa21b0d2436664bdc
Author: Christian Hergert <chergert redhat com>
Date: Mon May 4 12:16:46 2020 -0700
macos: locate surface at pointer position
gdk/macos/gdkmacosdevice.c | 39 ++++++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/gdk/macos/gdkmacosdevice.c b/gdk/macos/gdkmacosdevice.c
index 0f8e47c552..82c956e690 100644
--- a/gdk/macos/gdkmacosdevice.c
+++ b/gdk/macos/gdkmacosdevice.c
@@ -25,7 +25,8 @@
#include "gdkmacoscursor-private.h"
#include "gdkmacosdevice.h"
-#include "gdkmacossurface.h"
+#include "gdkmacosdisplay-private.h"
+#include "gdkmacossurface-private.h"
struct _GdkMacosDevice
{
@@ -59,21 +60,45 @@ gdk_macos_device_set_surface_cursor (GdkDevice *device,
}
}
-static void
-gdk_macos_device_finalize (GObject *object)
+static GdkSurface *
+gdk_macos_device_surface_at_position (GdkDevice *device,
+ gdouble *win_x,
+ gdouble *win_y,
+ GdkModifierType *state,
+ gboolean get_toplevel)
{
- G_OBJECT_CLASS (gdk_macos_device_parent_class)->finalize (object);
+ GdkMacosDisplay *display;
+ GdkMacosSurface *surface;
+ NSPoint point;
+ gint x;
+ gint y;
+
+ g_assert (GDK_IS_MACOS_DEVICE (device));
+ g_assert (win_x != NULL);
+ g_assert (win_y != NULL);
+
+ point = [NSEvent mouseLocation];
+ display = GDK_MACOS_DISPLAY (gdk_device_get_display (device));
+
+ if (state != NULL)
+ *state = (_gdk_macos_display_get_current_keyboard_modifiers (display) |
+ _gdk_macos_display_get_current_mouse_modifiers (display));
+
+ surface = _gdk_macos_display_get_surface_at_display_coords (display, point.x, point.y, &x, &y);
+
+ *win_x = x;
+ *win_y = y;
+
+ return GDK_SURFACE (surface);
}
static void
gdk_macos_device_class_init (GdkMacosDeviceClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
- object_class->finalize = gdk_macos_device_finalize;
-
device_class->set_surface_cursor = gdk_macos_device_set_surface_cursor;
+ device_class->surface_at_position = gdk_macos_device_surface_at_position;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]