+ show_verbose_time_cursor (drag_info.last_frame_position, 10);
+
+ if (drag_info.copy && drag_info.move_threshold_passed && drag_info.want_move_threshold) {
+
+ drag_info.want_move_threshold = false; // don't copy again
+
+ /* this is committed in the grab finished callback. */
+
+ begin_reversible_command (_("Drag region copy"));
+
+ /* duplicate the region(s) */
+
+ vector<RegionView*> new_regionviews;
+
+ set<Playlist*> affected_playlists;
+ pair<set<Playlist*>::iterator,bool> insert_result;
+
+ for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
+ RegionView* rv;
+
+ rv = (*i);
+
+ Playlist* to_playlist = rv->region().playlist();
+ RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
+
+ insert_result = affected_playlists.insert (to_playlist);
+ if (insert_result.second) {
+ session->add_command (new MementoUndoCommand<Playlist>(*to_playlist, to_playlist->get_state()));
+ }
+
+ latest_regionview = 0;
+
+ sigc::connection c = atv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
+
+ /* create a new region with the same name. */
+
+ // FIXME: ew. need a (virtual) Region::duplicate() or something?
+ Region* newregion = NULL;
+ if (dynamic_cast<AudioRegion*>(&rv->region()))
+ newregion = new AudioRegion (dynamic_cast<AudioRegion&>(rv->region()));
+ else if (dynamic_cast<MidiRegion*>(&rv->region()))
+ newregion = new MidiRegion (dynamic_cast<MidiRegion&>(rv->region()));
+ assert(newregion);
+
+ /* if the original region was locked, we don't care */
+
+ newregion->set_locked (false);
+
+ to_playlist->add_region (*newregion, (jack_nframes_t) (rv->region().position() * atv->get_diskstream()->speed()));
+
+ c.disconnect ();
+
+ if (latest_regionview) {
+ new_regionviews.push_back (latest_regionview);
+ }
+ }
+
+ if (new_regionviews.empty()) {
+ return;
+ }
+
+ /* reset selection to new regionviews */
+
+ selection->set (new_regionviews);
+
+ /* reset drag_info data to reflect the fact that we are dragging the copies */
+
+ drag_info.data = new_regionviews.front();
+ swap_grab (new_regionviews.front()->get_canvas_group (), 0, event->motion.time);
+ }