screenshooter: Grab pixel data directly before buffer swap
[profile/ivi/weston-ivi-shell.git] / src / compositor-x11.c
index 122e38a..6d9bb0e 100644 (file)
@@ -212,6 +212,8 @@ x11_output_repaint(struct weston_output *output_base,
        wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
                weston_surface_draw(surface, &output->base, damage);
 
+       weston_output_do_read_pixels(&output->base);
+
        eglSwapBuffers(compositor->base.display, output->egl_surface);
 
        wl_event_source_timer_update(output->finish_frame_timer, 10);
@@ -344,20 +346,6 @@ x11_output_set_icon(struct x11_compositor *c,
        pixman_image_unref(image);
 }
 
-static void
-x11_output_read_pixels(struct weston_output *output_base, void *data)
-{
-       struct x11_output *output = (struct x11_output *) output_base;
-       struct x11_compositor *compositor =
-               (struct x11_compositor *) output->base.compositor;
-
-       eglMakeCurrent(compositor->base.display, output->egl_surface,
-                       output->egl_surface, compositor->base.context);
-
-       glReadPixels(0, 0, output_base->current->width, output_base->current->height,
-                               GL_BGRA_EXT, GL_UNSIGNED_BYTE, data);
-}
-
 static int
 x11_compositor_create_output(struct x11_compositor *c, int x, int y,
                             int width, int height, int fullscreen)
@@ -465,12 +453,13 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
        output->finish_frame_timer =
                wl_event_loop_add_timer(loop, finish_frame_handler, output);
 
+       output->base.origin = output->base.current;
        output->base.repaint = x11_output_repaint;
        output->base.destroy = x11_output_destroy;
        output->base.assign_planes = NULL;
-       output->base.read_pixels = x11_output_read_pixels;
        output->base.set_backlight = NULL;
        output->base.set_dpms = NULL;
+       output->base.switch_mode = NULL;
 
        wl_list_insert(c->base.output_list.prev, &output->base.link);
 
@@ -613,9 +602,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
                        }
 
                        output = x11_compositor_find_output(c, focus_in->event);
-                       notify_keyboard_focus(c->base.input_device,
-                                             weston_compositor_get_time(),
-                                             &c->keys);
+                       notify_keyboard_focus(c->base.input_device, &c->keys);
 
                        free(prev);
                        prev = NULL;
@@ -664,7 +651,6 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
                                break;
                        output = x11_compositor_find_output(c, enter_notify->event);
                        notify_pointer_focus(c->base.input_device,
-                                            weston_compositor_get_time(),
                                             &output->base,
                                             output->base.x + enter_notify->event_x,
                                             output->base.y + enter_notify->event_y);
@@ -675,9 +661,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
                        if (enter_notify->state >= Button1Mask)
                                break;
                        output = x11_compositor_find_output(c, enter_notify->event);
-                       notify_pointer_focus(c->base.input_device,
-                                            weston_compositor_get_time(),
-                                            NULL,
+                       notify_pointer_focus(c->base.input_device, NULL,
                                             output->base.x + enter_notify->event_x,
                                             output->base.y + enter_notify->event_y);
                        break;
@@ -702,9 +686,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
                        if (focus_in->mode == XCB_NOTIFY_MODE_WHILE_GRABBED ||
                            focus_in->mode == XCB_NOTIFY_MODE_UNGRAB)
                                break;
-                       notify_keyboard_focus(c->base.input_device,
-                                             weston_compositor_get_time(),
-                                             NULL);
+                       notify_keyboard_focus(c->base.input_device, NULL);
                        break;
 
                default: