diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c index 57802d3c..2018e5c0 100644 --- a/compositor/compositor-drm.c +++ b/compositor/compositor-drm.c @@ -457,7 +457,7 @@ create_output_for_connector(struct drm_compositor *ec, } static int -create_outputs(struct drm_compositor *ec) +create_outputs(struct drm_compositor *ec, int option_connector) { drmModeConnector *connector; drmModeRes *resources; @@ -616,7 +616,7 @@ drm_authenticate(struct wlsc_compositor *c, uint32_t id) } struct wlsc_compositor * -drm_compositor_create(struct wl_display *display) +drm_compositor_create(struct wl_display *display, int connector) { struct drm_compositor *ec; struct udev_enumerate *e; @@ -663,7 +663,7 @@ drm_compositor_create(struct wl_display *display) if (wlsc_compositor_init(&ec->base, display) < 0) return NULL; - if (create_outputs(ec) < 0) { + if (create_outputs(ec, connector) < 0) { fprintf(stderr, "failed to create output for %s\n", path); return NULL; } diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c index 1aa45d91..b7a9d0df 100644 --- a/compositor/compositor-x11.c +++ b/compositor/compositor-x11.c @@ -620,7 +620,7 @@ x11_authenticate(struct wlsc_compositor *c, uint32_t id) } struct wlsc_compositor * -x11_compositor_create(struct wl_display *display) +x11_compositor_create(struct wl_display *display, int width, int height) { struct x11_compositor *c; struct wl_event_loop *loop; @@ -648,7 +648,7 @@ x11_compositor_create(struct wl_display *display) if (wlsc_compositor_init(&c->base, display) < 0) return NULL; - x11_compositor_create_output(c, 1024, 640); + x11_compositor_create_output(c, width, height); x11_input_create(c); diff --git a/compositor/compositor.c b/compositor/compositor.c index 8dadd730..7daacea9 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -32,14 +32,17 @@ #include "wayland-server-protocol.h" #include "compositor.h" -const char *option_background = "background.jpg"; -int option_connector = 0; +static const char *option_background = "background.jpg"; +static const char *option_geometry = "1024x640"; +static int option_connector = 0; static const GOptionEntry option_entries[] = { { "background", 'b', 0, G_OPTION_ARG_STRING, &option_background, "Background image" }, { "connector", 'c', 0, G_OPTION_ARG_INT, &option_connector, "KMS connector" }, + { "geometry", 'g', 0, G_OPTION_ARG_STRING, + &option_geometry, "Geometry" }, { NULL } }; @@ -1417,6 +1420,7 @@ int main(int argc, char *argv[]) struct wlsc_compositor *ec; GError *error = NULL; GOptionContext *context; + int width, height; g_type_init(); /* GdkPixbuf needs this, it seems. */ @@ -1426,19 +1430,24 @@ int main(int argc, char *argv[]) fprintf(stderr, "option parsing failed: %s\n", error->message); exit(EXIT_FAILURE); } + if (sscanf(option_geometry, "%dx%d", &width, &height) != 2) { + fprintf(stderr, "invalid geometry option: %s \n", + option_geometry); + exit(EXIT_FAILURE); + } display = wl_display_create(); if (getenv("DISPLAY")) - ec = x11_compositor_create(display); + ec = x11_compositor_create(display, width, height); else - ec = drm_compositor_create(display); + ec = drm_compositor_create(display, option_connector); if (ec == NULL) { fprintf(stderr, "failed to create compositor\n"); exit(EXIT_FAILURE); } - + if (wl_display_add_socket(display, socket_name, sizeof socket_name)) { fprintf(stderr, "failed to add socket: %m\n"); exit(EXIT_FAILURE); diff --git a/compositor/compositor.h b/compositor/compositor.h index 558bd79e..85535f33 100644 --- a/compositor/compositor.h +++ b/compositor/compositor.h @@ -229,15 +229,12 @@ wl_buffer_create_drm(struct wlsc_compositor *compositor, struct wl_visual *visual); struct wlsc_compositor * -x11_compositor_create(struct wl_display *display); +x11_compositor_create(struct wl_display *display, int width, int height); struct wlsc_compositor * -drm_compositor_create(struct wl_display *display); +drm_compositor_create(struct wl_display *display, int connector); void screenshooter_create(struct wlsc_compositor *ec); -extern const char *option_background; -extern int option_connector; - #endif