@ -39,7 +39,7 @@
static int
weston_xserver_handle_event ( int listen_fd , uint32_t mask , void * data )
{
struct weston_xserver * m xs = data ;
struct weston_xserver * w xs = data ;
char display [ 8 ] , s [ 8 ] ;
int sv [ 2 ] , client_fd ;
@ -48,8 +48,8 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
return 1 ;
}
m xs- > process . pid = fork ( ) ;
switch ( m xs- > process . pid ) {
w xs- > process . pid = fork ( ) ;
switch ( w xs- > process . pid ) {
case 0 :
/* SOCK_CLOEXEC closes both ends, so we need to unset
* the flag on the client fd . */
@ -60,7 +60,7 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
snprintf ( s , sizeof s , " %d " , client_fd ) ;
setenv ( " WAYLAND_SOCKET " , s , 1 ) ;
snprintf ( display , sizeof display , " :%d " , m xs- > display ) ;
snprintf ( display , sizeof display , " :%d " , w xs- > display ) ;
if ( execl ( XSERVER_PATH ,
XSERVER_PATH ,
@ -75,15 +75,15 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
exit ( - 1 ) ;
default :
weston_log ( " forked X server, pid %d \n " , m xs- > process . pid ) ;
weston_log ( " forked X server, pid %d \n " , w xs- > process . pid ) ;
close ( sv [ 1 ] ) ;
m xs- > client = wl_client_create ( m xs- > wl_display , sv [ 0 ] ) ;
w xs- > client = wl_client_create ( w xs- > wl_display , sv [ 0 ] ) ;
weston_watch_process ( & m xs- > process ) ;
weston_watch_process ( & w xs- > process ) ;
wl_event_source_remove ( m xs- > abstract_source ) ;
wl_event_source_remove ( m xs- > unix_source ) ;
wl_event_source_remove ( w xs- > abstract_source ) ;
wl_event_source_remove ( w xs- > unix_source ) ;
break ;
case - 1 :
@ -117,33 +117,33 @@ weston_xserver_shutdown(struct weston_xserver *wxs)
static void
weston_xserver_cleanup ( struct weston_process * process , int status )
{
struct weston_xserver * m xs =
struct weston_xserver * w xs =
container_of ( process , struct weston_xserver , process ) ;
m xs- > process . pid = 0 ;
m xs- > client = NULL ;
m xs- > resource = NULL ;
w xs- > process . pid = 0 ;
w xs- > client = NULL ;
w xs- > resource = NULL ;
m xs- > abstract_source =
wl_event_loop_add_fd ( m xs- > loop , m xs- > abstract_fd ,
w xs- > abstract_source =
wl_event_loop_add_fd ( w xs- > loop , w xs- > abstract_fd ,
WL_EVENT_READABLE ,
weston_xserver_handle_event , m xs) ;
weston_xserver_handle_event , w xs) ;
m xs- > unix_source =
wl_event_loop_add_fd ( m xs- > loop , m xs- > unix_fd ,
w xs- > unix_source =
wl_event_loop_add_fd ( w xs- > loop , w xs- > unix_fd ,
WL_EVENT_READABLE ,
weston_xserver_handle_event , m xs) ;
weston_xserver_handle_event , w xs) ;
if ( m xs- > wm ) {
if ( w xs- > wm ) {
weston_log ( " xserver exited, code %d \n " , status ) ;
weston_wm_destroy ( m xs- > wm ) ;
m xs- > wm = NULL ;
weston_wm_destroy ( w xs- > wm ) ;
w xs- > wm = NULL ;
} else {
/* If the X server crashes before it binds to the
* xserver interface , shut down and don ' t try
* again . */
weston_log ( " xserver crashing too fast: %d \n " , status ) ;
weston_xserver_shutdown ( m xs) ;
weston_xserver_shutdown ( w xs) ;
}
}
@ -315,64 +315,64 @@ WL_EXPORT int
module_init ( struct weston_compositor * compositor )
{
struct wl_display * display = compositor - > wl_display ;
struct weston_xserver * m xs;
struct weston_xserver * w xs;
char lockfile [ 256 ] , display_name [ 8 ] ;
m xs = malloc ( sizeof * m xs) ;
memset ( m xs, 0 , sizeof * m xs) ;
w xs = malloc ( sizeof * w xs) ;
memset ( w xs, 0 , sizeof * w xs) ;
m xs- > process . cleanup = weston_xserver_cleanup ;
m xs- > wl_display = display ;
m xs- > compositor = compositor ;
w xs- > process . cleanup = weston_xserver_cleanup ;
w xs- > wl_display = display ;
w xs- > compositor = compositor ;
m xs- > display = 0 ;
w xs- > display = 0 ;
retry :
if ( create_lockfile ( m xs- > display , lockfile , sizeof lockfile ) < 0 ) {
if ( create_lockfile ( w xs- > display , lockfile , sizeof lockfile ) < 0 ) {
if ( errno = = EAGAIN ) {
goto retry ;
} else if ( errno = = EEXIST ) {
m xs- > display + + ;
w xs- > display + + ;
goto retry ;
} else {
free ( m xs) ;
free ( w xs) ;
return - 1 ;
}
}
m xs- > abstract_fd = bind_to_abstract_socket ( m xs- > display ) ;
if ( m xs- > abstract_fd < 0 & & errno = = EADDRINUSE ) {
m xs- > display + + ;
w xs- > abstract_fd = bind_to_abstract_socket ( w xs- > display ) ;
if ( w xs- > abstract_fd < 0 & & errno = = EADDRINUSE ) {
w xs- > display + + ;
unlink ( lockfile ) ;
goto retry ;
}
m xs- > unix_fd = bind_to_unix_socket ( m xs- > display ) ;
if ( m xs- > unix_fd < 0 ) {
w xs- > unix_fd = bind_to_unix_socket ( w xs- > display ) ;
if ( w xs- > unix_fd < 0 ) {
unlink ( lockfile ) ;
close ( m xs- > abstract_fd ) ;
free ( m xs) ;
close ( w xs- > abstract_fd ) ;
free ( w xs) ;
return - 1 ;
}
snprintf ( display_name , sizeof display_name , " :%d " , m xs- > display ) ;
snprintf ( display_name , sizeof display_name , " :%d " , w xs- > display ) ;
weston_log ( " xserver listening on display %s \n " , display_name ) ;
setenv ( " DISPLAY " , display_name , 1 ) ;
m xs- > loop = wl_display_get_event_loop ( display ) ;
m xs- > abstract_source =
wl_event_loop_add_fd ( m xs- > loop , m xs- > abstract_fd ,
w xs- > loop = wl_display_get_event_loop ( display ) ;
w xs- > abstract_source =
wl_event_loop_add_fd ( w xs- > loop , w xs- > abstract_fd ,
WL_EVENT_READABLE ,
weston_xserver_handle_event , m xs) ;
m xs- > unix_source =
wl_event_loop_add_fd ( m xs- > loop , m xs- > unix_fd ,
weston_xserver_handle_event , w xs) ;
w xs- > unix_source =
wl_event_loop_add_fd ( w xs- > loop , w xs- > unix_fd ,
WL_EVENT_READABLE ,
weston_xserver_handle_event , m xs) ;
weston_xserver_handle_event , w xs) ;
wl_display_add_global ( display , & xserver_interface , m xs, bind_xserver ) ;
wl_display_add_global ( display , & xserver_interface , w xs, bind_xserver ) ;
m xs- > destroy_listener . notify = weston_xserver_destroy ;
wl_signal_add ( & compositor - > destroy_signal , & m xs- > destroy_listener ) ;
w xs- > destroy_listener . notify = weston_xserver_destroy ;
wl_signal_add ( & compositor - > destroy_signal , & w xs- > destroy_listener ) ;
return 0 ;
}