From 057bda6cd7a191d2f663443439c29ce7ca663577 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 17 Jun 2021 13:23:18 -0700 Subject: [PATCH] macos: register known clipboard types for drag destination --- gdk/macos/GdkMacosWindow.c | 4 ++++ gdk/macos/gdkmacosclipboard-private.h | 1 + gdk/macos/gdkmacosclipboard.c | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c index 3afcdeb826..8f3817ee6a 100644 --- a/gdk/macos/GdkMacosWindow.c +++ b/gdk/macos/GdkMacosWindow.c @@ -28,6 +28,7 @@ #import "GdkMacosGLView.h" #import "GdkMacosWindow.h" +#include "gdkmacosclipboard-private.h" #include "gdkmacosdisplay-private.h" #include "gdkmacosmonitor-private.h" #include "gdkmacossurface-private.h" @@ -287,6 +288,9 @@ typedef NSString *CALayerContentsGravity; [self setContentView:view]; [view release]; + /* TODO: We might want to make this more extensible at some point */ + _gdk_macos_clipboard_register_drag_types (self); + return self; } diff --git a/gdk/macos/gdkmacosclipboard-private.h b/gdk/macos/gdkmacosclipboard-private.h index 01a562c2b8..e612f73edd 100644 --- a/gdk/macos/gdkmacosclipboard-private.h +++ b/gdk/macos/gdkmacosclipboard-private.h @@ -40,6 +40,7 @@ void _gdk_macos_clipboard_check_externally_modified (GdkMacosClipbo NSPasteboardType _gdk_macos_clipboard_to_ns_type (const char *mime_type, NSPasteboardType *alternate); const char *_gdk_macos_clipboard_from_ns_type (NSPasteboardType ns_type); +void _gdk_macos_clipboard_register_drag_types (NSWindow *window); @interface GdkMacosClipboardDataProvider : NSObject { diff --git a/gdk/macos/gdkmacosclipboard.c b/gdk/macos/gdkmacosclipboard.c index 7ddf47d83b..ea0d19f923 100644 --- a/gdk/macos/gdkmacosclipboard.c +++ b/gdk/macos/gdkmacosclipboard.c @@ -622,4 +622,17 @@ on_data_ready_cb (GObject *object, write_request_free (wr); } +void +_gdk_macos_clipboard_register_drag_types (NSWindow *window) +{ + [window registerForDraggedTypes:[NSArray arrayWithObjects:PTYPE(STRING), + PTYPE(PBOARD), + PTYPE(URL), + PTYPE(FILE_URL), + PTYPE(COLOR), + PTYPE(TIFF), + PTYPE(PNG), + nil]]; +} + @end