<br><br><div class="gmail_quote">On Fri, Aug 3, 2012 at 2:42 AM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, 2 Aug 2012 20:42:17 -0600<br>
Scott Moreau <<a href="mailto:oreaus@gmail.com">oreaus@gmail.com</a>> wrote:<br>
<br>
> This patch provides a way to define outputs for the x11 backend. It<br>
> parses [output] sections and checks for 'name', 'width' and 'height'<br>
> keys. The 'name' key must start with an 'X' to distinguish between<br>
> drm output names. Command line options --width and --height supersede<br>
> what is in the config file. When --output-count is passed, the number<br>
> of outputs are limited or additional outputs added with default<br>
> values.<br>
<br>
</div>Hi Scott,<br>
<br>
the semantics sound good. Further comments below.<br></blockquote><div><br>Hi Pekka,<br><br>Thanks for your comments.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
> ---<br>
> src/compositor-x11.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++----<br>
> weston.ini | 5 ++<br>
> 2 files changed, 132 insertions(+), 9 deletions(-)<br>
><br>
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c<br>
> index 4507463..992b68f 100644<br>
> --- a/src/compositor-x11.c<br>
> +++ b/src/compositor-x11.c<br>
> @@ -50,6 +50,20 @@<br>
> #include "compositor.h"<br>
> #include "../shared/config-parser.h"<br>
><br>
> +static char *output_name;<br>
> +static char *output_width;<br>
> +static char *output_height;<br>
> +static int width_arg;<br>
> +static int height_arg;<br>
> +static int count_arg;<br>
> +static struct wl_list configured_output_list;<br>
> +<br>
> +struct x11_configured_output {<br>
> + char *name;<br>
> + int width, height;<br>
> + struct wl_list link;<br>
> +};<br>
> +<br>
> struct x11_compositor {<br>
> struct weston_compositor base;<br>
><br>
> @@ -1033,9 +1047,20 @@ x11_restore(struct weston_compositor *ec)<br>
> }<br>
><br>
> static void<br>
> +x11_free_configured_output(struct x11_configured_output *output)<br>
> +{<br>
> + free(output->name);<br>
> + free(output);<br>
> +}<br>
> +<br>
> +static void<br>
> x11_destroy(struct weston_compositor *ec)<br>
> {<br>
> struct x11_compositor *compositor = (struct x11_compositor *)ec;<br>
> + struct x11_configured_output *o, *n;<br>
> +<br>
> + wl_list_for_each_safe(o, n, &configured_output_list, link)<br>
> + x11_free_configured_output(o);<br>
><br>
> wl_event_source_remove(compositor->xcb_source);<br>
> x11_input_destroy(compositor);<br>
> @@ -1055,8 +1080,9 @@ x11_compositor_create(struct wl_display *display,<br>
> int argc, char *argv[], const char *config_file)<br>
> {<br>
> struct x11_compositor *c;<br>
> + struct x11_configured_output *o;<br>
> xcb_screen_iterator_t s;<br>
> - int i, x;<br>
> + int i, x = 0, output_count = 0;<br>
><br>
> weston_log("initializing x11 backend\n");<br>
><br>
> @@ -1099,11 +1125,35 @@ x11_compositor_create(struct wl_display *display,<br>
> if (x11_input_create(c, no_input) < 0)<br>
> goto err_egl;<br>
><br>
> - for (i = 0, x = 0; i < count; i++) {<br>
> - if (x11_compositor_create_output(c, x, 0, width, height,<br>
> - fullscreen, no_input) < 0)<br>
> - goto err_x11_input;<br>
> - x += width;<br>
> + if (wl_list_empty(&configured_output_list))<br>
> + for (i = 0; i < count; i++) {<br>
> + if (x11_compositor_create_output(c, x, 0, width, height,<br>
> + fullscreen, no_input) < 0)<br>
> + goto err_x11_input;<br>
> + x += width;<br>
> + }<br>
> + else {<br>
> + wl_list_for_each_reverse(o, &configured_output_list, link) {<br>
> + if (x11_compositor_create_output(c, x, 0,<br>
> + width_arg ? width_arg :<br>
> + o->width,<br>
> + height_arg ? height_arg :<br>
> + o->height,<br>
> + fullscreen, no_input) < 0)<br>
> + goto err_x11_input;<br>
> + x += width_arg ? width_arg : o->width;<br>
> + output_count++;<br>
> + if (count_arg && output_count >= count_arg)<br>
> + break;<br>
> + }<br>
> +<br>
> + if (count > output_count)<br>
> + for (i = output_count; i < count; i++) {<br>
> + if (x11_compositor_create_output(c, x, 0, width, height,<br>
> + fullscreen, no_input) < 0)<br>
> + goto err_x11_input;<br>
> + x += width;<br>
> + }<br>
> }<br>
><br>
> c->xcb_source =<br>
> @@ -1126,6 +1176,51 @@ err_free:<br>
> return NULL;<br>
> }<br>
><br>
> +static void<br>
> +output_section_done(void *data)<br>
> +{<br>
> + struct x11_configured_output *output;<br>
> + int error = 0;<br>
> +<br>
> + output = malloc(sizeof *output);<br>
> +<br>
> + if (!output || !output_name || !output_width || !output_height) {<br>
> + free(output_name);<br>
> + output_name = NULL;<br>
> +<br>
> + goto err_free;<br>
> + }<br>
> +<br>
> + output->name = output_name;<br>
> +<br>
> + if (sscanf(output_width, "%d", &output->width) != 1) {<br>
> + weston_log("Invalid width \"%s\" for output %s\n",<br>
> + output_width, output_name);<br>
> + error = 1;<br>
> + }<br>
> +<br>
> + if (sscanf(output_height, "%d", &output->height) != 1) {<br>
> + weston_log("Invalid height \"%s\" for output %s\n",<br>
> + output_height, output_name);<br>
> + error = 1;<br>
> + }<br>
<br>
</div></div>The above would simplify a bit, if you used just 'mode' (referring to<br>
my comments further down).<br>
<div class="im"><br>
> +<br>
> + if (error) {<br>
> + x11_free_configured_output(output);<br>
> + goto err_free;<br>
> + } else if (output_name[0] != 'X') {<br>
> + weston_log("Invalid output name \"%s\"\n", output_name);<br>
> + x11_free_configured_output(output);<br>
> + } else<br>
> + wl_list_insert(&configured_output_list, &output->link);<br>
<br>
</div>I see you are not using output->name anywhere else, so you practically<br>
discard it. I guess that left for follow-up patches, when you implement<br>
the relative positioning directives?<br>
<br>
Would be nice to see the output name in the X window title.<br></blockquote><div><br>Yes, we will need to identify the output as per user definition. I like the idea of setting the title to the output name.<br> <br></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> +<br>
> +err_free:<br>
> + free(output_width);<br>
> + output_width = NULL;<br>
> + free(output_height);<br>
> + output_height = NULL;<br>
<br>
</div>Missing x11_free_configured_output() call? Jump from the first goto<br>
err_free.<br></blockquote><div><br>I don't really like the way the clean-up is structured currently, hopefully it will become simpler when it's reworked to accept mode instead of width/height.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> +}<br>
> +<br>
> WL_EXPORT struct weston_compositor *<br>
> backend_init(struct wl_display *display, int argc, char *argv[],<br>
> const char *config_file)<br>
> @@ -1134,15 +1229,38 @@ backend_init(struct wl_display *display, int argc, char *argv[],<br>
> int no_input = 0;<br>
><br>
> const struct weston_option x11_options[] = {<br>
> - { WESTON_OPTION_INTEGER, "width", 0, &width },<br>
> - { WESTON_OPTION_INTEGER, "height", 0, &height },<br>
> + { WESTON_OPTION_INTEGER, "width", 0, &width_arg },<br>
> + { WESTON_OPTION_INTEGER, "height", 0, &height_arg },<br>
<br>
</div>With size in config file, do we even need the --width and --height<br>
command line parameters anymore?<br></blockquote><div><br>Yes, I think we'll keep these around. When a user passes --width or --height, it will set all outputs to use this parameter.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The x11 backend is just a testing backend, so I see no reason to avoid<br>
having a config file. We can still have the hardcoded default size.<br></blockquote><div><br>Who said anything about getting rid of the hardcoded default size?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Oh, another though, maybe --width and --height should set only the<br>
default size, and config would override that? Yes, it's a precedence<br>
violation, but these two overriding the output config seems less<br>
convenient than just setting defaults.</blockquote><div><br>I don't agree with this. I think the command line options should always take precedence.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
These command line options will<br>
not grow per-output versions nor handle relative positioning, either.<br></blockquote><div><br>They wont, but that's not a reason to ignore them.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> { WESTON_OPTION_BOOLEAN, "fullscreen", 0, &fullscreen },<br>
> - { WESTON_OPTION_INTEGER, "output-count", 0, &count },<br>
> + { WESTON_OPTION_INTEGER, "output-count", 0, &count_arg },<br>
<br>
</div>I could ask the same about output-count, since your patch takes care of<br>
that based on what is configured in the file, but I think this could be<br>
handy to keep.<br>
<div class="im"><br>
> { WESTON_OPTION_BOOLEAN, "no-input", 0, &no_input },<br>
> };<br>
><br>
> parse_options(x11_options, ARRAY_LENGTH(x11_options), argc, argv);<br>
><br>
> + if (width_arg)<br>
> + width = width_arg;<br>
> + if (height_arg)<br>
> + height = height_arg;<br>
> + if (count_arg)<br>
> + count = count_arg;<br>
> +<br>
> + wl_list_init(&configured_output_list);<br>
> +<br>
> + const struct config_key x11_config_keys[] = {<br>
> + { "name", CONFIG_KEY_STRING, &output_name },<br>
> + { "width", CONFIG_KEY_STRING, &output_width },<br>
> + { "height", CONFIG_KEY_STRING, &output_height },<br>
> + };<br>
<br>
</div>Why 'width' and 'height' instead of just 'mode' like the DRM backend<br>
uses?<br>
<br>
This will make an [output] section sometimes use 'mode' and sometimes<br>
'width' and 'height', which I think is confusing. Using only 'mode'<br>
everywhere would be consistent within a config file. 'mode' with just<br>
<width>x<height> is clear, and I might even go as far as saying that it<br>
could accept even a complete modeline, and use only the active image<br>
area, discarding other parameters. That would allow one to just copy a<br>
DRM output section and change the name to have a working x11 output<br>
section for testing.<br></blockquote><div><br>Yes, we will use mode=<width>x<height>. I don't think we need to go the extra mile to support raw modelines though.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
> +<br>
> + const struct config_section config_section[] = {<br>
> + { "output", x11_config_keys,<br>
> + ARRAY_LENGTH(x11_config_keys), output_section_done },<br>
> + };<br>
> +<br>
> + parse_config_file(config_file, config_section,<br>
> + ARRAY_LENGTH(config_section), NULL);<br>
> +<br>
> return x11_compositor_create(display,<br>
> width, height, count, fullscreen,<br>
> no_input,<br>
> diff --git a/weston.ini b/weston.ini<br>
> index c2d6369..1de8e29 100644<br>
> --- a/weston.ini<br>
> +++ b/weston.ini<br>
> @@ -41,3 +41,8 @@ duration=600<br>
> #[output]<br>
> #name=VGA1<br>
> #mode=173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync<br>
> +<br>
> +#[output]<br>
> +#name=X1<br>
> +#width=1024<br>
> +#height=768<br>
<br>
<br>
</div></div>Thanks,<br>
pq<br>
</blockquote></div><br>