+void
+Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
+ int x, int y,
+ const SelectionData& /*data*/,
+ guint /*info*/, guint /*time*/)
+{
+ GdkEvent event;
+ double px;
+ double py;
+
+ event.type = GDK_MOTION_NOTIFY;
+ event.button.x = x;
+ event.button.y = y;
+ /* assume we're dragging with button 1 */
+ event.motion.state = Gdk::BUTTON1_MASK;
+ framepos_t const pos = window_event_sample (&event, &px, &py);
+
+ boost::shared_ptr<Region> region = _regions->get_dragged_region ();
+ if (!region) { return; }
+
+ RouteTimeAxisView* rtav = 0;
+ std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (py, false);
+
+ if (tv.first != 0) {
+ rtav = dynamic_cast<RouteTimeAxisView*> (tv.first);
+ } else {
+ try {
+ if (boost::dynamic_pointer_cast<AudioRegion> (region)) {
+ uint32_t output_chan = region->n_channels();
+ if ((Config->get_output_auto_connect() & AutoConnectMaster) && session()->master_out()) {
+ output_chan = session()->master_out()->n_inputs().n_audio();
+ }
+ list<boost::shared_ptr<AudioTrack> > audio_tracks;
+ audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order);
+ rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (audio_tracks.front()));
+ } else if (boost::dynamic_pointer_cast<MidiRegion> (region)) {
+ ChanCount one_midi_port (DataType::MIDI, 1);
+ list<boost::shared_ptr<MidiTrack> > midi_tracks;
+ midi_tracks = session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr<ARDOUR::PluginInfo>(),
+ (ARDOUR::Plugin::PresetRecord*) 0,
+ (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order);
+ rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (midi_tracks.front()));
+ } else {
+ return;
+ }
+ } catch (...) {
+ error << _("Could not create new track after region placed in the drop zone") << endmsg;
+ return;