aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw
diff options
context:
space:
mode:
authormarius a. eriksen <marius.eriksen@gmail.com>2014-12-23 20:45:35 -0800
committerRuss Cox <rsc@google.com>2015-06-03 15:26:27 +0000
commitd52bdd3356137cf67a3458fdee5c94fdec4337e1 (patch)
tree99f1d4baf8e13448992224b7995e675cd19c4b10 /src/cmd/devdraw
parent25822e8da338df2c15959bd8d347f230dc2b2d89 (diff)
downloadplan9port-d52bdd3356137cf67a3458fdee5c94fdec4337e1.tar.gz
plan9port-d52bdd3356137cf67a3458fdee5c94fdec4337e1.tar.bz2
plan9port-d52bdd3356137cf67a3458fdee5c94fdec4337e1.zip
devdraw: plumb drag-n-dropped files
Change-Id: I7585870aee57c7482ebdd19c117be7982123ce79 Reviewed-on: https://plan9port-review.googlesource.com/1130 Reviewed-by: Russ Cox <rsc@google.com>
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r--src/cmd/devdraw/cocoa-screen.m39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
index 03355362..fc73814b 100644
--- a/src/cmd/devdraw/cocoa-screen.m
+++ b/src/cmd/devdraw/cocoa-screen.m
@@ -159,6 +159,7 @@ static NSRect dilate(NSRect);
detachDrawingThread:@selector(callservep9p:)
toTarget:[self class] withObject:nil];
}
+
- (void)windowDidBecomeKey:(id)arg
{
getmousepos();
@@ -298,6 +299,41 @@ attachscreen(char *label, char *winsize)
[win.content setHidden:NO];
[super deminiaturize:arg];
}
+
+- (NSDragOperation)draggingEntered:(id)arg
+{
+ NSPasteboard *b;
+ NSDragOperation op;
+
+ op = [arg draggingSourceOperationMask];
+ b = [arg draggingPasteboard];
+
+ if([[b types] containsObject:NSFilenamesPboardType])
+ if(op&NSDragOperationLink)
+ return NSDragOperationLink;
+
+ return NSDragOperationNone;
+}
+
+- (BOOL)performDragOperation:(id)arg
+{
+ NSPasteboard *b;
+ NSArray *files;
+ int i, n;
+
+ b = [arg draggingPasteboard];
+ if(![[b types] containsObject:NSFilenamesPboardType])
+ return NO;
+
+ files = [b propertyListForType:NSFilenamesPboardType];
+ n = [files count];
+ for(i=0; i<n; i++)
+ if(fork() == 0)
+ execl("macedit", "macedit", [[files objectAtIndex:i] UTF8String], nil);
+
+ return YES;
+}
+
@end
double
@@ -354,6 +390,9 @@ makewin(char *s)
#endif
[w setContentMinSize:NSMakeSize(128,128)];
+ [w registerForDraggedTypes:[NSArray arrayWithObjects:
+ NSFilenamesPboardType, nil]];
+
win.ofs[0] = w;
win.ofs[1] = [[appwin alloc]
initWithContentRect:sr