@@ -664,13 +664,17 @@ rdp_destroy(struct weston_compositor *ec)
664664b -> debug = NULL ;
665665}
666666
667+ if (b -> persistent_rail_seat )
668+ weston_seat_release (b -> persistent_rail_seat );
669+
667670weston_compositor_shutdown (ec );
668671
669672wl_list_for_each_safe (base ,next ,& ec -> head_list ,compositor_link )
670673rdp_head_destroy (ec ,to_rdp_head (base ));
671674
672675freerdp_listener_free (b -> listener );
673676
677+ free (b -> persistent_rail_seat );
674678free (b -> server_cert );
675679free (b -> server_key );
676680free (b -> rdp_key );
@@ -759,12 +763,14 @@ static void
759763rdp_peer_context_free (freerdp_peer * client ,RdpPeerContext * context )
760764{
761765struct rdp_backend * b ;
766+ rdpSettings * settings ;
762767unsigned i ;
763768
764769if (!context )
765770return ;
766771
767772b = context -> rdpBackend ;
773+ settings = client -> context -> settings ;
768774
769775/* While RDP client is disconnected, keep compositor sleep state */
770776weston_compositor_sleep (b -> compositor );
@@ -800,8 +806,15 @@ rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* context)
800806if (context -> item .flags & RDP_PEER_ACTIVATED ) {
801807weston_seat_release_keyboard (context -> item .seat );
802808weston_seat_release_pointer (context -> item .seat );
803- weston_seat_release (context -> item .seat );
804- free (context -> item .seat );
809+ /* save current seat for future use only when it's not saved yet */
810+ if (settings -> RemoteApplicationMode &&
811+ b -> enable_persistent_rail_seat ) {
812+ assert (!b -> persistent_rail_seat );
813+ b -> persistent_rail_seat = context -> item .seat ;
814+ }else {
815+ weston_seat_release (context -> item .seat );
816+ free (context -> item .seat );
817+ }
805818context -> item .seat = NULL ;
806819context -> item .flags &= ~RDP_PEER_ACTIVATED ;
807820}
@@ -1188,19 +1201,28 @@ xf_peer_activate(freerdp_peer* client)
11881201& xkbRuleNames ,0 );
11891202}
11901203
1204+ if (settings -> RemoteApplicationMode )
1205+ snprintf (seat_name ,sizeof (seat_name ),"RDP Remote Application Client" );
11911206if (settings -> ClientHostname )
11921207snprintf (seat_name ,sizeof (seat_name ),"RDP %s" ,settings -> ClientHostname );
11931208else
11941209snprintf (seat_name ,sizeof (seat_name ),"RDP peer @%s" ,settings -> ClientAddress );
11951210
1196- peersItem -> seat = zalloc (sizeof (* peersItem -> seat ));
1197- if (!peersItem -> seat ) {
1198- xkb_keymap_unref (keymap );
1199- rdp_debug_error (b ,"unable to create a weston_seat\n" );
1200- gotoerror_exit ;
1211+ if (settings -> RemoteApplicationMode &&
1212+ b -> persistent_rail_seat ) {
1213+ /* reuse persistent seat for RAIL connection */
1214+ peersItem -> seat = b -> persistent_rail_seat ;
1215+ b -> persistent_rail_seat = NULL ;
1216+ }else {
1217+ peersItem -> seat = zalloc (sizeof (* peersItem -> seat ));
1218+ if (!peersItem -> seat ) {
1219+ xkb_keymap_unref (keymap );
1220+ rdp_debug_error (b ,"unable to create a weston_seat\n" );
1221+ gotoerror_exit ;
1222+ }
1223+ weston_seat_init (peersItem -> seat ,b -> compositor ,seat_name );
12011224}
12021225
1203- weston_seat_init (peersItem -> seat ,b -> compositor ,seat_name );
12041226weston_seat_init_keyboard (peersItem -> seat ,keymap );
12051227xkb_keymap_unref (keymap );
12061228weston_seat_init_pointer (peersItem -> seat );
@@ -2111,6 +2133,7 @@ rdp_backend_create(struct weston_compositor *compositor,
21112133b -> no_clients_resize = config -> no_clients_resize ;
21122134b -> force_no_compression = config -> force_no_compression ;
21132135b -> redirect_clipboard = config -> redirect_clipboard ;
2136+ b -> enable_persistent_rail_seat = config -> enable_persistent_rail_seat ;
21142137b -> rdp_monitor_refresh_rate = config -> rdp_monitor_refresh_rate * 1000 ;
21152138b -> audio_in_setup = config -> audio_in_setup ;
21162139b -> audio_in_teardown = config -> audio_in_teardown ;
@@ -2298,6 +2321,7 @@ config_init_to_defaults(struct weston_rdp_backend_config *config)
22982321config -> no_clients_resize = 0 ;
22992322config -> force_no_compression = 0 ;
23002323config -> redirect_clipboard = false;
2324+ config -> enable_persistent_rail_seat = false;
23012325config -> rdp_monitor_refresh_rate = WESTON_RDP_MODE_FREQ ;
23022326config -> rail_config .use_rdpapplist = false;
23032327config -> rail_config .use_shared_memory = false;