Ticket #4104: 0001-Screenshot-global-key-Alt-1-fixed-SL-4104.patch

File 0001-Screenshot-global-key-Alt-1-fixed-SL-4104.patch, 2.2 KB (added by humitos, 10 years ago)
  • extensions/globalkey/screenshot.py

    From 1a2d68bace682f5065aa73c6efa47be364011cfe Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Wed, 5 Dec 2012 10:11:53 -0300
    Subject: [PATCH sugar] Screenshot (global key Alt+1) fixed SL #4104
    
    Without this PATCH we were getting always the same screenshot (image
    repeated) every time that we pressed Alt+1.
    
    I realized that Browse takes screenshots for its Bookmark previews and
    they always work. So, I copied the code from Browse to Sugar itself.
    
    Actually, the code was really similar but for some reason it was not
    working on Sugar.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     extensions/globalkey/screenshot.py | 14 +++++++-------
     1 file changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/extensions/globalkey/screenshot.py b/extensions/globalkey/screenshot.py
    index 5abf15b..a2ad363 100644
    a b def handle_key_press(key): 
    4242    window = Gdk.get_default_root_window()
    4343    width, height = window.get_width(), window.get_height()
    4444
    45     window_cr = Gdk.cairo_create(window)
    46     window_surface = window_cr.get_target()
    47     screenshot_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    48     cr = cairo.Context(screenshot_surface)
    49     cr.set_source_surface(window_surface)
     45    window_surface = Gdk.Window.create_similar_surface(
     46        window, cairo.CONTENT_COLOR, width, height)
     47
     48    cr = cairo.Context(window_surface)
     49    Gdk.cairo_set_source_window(cr, window, 0, 0)
    5050    cr.paint()
    51     screenshot_surface.write_to_png(file_path)
     51    window_surface.write_to_png(file_path)
    5252
    5353    client = GConf.Client.get_default()
    5454    color = client.get_string('/desktop/sugar/user/color')
    def handle_key_press(key): 
    8181        jobject.metadata['title'] = title
    8282        jobject.metadata['keep'] = '0'
    8383        jobject.metadata['buddies'] = ''
    84         jobject.metadata['preview'] = _get_preview_data(screenshot_surface)
     84        jobject.metadata['preview'] = _get_preview_data(window_surface)
    8585        jobject.metadata['icon-color'] = color
    8686        jobject.metadata['mime_type'] = 'image/png'
    8787        jobject.file_path = file_path