[PATCH v2] compositor: take argument for opening xserver display connection
Kristian Høgsberg
krh at bitplanet.net
Thu Aug 11 17:25:00 PDT 2011
On Fri, Aug 5, 2011 at 5:18 AM, Tiago Vignatti <tiago.vignatti at intel.com> wrote:
> For example, using --xserver=2 and -x2, both open connections for an
> X server in display :2. Similarly, -x and --xserver will open it on
> display :0.
We talked about this in IRC, and the underlying problem is that when
running the X server from a chroot environment, the wayland X server
will listen on :0 since there's no lock file in /tmp in the chroot.
However, outside the chroot, the "host" X server runs on :0 and has an
abstract socket for :0 that takes precedence over the unix socket
inside the chroot. So X client inside the chroot that should connect
to the Wayland X socket, end up talking to the abstract socket from
the outside X server.
The solution isn't to specify a display manually: instead, we can try
to bind to the abstract socket and if that fails, move on to the next
display number. I've pushed a commit that does that.
Kristian
> Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
> ---
> compositor/compositor.c | 18 ++++++++++++++----
> compositor/compositor.h | 2 +-
> compositor/xserver-launcher.c | 4 ++--
> 3 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/compositor/compositor.c b/compositor/compositor.c
> index 177de54..d8a5a6e 100644
> --- a/compositor/compositor.c
> +++ b/compositor/compositor.c
> @@ -1998,7 +1998,7 @@ int main(int argc, char *argv[])
> struct wl_display *display;
> struct wlsc_compositor *ec;
> struct wl_event_loop *loop;
> - int o, xserver = 0;
> + int o, xserver_dpy, xserver = 0;
> void *shell_module, *backend_module;
> int (*shell_init)(struct wlsc_compositor *ec);
> struct wlsc_compositor
> @@ -2008,7 +2008,7 @@ int main(int argc, char *argv[])
> char *shell = NULL;
> char *p;
>
> - static const char opts[] = "B:b:o:S:i:s:x";
> + static const char opts[] = "B:b:o:S:i:s:x::";
> static const struct option longopts[ ] = {
> { "backend", 1, NULL, 'B' },
> { "backend-options", 1, NULL, 'o' },
> @@ -2016,7 +2016,7 @@ int main(int argc, char *argv[])
> { "socket", 1, NULL, 'S' },
> { "idle-time", 1, NULL, 'i' },
> { "shell", 1, NULL, 's' },
> - { "xserver", 0, NULL, 'x' },
> + { "xserver", 2, 0, 'x' },
> { NULL, }
> };
>
> @@ -2048,6 +2048,16 @@ int main(int argc, char *argv[])
> break;
> case 'x':
> xserver = 1;
> + if (!optarg) {
> + xserver_dpy = 0;
> + } else {
> + xserver_dpy = strtol(optarg, &p, 0);
> + if (*p != '\0') {
> + fprintf(stderr, "invalid xserver"
> + "connection: %s\n", optarg);
> + exit(EXIT_FAILURE);
> + }
> + }
> break;
> }
> }
> @@ -2088,7 +2098,7 @@ int main(int argc, char *argv[])
> exit(EXIT_FAILURE);
>
> if (xserver)
> - wlsc_xserver_init(ec);
> + wlsc_xserver_init(ec, xserver_dpy);
>
> if (wl_display_add_socket(display, option_socket_name)) {
> fprintf(stderr, "failed to add socket: %m\n");
> diff --git a/compositor/compositor.h b/compositor/compositor.h
> index ea6e9e7..fce3693 100644
> --- a/compositor/compositor.h
> +++ b/compositor/compositor.h
> @@ -399,7 +399,7 @@ void
> wlsc_watch_process(struct wlsc_process *process);
>
> int
> -wlsc_xserver_init(struct wlsc_compositor *compositor);
> +wlsc_xserver_init(struct wlsc_compositor *compositor, int server_display);
> void
> wlsc_xserver_destroy(struct wlsc_compositor *compositor);
>
> diff --git a/compositor/xserver-launcher.c b/compositor/xserver-launcher.c
> index f39c38d..b01619b 100644
> --- a/compositor/xserver-launcher.c
> +++ b/compositor/xserver-launcher.c
> @@ -575,7 +575,7 @@ static const struct xserver_interface xserver_implementation = {
> };
>
> int
> -wlsc_xserver_init(struct wlsc_compositor *compositor)
> +wlsc_xserver_init(struct wlsc_compositor *compositor, int server_display)
> {
> struct wl_display *display = compositor->wl_display;
> struct wlsc_xserver *mxs;
> @@ -596,7 +596,7 @@ wlsc_xserver_init(struct wlsc_compositor *compositor)
> return -1;
> }
>
> - mxs->display = 0;
> + mxs->display = server_display;
> do {
> snprintf(lockfile, sizeof lockfile,
> "/tmp/.X%d-lock", mxs->display);
> --
> 1.7.2.2
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list