Kristian Høgsberg | ffd710e | 2008-12-02 15:15:01 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008 Kristian Høgsberg |
| 3 | * |
Bryce Harrington | 1f6b0d1 | 2015-06-10 22:48:59 -0700 | [diff] [blame] | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
Kristian Høgsberg | ffd710e | 2008-12-02 15:15:01 -0500 | [diff] [blame] | 10 | * |
Bryce Harrington | 1f6b0d1 | 2015-06-10 22:48:59 -0700 | [diff] [blame] | 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
Kristian Høgsberg | ffd710e | 2008-12-02 15:15:01 -0500 | [diff] [blame] | 22 | */ |
| 23 | |
Kristian Høgsberg | bdd8377 | 2013-08-12 21:45:19 -0700 | [diff] [blame] | 24 | #include "config.h" |
| 25 | |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 26 | #include <stdint.h> |
Kristian Høgsberg | bdd8377 | 2013-08-12 21:45:19 -0700 | [diff] [blame] | 27 | #include <errno.h> |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 28 | #include <stdlib.h> |
| 29 | #include <stdio.h> |
| 30 | #include <string.h> |
| 31 | #include <fcntl.h> |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 32 | #include <unistd.h> |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 33 | #include <limits.h> |
| 34 | #include <sys/param.h> |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 35 | #include <sys/mman.h> |
Kristian Høgsberg | f02a649 | 2012-03-12 01:05:25 -0400 | [diff] [blame] | 36 | #include <cairo.h> |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 37 | |
Pekka Paalanen | 50719bc | 2011-11-22 14:18:50 +0200 | [diff] [blame] | 38 | #include <wayland-client.h> |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 39 | #include "weston-screenshooter-client-protocol.h" |
Jon Cruz | 4678bab | 2015-06-15 15:37:07 -0700 | [diff] [blame] | 40 | #include "shared/os-compatibility.h" |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 41 | |
| 42 | /* The screenshooter is a good example of a custom object exposed by |
| 43 | * the compositor and serves as a test bed for implementing client |
| 44 | * side marshalling outside libwayland.so */ |
| 45 | |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 46 | static struct wl_shm *shm; |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 47 | static struct weston_screenshooter *screenshooter; |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 48 | static struct wl_list output_list; |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 49 | int min_x, min_y, max_x, max_y; |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 50 | int buffer_copy_done; |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 51 | |
| 52 | struct screenshooter_output { |
| 53 | struct wl_output *output; |
| 54 | struct wl_buffer *buffer; |
| 55 | int width, height, offset_x, offset_y; |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 56 | void *data; |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 57 | struct wl_list link; |
| 58 | }; |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 59 | |
| 60 | static void |
| 61 | display_handle_geometry(void *data, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 62 | struct wl_output *wl_output, |
| 63 | int x, |
| 64 | int y, |
| 65 | int physical_width, |
| 66 | int physical_height, |
| 67 | int subpixel, |
| 68 | const char *make, |
Kristian Høgsberg | 0e69647 | 2012-07-22 15:49:57 -0400 | [diff] [blame] | 69 | const char *model, |
| 70 | int transform) |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 71 | { |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 72 | struct screenshooter_output *output; |
| 73 | |
| 74 | output = wl_output_get_user_data(wl_output); |
| 75 | |
| 76 | if (wl_output == output->output) { |
| 77 | output->offset_x = x; |
| 78 | output->offset_y = y; |
| 79 | } |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 80 | } |
| 81 | |
Kristian Høgsberg | bdd8377 | 2013-08-12 21:45:19 -0700 | [diff] [blame] | 82 | static void * |
| 83 | xmalloc(size_t size) |
| 84 | { |
| 85 | void *p; |
| 86 | |
| 87 | p = malloc(size); |
| 88 | if (p == NULL) { |
| 89 | fprintf(stderr, "%s: out of memory\n", |
| 90 | program_invocation_short_name); |
| 91 | exit(EXIT_FAILURE); |
| 92 | } |
| 93 | |
| 94 | return p; |
| 95 | } |
| 96 | |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 97 | static void |
| 98 | display_handle_mode(void *data, |
| 99 | struct wl_output *wl_output, |
| 100 | uint32_t flags, |
| 101 | int width, |
| 102 | int height, |
| 103 | int refresh) |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 104 | { |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 105 | struct screenshooter_output *output; |
| 106 | |
| 107 | output = wl_output_get_user_data(wl_output); |
| 108 | |
Kristian Høgsberg | 1a36156 | 2012-04-04 14:52:35 -0400 | [diff] [blame] | 109 | if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT)) { |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 110 | output->width = width; |
| 111 | output->height = height; |
| 112 | } |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static const struct wl_output_listener output_listener = { |
| 116 | display_handle_geometry, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 117 | display_handle_mode |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 118 | }; |
| 119 | |
Kristian Høgsberg | 4fe1a3e | 2010-08-10 14:02:48 -0400 | [diff] [blame] | 120 | static void |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 121 | screenshot_done(void *data, struct weston_screenshooter *screenshooter) |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 122 | { |
| 123 | buffer_copy_done = 1; |
| 124 | } |
| 125 | |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 126 | static const struct weston_screenshooter_listener screenshooter_listener = { |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 127 | screenshot_done |
| 128 | }; |
| 129 | |
| 130 | static void |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 131 | handle_global(void *data, struct wl_registry *registry, |
| 132 | uint32_t name, const char *interface, uint32_t version) |
Kristian Høgsberg | 4fe1a3e | 2010-08-10 14:02:48 -0400 | [diff] [blame] | 133 | { |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 134 | static struct screenshooter_output *output; |
| 135 | |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 136 | if (strcmp(interface, "wl_output") == 0) { |
Brian Lovin | bc91926 | 2013-08-07 15:34:59 -0700 | [diff] [blame] | 137 | output = xmalloc(sizeof *output); |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 138 | output->output = wl_registry_bind(registry, name, |
| 139 | &wl_output_interface, 1); |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 140 | wl_list_insert(&output_list, &output->link); |
| 141 | wl_output_add_listener(output->output, &output_listener, output); |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 142 | } else if (strcmp(interface, "wl_shm") == 0) { |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 143 | shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 144 | } else if (strcmp(interface, "weston_screenshooter") == 0) { |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 145 | screenshooter = wl_registry_bind(registry, name, |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 146 | &weston_screenshooter_interface, |
| 147 | 1); |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | |
Pekka Paalanen | 0eab05d | 2013-01-22 14:53:55 +0200 | [diff] [blame] | 151 | static void |
| 152 | handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) |
| 153 | { |
| 154 | /* XXX: unimplemented */ |
| 155 | } |
| 156 | |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 157 | static const struct wl_registry_listener registry_listener = { |
Pekka Paalanen | 0eab05d | 2013-01-22 14:53:55 +0200 | [diff] [blame] | 158 | handle_global, |
| 159 | handle_global_remove |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 160 | }; |
| 161 | |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 162 | static struct wl_buffer * |
| 163 | create_shm_buffer(int width, int height, void **data_out) |
| 164 | { |
Kristian Høgsberg | 1662628 | 2012-04-03 11:21:27 -0400 | [diff] [blame] | 165 | struct wl_shm_pool *pool; |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 166 | struct wl_buffer *buffer; |
| 167 | int fd, size, stride; |
| 168 | void *data; |
| 169 | |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 170 | stride = width * 4; |
| 171 | size = stride * height; |
Pekka Paalanen | 1da1b8f | 2012-06-06 16:59:43 +0300 | [diff] [blame] | 172 | |
| 173 | fd = os_create_anonymous_file(size); |
| 174 | if (fd < 0) { |
| 175 | fprintf(stderr, "creating a buffer file for %d B failed: %m\n", |
| 176 | size); |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 177 | return NULL; |
| 178 | } |
| 179 | |
| 180 | data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 181 | if (data == MAP_FAILED) { |
| 182 | fprintf(stderr, "mmap failed: %m\n"); |
| 183 | close(fd); |
| 184 | return NULL; |
| 185 | } |
| 186 | |
Kristian Høgsberg | 1662628 | 2012-04-03 11:21:27 -0400 | [diff] [blame] | 187 | pool = wl_shm_create_pool(shm, fd, size); |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 188 | close(fd); |
Kristian Høgsberg | 1662628 | 2012-04-03 11:21:27 -0400 | [diff] [blame] | 189 | buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, |
| 190 | WL_SHM_FORMAT_XRGB8888); |
| 191 | wl_shm_pool_destroy(pool); |
Kristian Høgsberg | 8544903 | 2011-05-02 12:11:07 -0400 | [diff] [blame] | 192 | |
| 193 | *data_out = data; |
| 194 | |
| 195 | return buffer; |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 196 | } |
| 197 | |
Tiago Vignatti | 4d0d203 | 2011-07-26 11:42:59 +0300 | [diff] [blame] | 198 | static void |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 199 | write_png(int width, int height) |
Kristian Høgsberg | 8417d43 | 2011-07-27 05:58:57 -0700 | [diff] [blame] | 200 | { |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 201 | int output_stride, buffer_stride, i; |
Kristian Høgsberg | f02a649 | 2012-03-12 01:05:25 -0400 | [diff] [blame] | 202 | cairo_surface_t *surface; |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 203 | void *data, *d, *s; |
| 204 | struct screenshooter_output *output, *next; |
| 205 | |
| 206 | buffer_stride = width * 4; |
| 207 | |
Kristian Høgsberg | bdd8377 | 2013-08-12 21:45:19 -0700 | [diff] [blame] | 208 | data = xmalloc(buffer_stride * height); |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 209 | if (!data) |
| 210 | return; |
| 211 | |
| 212 | wl_list_for_each_safe(output, next, &output_list, link) { |
| 213 | output_stride = output->width * 4; |
| 214 | s = output->data; |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 215 | d = data + (output->offset_y - min_y) * buffer_stride + |
| 216 | (output->offset_x - min_x) * 4; |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 217 | |
| 218 | for (i = 0; i < output->height; i++) { |
| 219 | memcpy(d, s, output_stride); |
| 220 | d += buffer_stride; |
| 221 | s += output_stride; |
| 222 | } |
| 223 | |
| 224 | free(output); |
| 225 | } |
Tiago Vignatti | 4d0d203 | 2011-07-26 11:42:59 +0300 | [diff] [blame] | 226 | |
Kristian Høgsberg | f02a649 | 2012-03-12 01:05:25 -0400 | [diff] [blame] | 227 | surface = cairo_image_surface_create_for_data(data, |
| 228 | CAIRO_FORMAT_ARGB32, |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 229 | width, height, buffer_stride); |
Kristian Høgsberg | f02a649 | 2012-03-12 01:05:25 -0400 | [diff] [blame] | 230 | cairo_surface_write_to_png(surface, "wayland-screenshot.png"); |
| 231 | cairo_surface_destroy(surface); |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 232 | free(data); |
Tiago Vignatti | 4d0d203 | 2011-07-26 11:42:59 +0300 | [diff] [blame] | 233 | } |
| 234 | |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 235 | static int |
| 236 | set_buffer_size(int *width, int *height) |
| 237 | { |
| 238 | struct screenshooter_output *output; |
| 239 | min_x = min_y = INT_MAX; |
| 240 | max_x = max_y = INT_MIN; |
Scott Moreau | bb58983 | 2012-08-18 19:52:42 -0600 | [diff] [blame] | 241 | int position = 0; |
| 242 | |
| 243 | wl_list_for_each_reverse(output, &output_list, link) { |
| 244 | output->offset_x = position; |
| 245 | position += output->width; |
| 246 | } |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 247 | |
| 248 | wl_list_for_each(output, &output_list, link) { |
| 249 | min_x = MIN(min_x, output->offset_x); |
| 250 | min_y = MIN(min_y, output->offset_y); |
| 251 | max_x = MAX(max_x, output->offset_x + output->width); |
| 252 | max_y = MAX(max_y, output->offset_y + output->height); |
| 253 | } |
| 254 | |
| 255 | if (max_x <= min_x || max_y <= min_y) |
| 256 | return -1; |
| 257 | |
| 258 | *width = max_x - min_x; |
| 259 | *height = max_y - min_y; |
| 260 | |
| 261 | return 0; |
| 262 | } |
| 263 | |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 264 | int main(int argc, char *argv[]) |
| 265 | { |
| 266 | struct wl_display *display; |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 267 | struct wl_registry *registry; |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 268 | struct screenshooter_output *output; |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 269 | int width, height; |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 270 | |
Kristian Høgsberg | c4a42ca | 2013-02-13 13:40:58 -0500 | [diff] [blame] | 271 | if (getenv("WAYLAND_SOCKET") == NULL) { |
Bryce W. Harrington | 3d2046e | 2013-07-23 21:53:26 +0000 | [diff] [blame] | 272 | fprintf(stderr, "%s must be launched by weston.\n" |
Kristian Høgsberg | 473f248 | 2013-08-12 22:15:38 -0700 | [diff] [blame] | 273 | "Use the MOD+S shortcut to take a screenshot.\n", |
| 274 | program_invocation_short_name); |
Kristian Høgsberg | c4a42ca | 2013-02-13 13:40:58 -0500 | [diff] [blame] | 275 | return -1; |
| 276 | } |
| 277 | |
Kristian Høgsberg | 2bb3ebe | 2010-12-01 15:36:20 -0500 | [diff] [blame] | 278 | display = wl_display_connect(NULL); |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 279 | if (display == NULL) { |
| 280 | fprintf(stderr, "failed to create display: %m\n"); |
| 281 | return -1; |
| 282 | } |
| 283 | |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 284 | wl_list_init(&output_list); |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 285 | registry = wl_display_get_registry(display); |
| 286 | wl_registry_add_listener(registry, ®istry_listener, NULL); |
| 287 | wl_display_dispatch(display); |
Kristian Høgsberg | a8d1fa7 | 2011-08-23 18:14:06 -0400 | [diff] [blame] | 288 | wl_display_roundtrip(display); |
Kristian Høgsberg | 4fe1a3e | 2010-08-10 14:02:48 -0400 | [diff] [blame] | 289 | if (screenshooter == NULL) { |
| 290 | fprintf(stderr, "display doesn't support screenshooter\n"); |
| 291 | return -1; |
| 292 | } |
| 293 | |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 294 | weston_screenshooter_add_listener(screenshooter, |
| 295 | &screenshooter_listener, |
| 296 | screenshooter); |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 297 | |
Scott Moreau | 2074f1d | 2012-04-20 13:37:35 -0600 | [diff] [blame] | 298 | if (set_buffer_size(&width, &height)) |
| 299 | return -1; |
| 300 | |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 301 | |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 302 | wl_list_for_each(output, &output_list, link) { |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 303 | output->buffer = create_shm_buffer(output->width, output->height, &output->data); |
Jonas Ådahl | cf1efd2 | 2015-11-17 16:00:34 +0800 | [diff] [blame^] | 304 | weston_screenshooter_shoot(screenshooter, |
| 305 | output->output, |
| 306 | output->buffer); |
Scott Moreau | 062be7e | 2012-04-20 13:37:33 -0600 | [diff] [blame] | 307 | buffer_copy_done = 0; |
| 308 | while (!buffer_copy_done) |
| 309 | wl_display_roundtrip(display); |
Scott Moreau | 80d27b7 | 2012-04-04 11:49:21 -0600 | [diff] [blame] | 310 | } |
| 311 | |
Scott Moreau | 72c2372 | 2012-04-20 13:37:34 -0600 | [diff] [blame] | 312 | write_png(width, height); |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 313 | |
| 314 | return 0; |
| 315 | } |