[gtk/wip/chergert/quartz4u] macos: add helper to synthesize motion
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/quartz4u] macos: add helper to synthesize motion
- Date: Fri, 8 May 2020 00:04:03 +0000 (UTC)
commit b19a54b673208e013472d4b532e6835142dcbf39
Author: Christian Hergert <chergert redhat com>
Date: Thu May 7 16:51:26 2020 -0700
macos: add helper to synthesize motion
gdk/macos/gdkmacosdisplay-private.h | 2 ++
gdk/macos/gdkmacosdisplay-translate.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
---
diff --git a/gdk/macos/gdkmacosdisplay-private.h b/gdk/macos/gdkmacosdisplay-private.h
index 2530339e66..6d31144415 100644
--- a/gdk/macos/gdkmacosdisplay-private.h
+++ b/gdk/macos/gdkmacosdisplay-private.h
@@ -62,6 +62,8 @@ void _gdk_macos_display_add_frame_callback (GdkMacosDisp
GdkMacosSurface *surface);
void _gdk_macos_display_remove_frame_callback (GdkMacosDisplay *self,
GdkMacosSurface *surface);
+void _gdk_macos_display_synthesize_motion (GdkMacosDisplay *self,
+ GdkMacosSurface *surface);
G_END_DECLS
diff --git a/gdk/macos/gdkmacosdisplay-translate.c b/gdk/macos/gdkmacosdisplay-translate.c
index d0eb822c7d..ae5abb7a7b 100644
--- a/gdk/macos/gdkmacosdisplay-translate.c
+++ b/gdk/macos/gdkmacosdisplay-translate.c
@@ -813,3 +813,37 @@ _gdk_macos_display_translate (GdkMacosDisplay *self,
return ret;
}
+void
+_gdk_macos_display_synthesize_motion (GdkMacosDisplay *self,
+ GdkMacosSurface *surface)
+{
+ GdkModifierType state;
+ GdkEvent *event;
+ GdkSeat *seat;
+ NSPoint point;
+ GList *node;
+ int x;
+ int y;
+
+ g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
+ g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
+
+ seat = gdk_display_get_default_seat (GDK_DISPLAY (self));
+ point = [NSEvent mouseLocation];
+ _gdk_macos_display_from_display_coords (self, point.x, point.y, &x, &y);
+
+ state = _gdk_macos_display_get_current_keyboard_modifiers (self) |
+ _gdk_macos_display_get_current_mouse_modifiers (self);
+
+ event = gdk_motion_event_new (GDK_SURFACE (surface),
+ gdk_seat_get_pointer (seat),
+ NULL,
+ NULL,
+ get_time_from_ns_event ([NSApp currentEvent]),
+ state,
+ x,
+ y,
+ NULL);
+ node = _gdk_event_queue_append (GDK_DISPLAY (self), event);
+ _gdk_windowing_got_event (GDK_DISPLAY (self), node, event, 0);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]