<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><br><div><div class="h5"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


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

</div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><br>
<br>
&gt; +             else {<br>
&gt; +                     ss_area_width = MAX(ss_area_width, ss_output-&gt;offset_x + ss_output-&gt;width);<br>
&gt; +                     ss_area_height = MAX(ss_area_height, ss_output-&gt;offset_y + ss_output-&gt;height);<br>
&gt; +             }<br>
&gt; +             num_outputs++;<br>
&gt; +     }<br></div></blockquote></div></div></blockquote></div><br><br>
To be clear here, !num_outputs means the first output. If there is only a single output,<br>
the else condition will never be reached.<br>