macos: register known clipboard types for drag destination

This commit is contained in:
Christian Hergert 2021-06-17 13:23:18 -07:00
parent 352898ae9e
commit 057bda6cd7
3 changed files with 18 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#import "GdkMacosGLView.h" #import "GdkMacosGLView.h"
#import "GdkMacosWindow.h" #import "GdkMacosWindow.h"
#include "gdkmacosclipboard-private.h"
#include "gdkmacosdisplay-private.h" #include "gdkmacosdisplay-private.h"
#include "gdkmacosmonitor-private.h" #include "gdkmacosmonitor-private.h"
#include "gdkmacossurface-private.h" #include "gdkmacossurface-private.h"
@ -287,6 +288,9 @@ typedef NSString *CALayerContentsGravity;
[self setContentView:view]; [self setContentView:view];
[view release]; [view release];
/* TODO: We might want to make this more extensible at some point */
_gdk_macos_clipboard_register_drag_types (self);
return self; return self;
} }

View File

@ -40,6 +40,7 @@ void _gdk_macos_clipboard_check_externally_modified (GdkMacosClipbo
NSPasteboardType _gdk_macos_clipboard_to_ns_type (const char *mime_type, NSPasteboardType _gdk_macos_clipboard_to_ns_type (const char *mime_type,
NSPasteboardType *alternate); NSPasteboardType *alternate);
const char *_gdk_macos_clipboard_from_ns_type (NSPasteboardType ns_type); const char *_gdk_macos_clipboard_from_ns_type (NSPasteboardType ns_type);
void _gdk_macos_clipboard_register_drag_types (NSWindow *window);
@interface GdkMacosClipboardDataProvider : NSObject <NSPasteboardItemDataProvider> @interface GdkMacosClipboardDataProvider : NSObject <NSPasteboardItemDataProvider>
{ {

View File

@ -622,4 +622,17 @@ on_data_ready_cb (GObject *object,
write_request_free (wr); 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 @end