On Fri, 15 Apr 2016 20:28:31 -0700 Bryce Harrington <[email protected]> wrote:
> From: Benoit Gschwind <[email protected]> > > Use a "well" defined structure to configure x11-backend and move configuration > file parsing inside the weston compositor code. > > Signed-off-by: Bryce Harrington <[email protected]> > > v6: > - Define version number in the header > - Don't use initial underscores in header guards > - Add stub config_init_to_defaults() > - Allocate config on stack > - Install compositor-x11.h and list it in x11-backend sources > - Fail if invalid width or height given for an output. It's the > caller's job to ensure the values are valid when parsing weston.ini > and the command line options. > - Preserve preference for height/width passed as options > v5: > - Update to current trunk > - Reformated for style consistency (e.g. spaces in "if(", > linebreaks, etc.) > - Move variable declarations to top of block > - Rename header guard for consistency with other headers > - Other misc. code style formatting fixes > - Adjust code style to better match drm backend config > - Version the config struct > - Dropped use of bzero in favor of zalloc > - Don't initialize vars already zalloc'd > - Dropped weston_x11_backend_load in favor of more general > load_backend_new routine > - Dropped weston_x11_backend_config_outputs_clear and just free > outputs in error handler for init routine > - Dropped some temp variables for output configuration > - Restore use of 'backend_init' as module entrypoint > - Rename 'ths' to 'config' for backend config structs > - Rename 'x11_options' to 'options' for consistency > - Rename other variables for consistency with other code > - Rename 'noutputs' to 'num_outputs' > > Signed-off-by: Bryce Harrington <[email protected]> > --- > Makefile.am | 3 + > src/compositor-x11.c | 158 > ++++++++++++++++++--------------------------------- > src/compositor-x11.h | 62 ++++++++++++++++++++ > src/main.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++- > 4 files changed, 266 insertions(+), 104 deletions(-) > create mode 100644 src/compositor-x11.h > +static int > +load_x11_backend(struct weston_compositor *c, char const * backend, > + int *argc, char **argv, struct weston_config *wc) > +{ > + struct weston_x11_backend_output_config default_output; > + struct weston_x11_backend_config *config; > + struct weston_config_section *section; > + int ret = 0; > + int option_width = 0; > + int option_height = 0; > + int option_scale = 0; > + int option_count = 1; > + int output_count = 0; > + char const *section_name; > + int i; > + uint32_t j; > + > + config = zalloc(sizeof(struct weston_x11_backend_config)); > + if (config == NULL) > + return -1; > + > + const struct weston_option options[] = { > + { WESTON_OPTION_INTEGER, "width", 0, &option_width }, > + { WESTON_OPTION_INTEGER, "height", 0, &option_height }, > + { WESTON_OPTION_INTEGER, "scale", 0, &option_scale }, > + { WESTON_OPTION_BOOLEAN, "fullscreen", 'f', &config->fullscreen > }, > + { WESTON_OPTION_INTEGER, "output-count", 0, &option_count }, > + { WESTON_OPTION_BOOLEAN, "no-input", 0, &config->no_input }, > + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config->use_pixman }, > + }; > + > + parse_options(options, ARRAY_LENGTH(options), argc, argv); > + > + section = NULL; > + while (weston_config_next_section(wc, §ion, §ion_name)) { > + struct weston_x11_backend_output_config current_output = { 0, }; > + char *t; > + char *mode; > + > + if (strcmp(section_name, "output") != 0) { > + continue; > + } > + > + weston_config_section_get_string(section, "name", > ¤t_output.name, NULL); > + if (current_output.name == NULL || current_output.name[0] != > 'X') { > + free(current_output.name); > + continue; > + } > + > + weston_config_section_get_string(section, "mode", &mode, > "1024x600"); > + if (sscanf(mode, "%dx%d", ¤t_output.width, > + ¤t_output.height) != 2) { > + weston_log("Invalid mode \"%s\" for output %s\n", > + mode, current_output.name); > + current_output.width = 1024; > + current_output.height = 600; > + } > + free(mode); > + if (current_output.width < 1) > + current_output.width = 1024; > + if (current_output.height < 1) > + current_output.height = 600; > + if (option_width) > + current_output.width = option_width; > + if (option_height) > + current_output.height = option_height; > + > + weston_config_section_get_int(section, "scale", > ¤t_output.scale, 1); > + if (option_scale) > + current_output.scale = option_scale; > + > + weston_config_section_get_string(section, > + "transform", &t, "normal"); > + if (weston_parse_transform(t, ¤t_output.transform) < 0) > + weston_log("Invalid transform \"%s\" for output %s\n", > + t, current_output.name); > + free(t); > + > + if (weston_x11_backend_config_append_output_config(config, > ¤t_output) < 0) { > + ret = -1; > + goto error; > + } > + > + output_count++; > + if (option_count && output_count >= option_count) > + break; > + } > + > + default_output.name = NULL; > + default_output.width = option_width ? option_width : 1024; > + default_output.height = option_height ? option_height : 600; > + default_output.scale = option_scale ? option_scale : 1; > + default_output.transform = WL_OUTPUT_TRANSFORM_NORMAL; > + > + for (i = output_count; i < option_count; i++) { > + if (asprintf(default_output.name, "screen%d", i) < 0) { /home/pq/git/weston/src/main.c: In function ‘load_x11_backend’: /home/pq/git/weston/src/main.c:852:3: warning: passing argument 1 of ‘asprintf’ from incompatible pointer type [enabled by default] if (asprintf(default_output.name, "screen%d", i) < 0) { ^ In file included from /usr/include/features.h:365:0, from /usr/include/unistd.h:25, from /home/pq/git/weston/src/main.c:30: /usr/include/bits/stdio2.h:176:1: note: expected ‘char ** __restrict__’ but argument is of type ‘char *’ __NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...)) ^ This wasn't fixed by any of the later patches either. I recommend squashing of all hunks in later patches touching the x11-backend into this patch. Thanks, pq
pgp_UGyGbasAr.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/wayland-devel
