[PATCH] screenshooter: Properly handle multiple outputs.

Scott Moreau oreaus at gmail.com
Wed Apr 4 10:06:58 PDT 2012


>
>
>
>> >       } else if (strcmp(interface, "wl_shm") == 0) {
>> >               shm = wl_display_bind(display, id, &wl_shm_interface);
>> >       } else if (strcmp(interface, "screenshooter") == 0) {
>> > @@ -144,6 +171,8 @@ int main(int argc, char *argv[])
>> >       struct wl_display *display;
>> >       struct wl_buffer *buffer;
>> >       void *data = NULL;
>> > +     struct ss_output *ss_output;
>> > +     int ss_area_width = 0, ss_area_height = 0, num_outputs = 0;
>> >
>> >       display = wl_display_connect(NULL);
>> >       if (display == NULL) {
>> > @@ -151,6 +180,7 @@ int main(int argc, char *argv[])
>> >               return -1;
>> >       }
>> >
>> > +     wl_list_init(&output_list);
>> >       wl_display_add_global_listener(display, handle_global,
>> &screenshooter);
>> >       wl_display_iterate(display, WL_DISPLAY_READABLE);
>> >       wl_display_roundtrip(display);
>> > @@ -159,11 +189,32 @@ int main(int argc, char *argv[])
>> >               return -1;
>> >       }
>> >
>> > -     buffer = create_shm_buffer(output_width, output_height, &data);
>> > -     screenshooter_shoot(screenshooter, output, buffer);
>> > +     wl_list_for_each(ss_output, &output_list, link) {
>> > +
>> > +             if (!num_outputs) {
>> > +                     ss_area_width = ss_output->width +
>> ss_output->offset_x;
>> > +                     ss_area_height = ss_output->height +
>> ss_output->offset_y;
>> > +             }
>>
>> I'd just set ss_area_width/height to 0 initially.
>>
>
> num_outputs must be initialised since it checks !num_outputs on the first
> pass.
> Unless there is another way to do this, we need to set num_outputs to
> begin with.
>
>>
>>
>> > +             else {
>> > +                     ss_area_width = MAX(ss_area_width,
>> ss_output->offset_x + ss_output->width);
>> > +                     ss_area_height = MAX(ss_area_height,
>> ss_output->offset_y + ss_output->height);
>> > +             }
>> > +             num_outputs++;
>> > +     }
>>
>

To be clear here, !num_outputs means the first output. If there is only a
single output,
the else condition will never be reached.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20120404/1c1c7f37/attachment.htm>


More information about the wayland-devel mailing list