Page MenuHome

.blend files opening at startup and when dropped on application icon (OSX)
Closed, ArchivedPublicPATCH

Description

This short patch implements the handling of the GHOST_kEventDraggingDropOnIcon event.

The sending of this event is already implemented in Ghost-Cocoa.

So this now enables to:
- open a .blend file by double-clicking on it in the Finder
- open a .blend file that has been dropped on Blender icon in the dock.

Event Timeline

Hi Damien,

I had a quick look at this, and I suspect it's not really the right way to do it, though it's probably not possible to do it a 'right way' at the present.

I don't think reading the file should be handled inside the ghost_event_proc function, that should be a bare minimum of translating Ghost events to Blender events - really low level stuff. The problem here at the moment is that there are no Blender drag/drop events to convert to.

So I think this ties into the larger issue of Drag and Drop in Blender in general. Ideally, that Ghost drop event would get converted into a Blender drop event, and then processed further down the chain along with other events. Although this patch is just about dropping onto the icon, in the future we'd be able to do things like checking for Window drop events, what Area something has been dropped into, for example dragging and dropping a movie file into the sequence editor. This sort of thing should be handled further down the pipeline.

I remember vekoon had an initial patch for an initial version of a drag and drop system in Blender, but Ton asked him to wait until after SIGGRAPH, when Ton could have a look at that. I think it's probably time to raise that issue again, and get work started on Blender's drag and drop system - then the ghost drop event can just connect to that...

Hi Matt,

Thanks for the review!

I fully agree with you about the handling of the "regular" drag & drop events, and I'll ask Ton about its status on irc next week.

In fact, the event used here (drop on icon) is specific in the fact it is not linked to any window, and thus it can't be pushed further in Blender event pipeline in ghost_event_proc, as the next stage is handling of events of each window.
There is a similar event (GHOST_kEventQuit) that is handled directly in this function (call to WM_exit).

Another consideration: I don't think a similar event exists in any OS other than OSX, and dropping anything different from a registered document file on the dock icon needs a hack. => So maybe this event shall be renamed "OpenBlendFile" ?

Now that Ton has implemented DND support could you update the patch to work with that?

In fact, even if the action looks like DND, in Cocoa implementation, it is not. It is a "openFile" NSApplication delegate callback.
To avoid any confusion, I'll replace this event by a GHOST_kEventOpenMainFile event (with the filename as a string parameter), and code the Open_MainFile operator call in wm to handle it. And eventually commit it.

I've updated the OS DND wiki page to reflect this:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DragnDrop

Updated version implemented in svn rev 26496

Damien Plisson (damien78) changed the task status from Unknown Status to Unknown Status.Feb 1 2010, 10:13 AM