summaryrefslogtreecommitdiff
path: root/clients/screenshot.c
diff options
context:
space:
mode:
authorScott Moreau <oreaus@gmail.com>2012-04-20 13:37:33 -0600
committerKristian Høgsberg <krh@bitplanet.net>2012-04-20 16:13:27 -0400
commit062be7ec93bc658f0e5ae02fc1b4e5b43f3f100a (patch)
tree20364dfb905f5694abcf58911453f1d0711a3660 /clients/screenshot.c
parent9074db5d626e01d6d310cfed11b77827f3284c22 (diff)
downloadweston-062be7ec93bc658f0e5ae02fc1b4e5b43f3f100a.tar.gz
screenshooter: Grab pixel data directly before buffer swap
Diffstat (limited to 'clients/screenshot.c')
-rw-r--r--clients/screenshot.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/clients/screenshot.c b/clients/screenshot.c
index 086ddd9c..328d106c 100644
--- a/clients/screenshot.c
+++ b/clients/screenshot.c
@@ -41,6 +41,7 @@
static struct wl_shm *shm;
static struct screenshooter *screenshooter;
static struct wl_list output_list;
+int buffer_copy_done;
struct screenshooter_output {
struct wl_output *output;
@@ -94,6 +95,16 @@ static const struct wl_output_listener output_listener = {
};
static void
+screenshot_done(void *data, struct screenshooter *screenshooter)
+{
+ buffer_copy_done = 1;
+}
+
+static const struct screenshooter_listener screenshooter_listener = {
+ screenshot_done
+};
+
+static void
handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
@@ -188,6 +199,9 @@ int main(int argc, char *argv[])
return -1;
}
+ screenshooter_add_listener(screenshooter, &screenshooter_listener, screenshooter);
+
+
wl_list_for_each(output, &output_list, link) {
width = MAX(width, output->offset_x + output->width);
height = MAX(height, output->offset_y + output->height);
@@ -197,11 +211,12 @@ int main(int argc, char *argv[])
wl_list_for_each_safe(output, next, &output_list, link) {
screenshooter_shoot(screenshooter, output->output, buffer);
+ buffer_copy_done = 0;
+ while (!buffer_copy_done)
+ wl_display_roundtrip(display);
free(output);
}
- wl_display_roundtrip(display);
-
write_png(width, height, data);
return 0;