macos: allow dropping NSEvent without propagation
authorChristian Hergert <christian@hergert.me>
Wed, 9 Mar 2022 21:19:22 +0000 (13:19 -0800)
committerChristian Hergert <chergert@redhat.com>
Wed, 16 Mar 2022 19:25:10 +0000 (12:25 -0700)
There are cases we might want to consume a NSEvent without creating a
GdkEvent or passing it along to the NSApplication for processing. This
creates a new value we can use and check against to propagate that without
having to do out parameters at the slightly odd invalid pointer value for
a GdkEvent (similar to how MMAP_FAILED is done).

gdk/macos/gdkmacosdisplay-private.h
gdk/macos/gdkmacosdisplay.c

index ef17618d615cefd44f206213592802716a9a6bd8..72b5f5cd57db22551b7f6ab422963c8698e97a11 100644 (file)
@@ -43,6 +43,8 @@ G_BEGIN_DECLS
 #define GIC_FILTER_PASSTHRU  0
 #define GIC_FILTER_FILTERED  1
 
+#define GDK_MACOS_EVENT_DROP (GdkEvent *)GSIZE_TO_POINTER(1)
+
 struct _GdkMacosDisplay
 {
   GdkDisplay parent_instance;
index bc58c2a6f346953aa15858d2b48e9713171a205f..9fbfac49ed1e480f7eb9ce067e6c4d859946b325 100644 (file)
@@ -314,7 +314,11 @@ gdk_macos_display_queue_events (GdkDisplay *display)
     {
       GdkEvent *event = _gdk_macos_display_translate (self, nsevent);
 
-      if (event != NULL)
+      if (event == GDK_MACOS_EVENT_DROP)
+        {
+          [nsevent release];
+        }
+      else if (event != NULL)
         {
           push_nsevent (event, nsevent);
           _gdk_windowing_got_event (GDK_DISPLAY (self),