[PATCH v2] compositor: take argument for opening xserver display connection
Tiago Vignatti
tiago.vignatti at intel.com
Fri Aug 5 02:18:21 PDT 2011
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.
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
More information about the wayland-devel
mailing list