compositor-wayland: move config parsing in create_cursor

Move configuration parsing from create_cursor to backend_init. Use newer
configuration structure to initialize the cursor in create_cursor.

Signed-off-by: Benoit Gschwind <gschwind@gnu-log.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Benoit Gschwind 9 years ago committed by Pekka Paalanen
parent 3a49b51f8e
commit 244ff799fb
  1. 32
      src/compositor-wayland.c

@ -57,6 +57,8 @@ struct weston_wayland_backend_config {
int sprawl; int sprawl;
char *display_name; char *display_name;
int fullscreen; int fullscreen;
char *cursor_theme;
int cursor_size;
}; };
struct wayland_backend { struct wayland_backend {
@ -2174,25 +2176,19 @@ static const char *left_ptrs[] = {
}; };
static void static void
create_cursor(struct wayland_backend *b, struct weston_config *config) create_cursor(struct wayland_backend *b,
struct weston_wayland_backend_config *config)
{ {
struct weston_config_section *s;
int size;
char *theme = NULL;
unsigned int i; unsigned int i;
s = weston_config_get_section(config, "shell", NULL, NULL); b->cursor_theme = wl_cursor_theme_load(config->cursor_theme,
weston_config_section_get_string(s, "cursor-theme", &theme, NULL); config->cursor_size,
weston_config_section_get_int(s, "cursor-size", &size, 32); b->parent.shm);
b->cursor_theme = wl_cursor_theme_load(theme, size, b->parent.shm);
if (!b->cursor_theme) { if (!b->cursor_theme) {
fprintf(stderr, "could not load cursor theme\n"); fprintf(stderr, "could not load cursor theme\n");
return; return;
} }
free(theme);
b->cursor = NULL; b->cursor = NULL;
for (i = 0; !b->cursor && i < ARRAY_LENGTH(left_ptrs); ++i) for (i = 0; !b->cursor && i < ARRAY_LENGTH(left_ptrs); ++i)
b->cursor = wl_cursor_theme_get_cursor(b->cursor_theme, b->cursor = wl_cursor_theme_get_cursor(b->cursor_theme,
@ -2254,7 +2250,7 @@ wayland_backend_create(struct weston_compositor *compositor,
wl_registry_add_listener(b->parent.registry, &registry_listener, b); wl_registry_add_listener(b->parent.registry, &registry_listener, b);
wl_display_roundtrip(b->parent.wl_display); wl_display_roundtrip(b->parent.wl_display);
create_cursor(b, config); create_cursor(b, new_config);
b->use_pixman = new_config->use_pixman; b->use_pixman = new_config->use_pixman;
@ -2366,6 +2362,15 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
parse_options(wayland_options, parse_options(wayland_options,
ARRAY_LENGTH(wayland_options), argc, argv); ARRAY_LENGTH(wayland_options), argc, argv);
new_config.cursor_size = 32;
new_config.cursor_theme = NULL;
section = weston_config_get_section(config, "shell", NULL, NULL);
weston_config_section_get_string(section, "cursor-theme",
&new_config.cursor_theme, NULL);
weston_config_section_get_int(section, "cursor-size",
&new_config.cursor_size, 32);
b = wayland_backend_create(compositor, &new_config, argc, argv, config); b = wayland_backend_create(compositor, &new_config, argc, argv, config);
if (!b) if (!b)
@ -2438,12 +2443,13 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
weston_compositor_add_key_binding(compositor, KEY_F, weston_compositor_add_key_binding(compositor, KEY_F,
MODIFIER_CTRL | MODIFIER_ALT, MODIFIER_CTRL | MODIFIER_ALT,
fullscreen_binding, b); fullscreen_binding, b);
free(new_config.cursor_theme);
free(new_config.display_name); free(new_config.display_name);
return 0; return 0;
err_outputs: err_outputs:
wayland_backend_destroy(b); wayland_backend_destroy(b);
free(new_config.cursor_theme);
free(new_config.display_name); free(new_config.display_name);
return -1; return -1;
} }

Loading…
Cancel
Save