diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2021-09-03 14:46:53 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2021-09-03 14:52:44 +0300 |
commit | 5b8d4c56e7d793cf38286ed20b1291e3527aa85c (patch) | |
tree | f3d957e78d13b483946eadb16092504fd5b39c6c /clients | |
parent | ba86e440b28d1ade0b264ee4afd789faff56b30c (diff) |
clients/screenshooter: Fix taking screenshot on multiple outputs
Turns out we were re-initializing the buffers min/max values each time
for each output, thus not computing the entire combined output. This is
a trivial fix.
Bug-AGL: SPEC-4064
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: Ie0c7490c902273b42c81e09cd08e480f30a654c0
Diffstat (limited to 'clients')
-rw-r--r-- | clients/screenshooter.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/clients/screenshooter.c b/clients/screenshooter.c index faced55..64dc76a 100644 --- a/clients/screenshooter.c +++ b/clients/screenshooter.c @@ -395,28 +395,15 @@ screenshot_write_png(const struct buffer_size *buff_size, free(data); } -static int +static void screenshot_set_buffer_size_per_output(struct buffer_size *buff_size, struct screenshooter_output *output) { - buff_size->min_x = buff_size->min_y = INT_MAX; - buff_size->max_x = buff_size->max_y = INT_MIN; - buff_size->min_x = MIN(buff_size->min_x, output->offset_x); buff_size->min_y = MIN(buff_size->min_y, output->offset_y); - buff_size->max_x = - MAX(buff_size->max_x, output->offset_x + output->width); - buff_size->max_y = - MAX(buff_size->max_y, output->offset_y + output->height); - - if (buff_size->max_x <= buff_size->min_x || - buff_size->max_y <= buff_size->min_y) - return -1; - - buff_size->width = buff_size->max_x - buff_size->min_x; - buff_size->height = buff_size->max_y - buff_size->min_y; + buff_size->max_x = MAX(buff_size->max_x, output->offset_x + output->width); + buff_size->max_y = MAX(buff_size->max_y, output->offset_y + output->height); - return 0; } static void @@ -432,12 +419,21 @@ screenshot_set_buffer_size(struct buffer_size *buff_size, struct wl_list *output struct screenshooter_output *output; int pos = 0; + buff_size->min_x = buff_size->min_y = INT_MAX; + buff_size->max_x = buff_size->max_y = INT_MIN; + wl_list_for_each_reverse(output, output_list, link) screenshot_compute_output_offset(&pos, output); wl_list_for_each(output, output_list, link) - if (screenshot_set_buffer_size_per_output(buff_size, output)) - return -1; + screenshot_set_buffer_size_per_output(buff_size, output); + + if (buff_size->max_x <= buff_size->min_x || + buff_size->max_y <= buff_size->min_y) + return -1; + + buff_size->width = buff_size->max_x - buff_size->min_x; + buff_size->height = buff_size->max_y - buff_size->min_y; return 0; } |