From 6bde5017f5caf86406ec3e8a6d087676611e2e52 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 1 Nov 2020 22:29:33 -0800 Subject: [PATCH] Mixer,Timeline: Fix port connection drag and drop between applications. --- mixer/src/JACK_Module.C | 5 ++-- timeline/src/Track.C | 51 +++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/mixer/src/JACK_Module.C b/mixer/src/JACK_Module.C index 8672285..5c2971e 100644 --- a/mixer/src/JACK_Module.C +++ b/mixer/src/JACK_Module.C @@ -614,13 +614,12 @@ JACK_Module::handle ( int m ) if ( Fl::event_inside( output_connection_handle ) || Fl::event_inside( output_connection2_handle ) || Fl::event_inside( input_connection_handle ) ) - { fl_cursor( FL_CURSOR_HAND ); - } else fl_cursor( FL_CURSOR_DEFAULT ); - Module::handle(m); + /* This calls Fl_Group::handle() which somehow prevent DND FL_PASTE event from being delivered later */ + /* Module::handle(m); */ return 1; case FL_ENTER: case FL_DND_ENTER: diff --git a/timeline/src/Track.C b/timeline/src/Track.C index 043a6af..084dd96 100644 --- a/timeline/src/Track.C +++ b/timeline/src/Track.C @@ -1081,7 +1081,8 @@ Track::handle ( int m ) case FL_DND_DRAG: case FL_DND_RELEASE: case FL_PASTE: - if ( Fl::event_x() > Track::width() ) + if ( dragging != ((Track_Header*)child(0))->output_connector_handle && + Fl::event_x() > Track::width() ) return sequence()->handle(m); default: break; @@ -1122,6 +1123,7 @@ Track::handle ( int m ) if ( Fl::event_button1() && Fl::event_inside( ((Track_Header*)child(0))->color_box ) ) { dragging = this; + fl_cursor( FL_CURSOR_MOVE ); return 1; } if ( Fl::event_button1() && Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) ) @@ -1144,29 +1146,46 @@ Track::handle ( int m ) case FL_ENTER: case FL_LEAVE: case FL_MOVE: - if ( Fl::event_x() >= Track::width() ) + + if ( dragging != ((Track_Header*)child(0))->output_connector_handle && + Fl::event_x() >= Track::width() ) { return Fl_Group::handle(m); } + else + { + if ( Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) || + Fl::event_inside( ((Track_Header*)child(0))->input_connector_handle ) || + Fl::event_inside( ((Track_Header*)child(0))->color_box ) ) + fl_cursor( FL_CURSOR_HAND ); + } return 1; case FL_DND_ENTER: return 1; case FL_DND_LEAVE: - if ( ! Fl::event_inside(this) && this == receptive_to_drop ) - { + /* if ( ! Fl::event_inside(this) )// && this == receptive_to_drop ) */ + /* { */ receptive_to_drop = 0; redraw(); Fl::selection_owner(0); - } + /* } */ return 1; case FL_RELEASE: if ( dragging == this ) { dragging = NULL; timeline->insert_track( this, timeline->event_inside() ); - return 1; + fl_cursor( FL_CURSOR_DEFAULT ); + return 1; } + else if ( dragging == ((Track_Header*)child(0))->output_connector_handle ) + { + dragging = NULL; + fl_cursor( FL_CURSOR_DEFAULT ); + return 1; + } + return Fl_Group::handle( m ); break; case FL_DND_RELEASE: @@ -1253,6 +1272,9 @@ Track::handle ( int m ) } case FL_DRAG: { + if ( Fl::event_is_click() ) + return 1; + if ( this != Fl::selection_owner() && Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) ) { @@ -1262,8 +1284,9 @@ Track::handle ( int m ) for ( unsigned int i = 0; i < output.size(); ++i ) { char *s2; - asprintf(&s2, "jack.port://%s:%s\r\n", instance_name, output[i].name() ); - + asprintf(&s2, "jack.port://%s\r\n", + output[i].jack_name() ); + s = (char*)realloc( s, strlen( s ) + strlen( s2 ) + 1 ); strcat( s, s2 ); @@ -1275,14 +1298,12 @@ Track::handle ( int m ) free( s ); + dragging = ((Track_Header*)child(0))->output_connector_handle; + Fl::dnd(); - - return 1; - } - else - { - return 1; - } + } + + return 1; } default: return Fl_Group::handle( m );