Files

90 lines
2.4 KiB
Diff
Raw Permalink Normal View History

2023-03-25 23:35:59 +01:00
Patch drag & drop handler for old versions of macOS.
Currently this is a hack which simply disables most of the code.
This hack likely doesn't work.
--- ./src/interface/dropsource_mac.mm.orig 2022-06-01 15:56:30.000000000 +0200
+++ ./src/interface/dropsource_mac.mm 2023-03-25 20:24:32.000000000 +0100
@@ -7,6 +7,7 @@
#include <wx/utils.h>
#include <wx/filename.h>
+#include <AvailabilityMacros.h>
#include <AppKit/AppKit.h>
wxDragResult NSFileDragOperationToWxDragResult(NSDragOperation code)
@@ -30,6 +31,7 @@
return wxDragNone;
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
@interface FileDropSourceDelegate : NSObject<NSDraggingSource>
{
BOOL dragFinished;
@@ -125,7 +127,9 @@
}
@end
+#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
@interface FilePromiseProviderDelegate : NSObject<NSFilePromiseProviderDelegate>
{
NSOperationQueue * workQueue;
@@ -142,7 +146,9 @@
{
self = [super init];
workQueue = [[NSOperationQueue alloc] init];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
workQueue.qualityOfService = NSQualityOfServiceUserInitiated;
+#endif
path = nil;
return self;
}
@@ -185,6 +191,7 @@
return workQueue;
}
@end
+#endif
wxDragResult DropSource::DoFileDragDrop(int flags)
{
@@ -200,8 +207,10 @@
NSEvent* theEvent = (NSEvent*)wxTheApp->MacGetCurrentEvent();
wxASSERT_MSG(theEvent, "DoDragDrop must be called in response to a mouse down or drag event.");
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
FileDropSourceDelegate* delegate = [[FileDropSourceDelegate alloc] init];
[delegate setImplementation:this flags:flags];
+#endif
// add a dummy square as dragged image for the moment,
// TODO: proper drag image for data
@@ -223,6 +232,7 @@
NSMutableArray *items = [[NSMutableArray alloc] init];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
FilePromiseProviderDelegate * filePromiseDelegate = [[FilePromiseProviderDelegate alloc] init];
NSDraggingItem* draggingItem = [[NSDraggingItem alloc] initWithPasteboardWriter:[filePromiseDelegate pasteboardWriter]];
[draggingItem setDraggingFrame:NSMakeRect(p.x, p.y, 16, 16) contents:image];
@@ -248,6 +258,7 @@
[delegate release];
[image release];
[filePromiseDelegate release];
+#endif
wxWindow* mouseUpTarget = wxWindow::GetCapture();
@@ -261,6 +272,9 @@
wxevent.SetEventType(wxEVT_LEFT_UP);
mouseUpTarget->HandleWindowEvent(wxevent);
}
-
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
return result;
+#else
+ return wxDragError;
+#endif
}