Skip to content

Commit 7b43c27

Browse files
Mac clipboard: don't create a new dragboard for private-only drags
It isn't needed - we can do this using the main dragboard.
1 parent 6107583 commit 7b43c27

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

engine/src/desktop.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ void MCPlatformHandleDragDrop(MCPlatformWindowRef p_window, bool& r_accepted)
556556
{
557557
MCdispatcher -> wmdragdrop(p_window);
558558

559+
// On some platforms (Mac and iOS), the drag board used for drag-and-drop
560+
// operations may not be the main drag board. Reset the drag board back to
561+
// the main one after the drag has left.
562+
MCAutoRefcounted<MCRawClipboard> t_dragboard(MCRawClipboard::CreateSystemDragboard());
563+
MCdragboard->Rebind(t_dragboard);
564+
559565
// PLATFORM-TODO: Should we do more than this? i.e. Should the dragDrop
560566
// message be able to signal refusal?
561567
r_accepted = true;

engine/src/mac-pasteboard.mm

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,9 @@ void MCPlatformDoDragDrop(MCPlatformWindowRef p_window, MCPlatformAllowedDragOpe
8787
// This is required as the OSX drag-and-drop loop requires a pasteboard to
8888
// be specified.
8989
NSPasteboard *t_pboard;
90-
bool t_is_private;
91-
t_is_private = false;
9290
t_pboard = [NSPasteboard pasteboardWithName: NSDragPboard];
9391
if ([[t_pboard pasteboardItems] count] == 0)
9492
{
95-
t_is_private = true;
96-
t_pboard = [NSPasteboard pasteboardWithUniqueName];
97-
9893
NSPasteboardItem *t_item;
9994
t_item = [[[NSPasteboardItem alloc] init] autorelease];
10095
[t_item setString: @"" forType: @"com.runrev.livecode.private"];
@@ -105,9 +100,6 @@ void MCPlatformDoDragDrop(MCPlatformWindowRef p_window, MCPlatformAllowedDragOpe
105100

106101
NSDragOperation t_op;
107102
t_op = [((MCMacPlatformWindow *)p_window) -> GetView() dragImage: t_image offset: t_image_loc allowing: t_allowed_operations pasteboard: t_pboard];
108-
109-
if (t_is_private)
110-
[t_pboard releaseGlobally];
111103

112104
[t_image release];
113105

engine/src/mac-window.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,11 @@ - (BOOL)wantsPeriodicDraggingUpdates
13591359

13601360
- (NSDragOperation)draggingEntered: (id<NSDraggingInfo>)sender
13611361
{
1362-
// Create a wrapper around the drag board for this operation
1363-
MCAutoRefcounted<MCMacRawClipboard> t_dragboard = new MCMacRawClipboard([sender draggingPasteboard]);
1362+
// Create a wrapper around the drag board for this operation if the drag
1363+
// source is outside this instance of LiveCode.
1364+
MCAutoRefcounted<MCMacRawClipboard> t_dragboard;
1365+
if ([sender draggingSource] != nil)
1366+
t_dragboard = new MCMacRawClipboard([sender draggingPasteboard]);
13641367

13651368
NSDragOperation t_ns_operation;
13661369

0 commit comments

Comments
 (0)