-
Notifications
You must be signed in to change notification settings - Fork 25
/
drop.patch
executable file
·75 lines (61 loc) · 2.56 KB
/
drop.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rst' --exclude='*.po' lazarus/lcl/interfaces/carbon/carbonobject.inc lazarus.w/lcl/interfaces/carbon/carbonobject.inc
--- lazarus/lcl/interfaces/carbon/carbonobject.inc 2013-11-16 10:59:07.000000000 +0000
++ lazarus.w/lcl/interfaces/carbon/carbonobject.inc 2013-11-16 22:03:34.000000000 +0000
@@ -449,6 +449,62 @@
end;
{------------------------------------------------------------------------------
Name: CarbonApp_DragReceive
Handles dropping files on application
------------------------------------------------------------------------------}
function CarbonApp_DragReceive(theWindow: WindowRef; handlerRefCon: UnivPtr; theDrag: DragRef): OSErr; {$IFDEF darwin}mwpascal;{$ENDIF}
var
theItemRef: DragItemRef;
theFlavorData: HFSFlavor;
theDataSize: Size;
theFilename: pchar;
theFileRef: FSRef;
numItems: UInt16;
Files: array of string;
itemNum: UInt16;
begin
SetLength(Files, 0);
numItems := 0;
if CountDragItems(theDrag, numItems) <> noErr then exit;
if numItems > 0 then
for itemNum := 1 to numItems do
begin
if GetDragItemReferenceNumber(theDrag, itemNum, theItemRef) <> noErr then continue;
theDataSize := sizeof(theFlavorData);
if GetFlavorData(theDrag, theItemRef, kDragFlavorTypeHFS, @theFlavorData, theDataSize, 0) <> noErr then continue;
FSpMakeFSRef(theFlavorData.fileSpec, theFileRef);
theFilename := stralloc(1024); //PATH_MAX = 1024
FSRefMakePath(theFileRef, theFilename, StrBufSize(theFilename));
try
SetLength(Files, Length(Files) + 1);
Files[High(Files)] := theFilename;
finally
StrDispose(theFilename);
end;
end;
if Length(Files) > 0 then
begin
if Application <> nil then
begin
if Application.MainForm <> nil then
Application.MainForm.IntfDropFiles(Files);
Application.IntfDropFiles(Files);
end;
end;
Result := noErr;
end;
{------------------------------------------------------------------------------
Name: CarbonApp_Quit
Handles application quit
------------------------------------------------------------------------------}
@@ -1213,6 +1269,8 @@
InstallApplicationEventHandler(RegisterEventHandler(@CarbonApp_LazWake),
1, @TmpSpec, nil, @FAEventHandlerRef[5]);
InstallReceiveHandler(@CarbonApp_DragReceive, nil, nil);
FOpenEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Open));
FQuitEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Quit));
OSError(