compositor-x11: add an option to ignore input

For testing the compositor without any input devices. Exposes cases
where e.g. keyboard or pointer are NULL-dereferenced.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Pekka Paalanen 13 years ago committed by Kristian Høgsberg
parent 4e1f2ff1c6
commit 36f155f80f
  1. 33
      src/compositor-x11.c

@ -133,7 +133,7 @@ x11_compositor_get_keymap(struct x11_compositor *c)
} }
static int static int
x11_input_create(struct x11_compositor *c) x11_input_create(struct x11_compositor *c, int no_input)
{ {
struct x11_input *input; struct x11_input *input;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
@ -144,6 +144,11 @@ x11_input_create(struct x11_compositor *c)
memset(input, 0, sizeof *input); memset(input, 0, sizeof *input);
weston_seat_init(&input->base, &c->base); weston_seat_init(&input->base, &c->base);
c->base.seat = &input->base;
if (no_input)
return 0;
weston_seat_init_pointer(&input->base); weston_seat_init_pointer(&input->base);
keymap = x11_compositor_get_keymap(c); keymap = x11_compositor_get_keymap(c);
@ -151,8 +156,6 @@ x11_input_create(struct x11_compositor *c)
if (keymap) if (keymap)
xkb_map_unref(keymap); xkb_map_unref(keymap);
c->base.seat = &input->base;
return 0; return 0;
} }
@ -401,7 +404,8 @@ x11_output_set_icon(struct x11_compositor *c,
static int static int
x11_compositor_create_output(struct x11_compositor *c, int x, int y, x11_compositor_create_output(struct x11_compositor *c, int x, int y,
int width, int height, int fullscreen) int width, int height, int fullscreen,
int no_input)
{ {
static const char name[] = "Weston Compositor"; static const char name[] = "Weston Compositor";
static const char class[] = "weston-1\0Weston Compositor"; static const char class[] = "weston-1\0Weston Compositor";
@ -411,19 +415,22 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
struct wl_event_loop *loop; struct wl_event_loop *loop;
uint32_t mask = XCB_CW_EVENT_MASK | XCB_CW_CURSOR; uint32_t mask = XCB_CW_EVENT_MASK | XCB_CW_CURSOR;
uint32_t values[2] = { uint32_t values[2] = {
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY,
0
};
if (!no_input)
values[0] |=
XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_PRESS |
XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_RELEASE |
XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_ENTER_WINDOW |
XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
XCB_EVENT_MASK_KEYMAP_STATE | XCB_EVENT_MASK_KEYMAP_STATE |
XCB_EVENT_MASK_FOCUS_CHANGE, XCB_EVENT_MASK_FOCUS_CHANGE;
0
};
output = malloc(sizeof *output); output = malloc(sizeof *output);
if (output == NULL) if (output == NULL)
@ -851,6 +858,7 @@ x11_destroy(struct weston_compositor *ec)
static struct weston_compositor * static struct weston_compositor *
x11_compositor_create(struct wl_display *display, x11_compositor_create(struct wl_display *display,
int width, int height, int count, int fullscreen, int width, int height, int count, int fullscreen,
int no_input,
int argc, char *argv[], const char *config_file) int argc, char *argv[], const char *config_file)
{ {
struct x11_compositor *c; struct x11_compositor *c;
@ -892,12 +900,12 @@ x11_compositor_create(struct wl_display *display,
for (i = 0, x = 0; i < count; i++) { for (i = 0, x = 0; i < count; i++) {
if (x11_compositor_create_output(c, x, 0, width, height, if (x11_compositor_create_output(c, x, 0, width, height,
fullscreen) < 0) fullscreen, no_input) < 0)
return NULL; return NULL;
x += width; x += width;
} }
if (x11_input_create(c) < 0) if (x11_input_create(c, no_input) < 0)
return NULL; return NULL;
c->xcb_source = c->xcb_source =
@ -915,17 +923,20 @@ backend_init(struct wl_display *display, int argc, char *argv[],
const char *config_file) const char *config_file)
{ {
int width = 1024, height = 640, fullscreen = 0, count = 1; int width = 1024, height = 640, fullscreen = 0, count = 1;
int no_input = 0;
const struct weston_option x11_options[] = { const struct weston_option x11_options[] = {
{ WESTON_OPTION_INTEGER, "width", 0, &width }, { WESTON_OPTION_INTEGER, "width", 0, &width },
{ WESTON_OPTION_INTEGER, "height", 0, &height }, { WESTON_OPTION_INTEGER, "height", 0, &height },
{ WESTON_OPTION_BOOLEAN, "fullscreen", 0, &fullscreen }, { WESTON_OPTION_BOOLEAN, "fullscreen", 0, &fullscreen },
{ WESTON_OPTION_INTEGER, "output-count", 0, &count }, { WESTON_OPTION_INTEGER, "output-count", 0, &count },
{ WESTON_OPTION_BOOLEAN, "no-input", 0, &no_input },
}; };
parse_options(x11_options, ARRAY_LENGTH(x11_options), argc, argv); parse_options(x11_options, ARRAY_LENGTH(x11_options), argc, argv);
return x11_compositor_create(display, return x11_compositor_create(display,
width, height, count, fullscreen, width, height, count, fullscreen,
no_input,
argc, argv, config_file); argc, argv, config_file);
} }

Loading…
Cancel
Save