def screenshot(self): """ Capture the screenshot based on the window size or the selected window """ x, y = (self.x, self.y) window = self.root width, height = self.width, self.height # if no motion(click and release) # get screenshot of the selected window if self.height < 5 or self.width < 5: xid = get_selected_window() if not xid: print "Can't get the xid of the selected window" exit(EXIT_XID_ERROR) window = gtk.gdk.window_foreign_new(xid) width, height = window.get_size() x = y = 0 pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) pb = pb.get_from_drawable(window, window.get_colormap(), x, y, 0, 0, width, height) if not pb: print "Invalid Pixbuf" exit(EXIT_INVALID_PIXBUF) if self.use_clipboard: self.save_clipboard(pb) else: self.save_file(pb, width, height)
def screenshot(self): """ Capture the screenshot based on the window size or the selected window """ x, y = (self.x, self.y) window = self.root width, height = self.width, self.height # get screenshot of the selected window if self.click_selection: xid = get_selected_window() if not xid: print "Can't get the xid of the selected window" exit(EXIT_XID_ERROR) window = gtk.gdk.window_foreign_new(xid) width, height = window.get_size() x = y = 0 pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) pb = pb.get_from_drawable(window, window.get_colormap(), x, y, 0, 0, width, height) if not pb: print "Invalid Pixbuf" exit(EXIT_INVALID_PIXBUF) if self.use_clipboard: self.save_clipboard(pb) else: self.save_file(pb, width, height)
def screenshot(self): """ Capture the screenshot based on the window size or the selected window """ x, y = (self.x, self.y) window = self.root width, height = self.width, self.height # get screenshot of the selected window if self.click_selection: xid = get_selected_window() if not xid: print "Can't get the xid of the selected window" exit(EXIT_XID_ERROR) selected_window = gtk.gdk.window_foreign_new(xid) width, height = selected_window.get_size() x, y = selected_window.get_origin() pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height) # mask the pixbuf if we have more than one screen root_width, root_height = window.get_size() pb2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, root_width, root_height) pb2 = pb2.get_from_drawable(window, window.get_colormap(), x, y, x, y, width, height) pb2 = self.mask_pixbuf(pb2, root_width, root_height) pb2.copy_area(x, y, width, height, pb, 0, 0) if not pb: print "Invalid Pixbuf" exit(EXIT_INVALID_PIXBUF) if self.use_clipboard: self.save_clipboard(pb) else: self.save_file(pb, width, height) if self.command: self.call_exec(width, height) # daemonize here so we don't mess with the CWD on subprocess if self.use_clipboard: daemonize() else: # exit here instead of inside save_file exit()
def screenshot(self): """ Capture the screenshot based on the window size or the selected window """ x, y = (self.x, self.y) window = self.root width, height = self.width, self.height # get screenshot of the selected window if self.click_selection: xid = get_selected_window() if not xid: print "Can't get the xid of the selected window" exit(EXIT_XID_ERROR) window = gtk.gdk.window_foreign_new(xid) width, height = window.get_size() x = y = 0 pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height) # mask the pixbuf if we have more than one screen if window == self.root and len(self.get_geometry()) > 1: root_width, root_height = window.get_size() pb2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, root_width, root_height) pb2 = pb2.get_from_drawable(window, window.get_colormap(), x, y, x, y, width, height) pb2 = self.mask_pixbuf(pb2, root_width, root_height) pb2.copy_area(x, y, width, height, pb, 0, 0) else: pb = pb.get_from_drawable(window, window.get_colormap(), x, y, 0, 0, width, height) if not pb: print "Invalid Pixbuf" exit(EXIT_INVALID_PIXBUF) if self.use_clipboard: self.save_clipboard(pb) else: self.save_file(pb, width, height)