From e3e76ec0892ab110bea5b4da4db623160db39141 Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Wed, 5 Dec 2012 10:11:53 -0300
Subject: [PATCH shell] Screenshot extension: make sure we use a compatible
cairo surface - SL #4104
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
To create the screenshot surface, use
gdk_window_create_similar_surface instead. In toolkit
(Activity.get_preview) we do the same. It creates a more compatible
surface. Otherwise we are hardcoding the format, which showed to fail
in XO-4 hardware.
To set the window surface as the source surface on the new context,
use gdk_cairo_set_source_window instead. This way there is no need to
create a new cairo context to get the surface, use the gdk window
directly instead.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
extensions/globalkey/screenshot.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/extensions/globalkey/screenshot.py b/extensions/globalkey/screenshot.py
index 5abf15b..4ece642 100644
a
|
b
|
def handle_key_press(key): |
42 | 42 | window = Gdk.get_default_root_window() |
43 | 43 | width, height = window.get_width(), window.get_height() |
44 | 44 | |
45 | | window_cr = Gdk.cairo_create(window) |
46 | | window_surface = window_cr.get_target() |
47 | | screenshot_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) |
| 45 | screenshot_surface = Gdk.Window.create_similar_surface( |
| 46 | window, cairo.CONTENT_COLOR, width, height) |
| 47 | |
48 | 48 | cr = cairo.Context(screenshot_surface) |
49 | | cr.set_source_surface(window_surface) |
| 49 | Gdk.cairo_set_source_window(cr, window, 0, 0) |
50 | 50 | cr.paint() |
51 | 51 | screenshot_surface.write_to_png(file_path) |
52 | 52 | |