xwayland: Standardize 'wxs' for weston_xserver variables

It was already being used in most of launcher.c and window-manager.c, so let's
make a standard everywhere now.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
dev
Tiago Vignatti 12 years ago committed by Kristian Høgsberg
parent bf74d5242a
commit f268446339
  1. 102
      src/xwayland/launcher.c

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

Loading…
Cancel
Save