/*# @method get_image GdkCursor @brief Returns a GdkPixbuf with the image used to display the cursor. @return a GdkPixbuf representing cursor, or NULL Note that depending on the capabilities of the windowing system and on the cursor, GDK may not be able to obtain the image data. In this case, NULL is returned. */ FALCON_FUNC Cursor::get_image( VMARG ) { NO_ARGS GdkPixbuf* pix = gdk_cursor_get_image( GET_CURSOR( vm->self() ) ); if ( pix ) vm->retval( new Gdk::Pixbuf( vm->findWKI( "GdkPixbuf" )->asClass(), pix ) ); else vm->retnil(); }
static VALUE rg_image(VALUE self) { return GOBJ2RVAL(gdk_cursor_get_image(RVAL2GDKCURSOR(self))); }
static GdkPixbuf * screenshot_fallback_get_pixbuf (GdkRectangle *rectangle) { GdkWindow *root, *wm_window = NULL; GdkPixbuf *screenshot; GdkRectangle real_coords, screenshot_coords; Window wm; GtkBorder frame_offset = { 0, 0, 0, 0 }; GdkWindow *window; window = screenshot_fallback_find_current_window (); screenshot_fallback_get_window_rect_coords (window, screenshot_config->include_border, &real_coords, &screenshot_coords); wm = find_wm_window (window); if (wm != None) { GdkRectangle wm_real_coords; wm_window = gdk_x11_window_foreign_new_for_display (gdk_window_get_display (window), wm); screenshot_fallback_get_window_rect_coords (wm_window, FALSE, &wm_real_coords, NULL); frame_offset.left = (gdouble) (real_coords.x - wm_real_coords.x); frame_offset.top = (gdouble) (real_coords.y - wm_real_coords.y); frame_offset.right = (gdouble) (wm_real_coords.width - real_coords.width - frame_offset.left); frame_offset.bottom = (gdouble) (wm_real_coords.height - real_coords.height - frame_offset.top); } if (rectangle) { screenshot_coords.x = rectangle->x - screenshot_coords.x; screenshot_coords.y = rectangle->y - screenshot_coords.y; screenshot_coords.width = rectangle->width; screenshot_coords.height = rectangle->height; } root = gdk_get_default_root_window (); screenshot = gdk_pixbuf_get_from_window (root, screenshot_coords.x, screenshot_coords.y, screenshot_coords.width, screenshot_coords.height); if (!screenshot_config->take_window_shot && !screenshot_config->take_area_shot) mask_monitors (screenshot, root); #ifdef HAVE_X11_EXTENSIONS_SHAPE_H if (screenshot_config->include_border && (wm != None)) { XRectangle *rectangles; GdkPixbuf *tmp; int rectangle_count, rectangle_order, i; /* we must use XShape to avoid showing what's under the rounder corners * of the WM decoration. */ rectangles = XShapeGetRectangles (GDK_DISPLAY_XDISPLAY (gdk_display_get_default()), wm, ShapeBounding, &rectangle_count, &rectangle_order); if (rectangles && rectangle_count > 0) { gboolean has_alpha = gdk_pixbuf_get_has_alpha (screenshot); tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, screenshot_coords.width, screenshot_coords.height); gdk_pixbuf_fill (tmp, 0); for (i = 0; i < rectangle_count; i++) { gint rec_x, rec_y; gint rec_width, rec_height; gint y; /* If we're using invisible borders, the ShapeBounding might not * have the same size as the frame extents, as it would include the * areas for the invisible borders themselves. * In that case, trim every rectangle we get by the offset between the * WM window size and the frame extents. */ rec_x = rectangles[i].x; rec_y = rectangles[i].y; rec_width = rectangles[i].width - (frame_offset.left + frame_offset.right); rec_height = rectangles[i].height - (frame_offset.top + frame_offset.bottom); if (real_coords.x < 0) { rec_x += real_coords.x; rec_x = MAX(rec_x, 0); rec_width += real_coords.x; } if (real_coords.y < 0) { rec_y += real_coords.y; rec_y = MAX(rec_y, 0); rec_height += real_coords.y; } if (screenshot_coords.x + rec_x + rec_width > gdk_screen_width ()) rec_width = gdk_screen_width () - screenshot_coords.x - rec_x; if (screenshot_coords.y + rec_y + rec_height > gdk_screen_height ()) rec_height = gdk_screen_height () - screenshot_coords.y - rec_y; for (y = rec_y; y < rec_y + rec_height; y++) { guchar *src_pixels, *dest_pixels; gint x; src_pixels = gdk_pixbuf_get_pixels (screenshot) + y * gdk_pixbuf_get_rowstride(screenshot) + rec_x * (has_alpha ? 4 : 3); dest_pixels = gdk_pixbuf_get_pixels (tmp) + y * gdk_pixbuf_get_rowstride (tmp) + rec_x * 4; for (x = 0; x < rec_width; x++) { *dest_pixels++ = *src_pixels++; *dest_pixels++ = *src_pixels++; *dest_pixels++ = *src_pixels++; if (has_alpha) *dest_pixels++ = *src_pixels++; else *dest_pixels++ = 255; } } } g_object_unref (screenshot); screenshot = tmp; XFree (rectangles); } } #endif /* HAVE_X11_EXTENSIONS_SHAPE_H */ /* if we have a selected area, there were by definition no cursor in the * screenshot */ if (screenshot_config->include_pointer && !rectangle) { GdkCursor *cursor; GdkPixbuf *cursor_pixbuf; cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_LEFT_PTR); cursor_pixbuf = gdk_cursor_get_image (cursor); if (cursor_pixbuf != NULL) { GdkDeviceManager *manager; GdkDevice *device; GdkRectangle rect; gint cx, cy, xhot, yhot; manager = gdk_display_get_device_manager (gdk_display_get_default ()); device = gdk_device_manager_get_client_pointer (manager); if (wm_window != NULL) gdk_window_get_device_position (wm_window, device, &cx, &cy, NULL); else gdk_window_get_device_position (window, device, &cx, &cy, NULL); sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "x_hot"), "%d", &xhot); sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "y_hot"), "%d", &yhot); /* in rect we have the cursor window coordinates */ rect.x = cx + real_coords.x; rect.y = cy + real_coords.y; rect.width = gdk_pixbuf_get_width (cursor_pixbuf); rect.height = gdk_pixbuf_get_height (cursor_pixbuf); /* see if the pointer is inside the window */ if (gdk_rectangle_intersect (&real_coords, &rect, &rect)) { gint cursor_x, cursor_y; cursor_x = cx - xhot - frame_offset.left; cursor_y = cy - yhot - frame_offset.top; gdk_pixbuf_composite (cursor_pixbuf, screenshot, cursor_x, cursor_y, rect.width, rect.height, cursor_x, cursor_y, 1.0, 1.0, GDK_INTERP_BILINEAR, 255); } g_object_unref (cursor_pixbuf); g_object_unref (cursor); } } screenshot_fallback_fire_flash (window, rectangle); return screenshot; }