@ -49,6 +49,7 @@
# define MAX_FREERDP_FDS 32
# define MAX_FREERDP_FDS 32
# define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
# define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
# define RDP_MODE_FREQ 60 * 1000
struct rdp_compositor_config {
struct rdp_compositor_config {
int width ;
int width ;
@ -58,7 +59,6 @@ struct rdp_compositor_config {
char * rdp_key ;
char * rdp_key ;
char * server_cert ;
char * server_cert ;
char * server_key ;
char * server_key ;
char * extra_modes ;
int env_socket ;
int env_socket ;
} ;
} ;
@ -121,7 +121,6 @@ rdp_compositor_config_init(struct rdp_compositor_config *config) {
config - > rdp_key = NULL ;
config - > rdp_key = NULL ;
config - > server_cert = NULL ;
config - > server_cert = NULL ;
config - > server_key = NULL ;
config - > server_key = NULL ;
config - > extra_modes = NULL ;
config - > env_socket = 0 ;
config - > env_socket = 0 ;
}
}
@ -320,6 +319,7 @@ rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage)
pixman_renderer_output_set_buffer ( output_base , output - > shadow_surface ) ;
pixman_renderer_output_set_buffer ( output_base , output - > shadow_surface ) ;
ec - > renderer - > repaint_output ( & output - > base , damage ) ;
ec - > renderer - > repaint_output ( & output - > base , damage ) ;
if ( pixman_region32_not_empty ( damage ) ) {
wl_list_for_each ( outputPeer , & output - > peers , link ) {
wl_list_for_each ( outputPeer , & output - > peers , link ) {
if ( ( outputPeer - > flags & RDP_PEER_ACTIVATED ) & &
if ( ( outputPeer - > flags & RDP_PEER_ACTIVATED ) & &
( outputPeer - > flags & RDP_PEER_OUTPUT_ENABLED ) )
( outputPeer - > flags & RDP_PEER_OUTPUT_ENABLED ) )
@ -327,6 +327,7 @@ rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage)
rdp_peer_refresh_region ( damage , outputPeer - > peer ) ;
rdp_peer_refresh_region ( damage , outputPeer - > peer ) ;
}
}
}
}
}
pixman_region32_subtract ( & ec - > primary_plane . damage ,
pixman_region32_subtract ( & ec - > primary_plane . damage ,
& ec - > primary_plane . damage , damage ) ;
& ec - > primary_plane . damage , damage ) ;
@ -352,16 +353,29 @@ finish_frame_handler(void *data)
return 1 ;
return 1 ;
}
}
static struct weston_mode *
rdp_insert_new_mode ( struct weston_output * output , int width , int height , int rate ) {
struct weston_mode * ret ;
ret = zalloc ( sizeof * ret ) ;
if ( ! ret )
return NULL ;
ret - > width = width ;
ret - > height = height ;
ret - > refresh = rate ;
wl_list_insert ( & output - > mode_list , & ret - > link ) ;
return ret ;
}
static struct weston_mode *
static struct weston_mode *
find_matching_mode ( struct weston_output * output , struct weston_mode * target ) {
ensure _matching_mode( struct weston_output * output , struct weston_mode * target ) {
struct weston_mode * local ;
struct weston_mode * local ;
wl_list_for_each ( local , & output - > mode_list , link ) {
wl_list_for_each ( local , & output - > mode_list , link ) {
if ( ( local - > width = = target - > width ) & & ( local - > height = = target - > height ) )
if ( ( local - > width = = target - > width ) & & ( local - > height = = target - > height ) )
return local ;
return local ;
}
}
return 0 ;
return rdp_insert_new_mode ( output , target - > width , target - > height , RDP_MODE_FREQ ) ;
}
}
static int
static int
@ -372,7 +386,7 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) {
pixman_image_t * new_shadow_buffer ;
pixman_image_t * new_shadow_buffer ;
struct weston_mode * local_mode ;
struct weston_mode * local_mode ;
local_mode = find _matching_mode( output , target_mode ) ;
local_mode = ensure _matching_mode( output , target_mode ) ;
if ( ! local_mode ) {
if ( ! local_mode ) {
weston_log ( " mode %dx%d not available \n " , target_mode - > width , target_mode - > height ) ;
weston_log ( " mode %dx%d not available \n " , target_mode - > width , target_mode - > height ) ;
return - ENOENT ;
return - ENOENT ;
@ -398,6 +412,9 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) {
wl_list_for_each ( rdpPeer , & rdpOutput - > peers , link ) {
wl_list_for_each ( rdpPeer , & rdpOutput - > peers , link ) {
settings = rdpPeer - > peer - > settings ;
settings = rdpPeer - > peer - > settings ;
if ( settings - > DesktopWidth = = target_mode - > width & & settings - > DesktopHeight = = target_mode - > height )
continue ;
if ( ! settings - > DesktopResize ) {
if ( ! settings - > DesktopResize ) {
/* too bad this peer does not support desktop resize */
/* too bad this peer does not support desktop resize */
rdpPeer - > peer - > Close ( rdpPeer - > peer ) ;
rdpPeer - > peer - > Close ( rdpPeer - > peer ) ;
@ -411,49 +428,12 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) {
}
}
static int
static int
parse_extra_modes ( const char * modes_str , struct rdp_output * output ) {
rdp_compositor_create_output ( struct rdp_compositor * c , int width , int height )
const char * startAt = modes_str ;
const char * nextPos ;
int w , h ;
struct weston_mode * mode ;
while ( startAt & & * startAt ) {
nextPos = strchr ( startAt , ' x ' ) ;
if ( ! nextPos )
return - 1 ;
w = strtoul ( startAt , NULL , 0 ) ;
startAt = nextPos + 1 ;
if ( ! * startAt )
return - 1 ;
h = strtoul ( startAt , NULL , 0 ) ;
if ( ! w | | ( w > 3000 ) | | ! h | | ( h > 3000 ) )
return - 1 ;
mode = malloc ( sizeof * mode ) ;
if ( ! mode )
return - 1 ;
mode - > width = w ;
mode - > height = h ;
mode - > refresh = 5 ;
mode - > flags = 0 ;
wl_list_insert ( & output - > base . mode_list , & mode - > link ) ;
startAt = strchr ( startAt , ' , ' ) ;
if ( startAt & & * startAt = = ' , ' )
startAt + + ;
}
return 0 ;
}
static int
rdp_compositor_create_output ( struct rdp_compositor * c , int width , int height ,
const char * extraModes )
{
{
struct rdp_output * output ;
struct rdp_output * output ;
struct wl_event_loop * loop ;
struct wl_event_loop * loop ;
struct weston_mode * currentMode , * next ;
struct weston_mode * currentMode ;
struct weston_mode initMode ;
output = zalloc ( sizeof * output ) ;
output = zalloc ( sizeof * output ) ;
if ( output = = NULL )
if ( output = = NULL )
@ -462,19 +442,14 @@ rdp_compositor_create_output(struct rdp_compositor *c, int width, int height,
wl_list_init ( & output - > peers ) ;
wl_list_init ( & output - > peers ) ;
wl_list_init ( & output - > base . mode_list ) ;
wl_list_init ( & output - > base . mode_list ) ;
currentMode = malloc ( sizeof * currentMode ) ;
initMode . flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED ;
initMode . width = width ;
initMode . height = height ;
initMode . refresh = RDP_MODE_FREQ ;
currentMode = ensure_matching_mode ( & output - > base , & initMode ) ;
if ( ! currentMode )
if ( ! currentMode )
goto out_free_output ;
goto out_free_output ;
currentMode - > flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED ;
currentMode - > width = width ;
currentMode - > height = height ;
currentMode - > refresh = 5 ;
wl_list_insert ( & output - > base . mode_list , & currentMode - > link ) ;
if ( parse_extra_modes ( extraModes , output ) < 0 ) {
weston_log ( " invalid extra modes \n " ) ;
goto out_free_output_and_modes ;
}
output - > base . current_mode = output - > base . native_mode = currentMode ;
output - > base . current_mode = output - > base . native_mode = currentMode ;
weston_output_init ( & output - > base , & c - > base , 0 , 0 , width , height ,
weston_output_init ( & output - > base , & c - > base , 0 , 0 , width , height ,
@ -513,9 +488,6 @@ out_shadow_surface:
pixman_image_unref ( output - > shadow_surface ) ;
pixman_image_unref ( output - > shadow_surface ) ;
out_output :
out_output :
weston_output_destroy ( & output - > base ) ;
weston_output_destroy ( & output - > base ) ;
out_free_output_and_modes :
wl_list_for_each_safe ( currentMode , next , & output - > base . mode_list , link )
free ( currentMode ) ;
out_free_output :
out_free_output :
free ( output ) ;
free ( output ) ;
return - 1 ;
return - 1 ;
@ -704,7 +676,7 @@ xf_peer_post_connect(freerdp_peer* client)
struct weston_mode * target_mode ;
struct weston_mode * target_mode ;
new_mode . width = ( int ) settings - > DesktopWidth ;
new_mode . width = ( int ) settings - > DesktopWidth ;
new_mode . height = ( int ) settings - > DesktopHeight ;
new_mode . height = ( int ) settings - > DesktopHeight ;
target_mode = find _matching_mode( & output - > base , & new_mode ) ;
target_mode = ensure _matching_mode( & output - > base , & new_mode ) ;
if ( ! target_mode ) {
if ( ! target_mode ) {
weston_log ( " client mode not found \n " ) ;
weston_log ( " client mode not found \n " ) ;
return FALSE ;
return FALSE ;
@ -1030,7 +1002,7 @@ rdp_compositor_create(struct wl_display *display,
if ( pixman_renderer_init ( & c - > base ) < 0 )
if ( pixman_renderer_init ( & c - > base ) < 0 )
goto err_compositor ;
goto err_compositor ;
if ( rdp_compositor_create_output ( c , config - > width , config - > height , config - > extra_modes ) < 0 )
if ( rdp_compositor_create_output ( c , config - > width , config - > height ) < 0 )
goto err_compositor ;
goto err_compositor ;
if ( ! config - > env_socket ) {
if ( ! config - > env_socket ) {
@ -1093,7 +1065,6 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
{ WESTON_OPTION_BOOLEAN , " env-socket " , 0 , & config . env_socket } ,
{ WESTON_OPTION_BOOLEAN , " env-socket " , 0 , & config . env_socket } ,
{ WESTON_OPTION_INTEGER , " width " , 0 , & config . width } ,
{ WESTON_OPTION_INTEGER , " width " , 0 , & config . width } ,
{ WESTON_OPTION_INTEGER , " height " , 0 , & config . height } ,
{ WESTON_OPTION_INTEGER , " height " , 0 , & config . height } ,
{ WESTON_OPTION_STRING , " extra-modes " , 0 , & config . extra_modes } ,
{ WESTON_OPTION_STRING , " address " , 0 , & config . bind_address } ,
{ WESTON_OPTION_STRING , " address " , 0 , & config . bind_address } ,
{ WESTON_OPTION_INTEGER , " port " , 0 , & config . port } ,
{ WESTON_OPTION_INTEGER , " port " , 0 , & config . port } ,
{ WESTON_OPTION_STRING , " rdp4-key " , 0 , & config . rdp_key } ,
{ WESTON_OPTION_STRING , " rdp4-key " , 0 , & config . rdp_key } ,