Add a geometry option for x11 compositor

dev
Kristian Høgsberg 14 years ago
parent 012a007771
commit 61a8251360
  1. 6
      compositor/compositor-drm.c
  2. 4
      compositor/compositor-x11.c
  3. 19
      compositor/compositor.c
  4. 7
      compositor/compositor.h

@ -457,7 +457,7 @@ create_output_for_connector(struct drm_compositor *ec,
} }
static int static int
create_outputs(struct drm_compositor *ec) create_outputs(struct drm_compositor *ec, int option_connector)
{ {
drmModeConnector *connector; drmModeConnector *connector;
drmModeRes *resources; drmModeRes *resources;
@ -616,7 +616,7 @@ drm_authenticate(struct wlsc_compositor *c, uint32_t id)
} }
struct wlsc_compositor * struct wlsc_compositor *
drm_compositor_create(struct wl_display *display) drm_compositor_create(struct wl_display *display, int connector)
{ {
struct drm_compositor *ec; struct drm_compositor *ec;
struct udev_enumerate *e; struct udev_enumerate *e;
@ -663,7 +663,7 @@ drm_compositor_create(struct wl_display *display)
if (wlsc_compositor_init(&ec->base, display) < 0) if (wlsc_compositor_init(&ec->base, display) < 0)
return NULL; return NULL;
if (create_outputs(ec) < 0) { if (create_outputs(ec, connector) < 0) {
fprintf(stderr, "failed to create output for %s\n", path); fprintf(stderr, "failed to create output for %s\n", path);
return NULL; return NULL;
} }

@ -620,7 +620,7 @@ x11_authenticate(struct wlsc_compositor *c, uint32_t id)
} }
struct wlsc_compositor * 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 x11_compositor *c;
struct wl_event_loop *loop; struct wl_event_loop *loop;
@ -648,7 +648,7 @@ x11_compositor_create(struct wl_display *display)
if (wlsc_compositor_init(&c->base, display) < 0) if (wlsc_compositor_init(&c->base, display) < 0)
return NULL; return NULL;
x11_compositor_create_output(c, 1024, 640); x11_compositor_create_output(c, width, height);
x11_input_create(c); x11_input_create(c);

@ -32,14 +32,17 @@
#include "wayland-server-protocol.h" #include "wayland-server-protocol.h"
#include "compositor.h" #include "compositor.h"
const char *option_background = "background.jpg"; static const char *option_background = "background.jpg";
int option_connector = 0; static const char *option_geometry = "1024x640";
static int option_connector = 0;
static const GOptionEntry option_entries[] = { static const GOptionEntry option_entries[] = {
{ "background", 'b', 0, G_OPTION_ARG_STRING, { "background", 'b', 0, G_OPTION_ARG_STRING,
&option_background, "Background image" }, &option_background, "Background image" },
{ "connector", 'c', 0, G_OPTION_ARG_INT, { "connector", 'c', 0, G_OPTION_ARG_INT,
&option_connector, "KMS connector" }, &option_connector, "KMS connector" },
{ "geometry", 'g', 0, G_OPTION_ARG_STRING,
&option_geometry, "Geometry" },
{ NULL } { NULL }
}; };
@ -1417,6 +1420,7 @@ int main(int argc, char *argv[])
struct wlsc_compositor *ec; struct wlsc_compositor *ec;
GError *error = NULL; GError *error = NULL;
GOptionContext *context; GOptionContext *context;
int width, height;
g_type_init(); /* GdkPixbuf needs this, it seems. */ 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); fprintf(stderr, "option parsing failed: %s\n", error->message);
exit(EXIT_FAILURE); 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(); display = wl_display_create();
if (getenv("DISPLAY")) if (getenv("DISPLAY"))
ec = x11_compositor_create(display); ec = x11_compositor_create(display, width, height);
else else
ec = drm_compositor_create(display); ec = drm_compositor_create(display, option_connector);
if (ec == NULL) { if (ec == NULL) {
fprintf(stderr, "failed to create compositor\n"); fprintf(stderr, "failed to create compositor\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (wl_display_add_socket(display, socket_name, sizeof socket_name)) { if (wl_display_add_socket(display, socket_name, sizeof socket_name)) {
fprintf(stderr, "failed to add socket: %m\n"); fprintf(stderr, "failed to add socket: %m\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

@ -229,15 +229,12 @@ wl_buffer_create_drm(struct wlsc_compositor *compositor,
struct wl_visual *visual); struct wl_visual *visual);
struct wlsc_compositor * struct wlsc_compositor *
x11_compositor_create(struct wl_display *display); x11_compositor_create(struct wl_display *display, int width, int height);
struct wlsc_compositor * struct wlsc_compositor *
drm_compositor_create(struct wl_display *display); drm_compositor_create(struct wl_display *display, int connector);
void void
screenshooter_create(struct wlsc_compositor *ec); screenshooter_create(struct wlsc_compositor *ec);
extern const char *option_background;
extern int option_connector;
#endif #endif

Loading…
Cancel
Save