[Goodies-commits] r6113 - in xfce4-screenshooter-plugin/trunk: . lib
Jerome Guelfucci
jeromeg at xfce.org
Sat Nov 15 18:22:14 CET 2008
Author: jeromeg
Date: 2008-11-15 17:22:14 +0000 (Sat, 15 Nov 2008)
New Revision: 6113
Modified:
xfce4-screenshooter-plugin/trunk/ChangeLog
xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
Log:
* lib/screenshooter-utils.c:
- (screenshooter_take_screenshot) Use gnome-screenshot technic,
grab the screenshot on the root window, to also take things such
as menus.
Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog 2008-11-15 16:55:23 UTC (rev 6112)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog 2008-11-15 17:22:14 UTC (rev 6113)
@@ -1,5 +1,12 @@
2008-11-15 jeromeg
+ * lib/screenshooter-utils.c:
+ - (screenshooter_take_screenshot) Use gnome-screenshot technic,
+ grab the screenshot on the root window, to also take things such
+ as menus.
+
+2008-11-15 jeromeg
+
* po/: update-po.
2008-11-15 jeromeg
Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c 2008-11-15 16:55:23 UTC (rev 6112)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c 2008-11-15 17:22:14 UTC (rev 6113)
@@ -132,17 +132,23 @@
GdkPixbuf *screenshot;
GdkWindow *window = NULL;
GdkWindow *window2 = NULL;
+ GdkWindow *root;
GdkScreen *screen;
+ gint x_real_orig, y_real_orig, x_orig, y_orig;
+ gint width, real_width, height, real_height;
- gint width;
- gint height;
- /* gdk_get_default_root_window (), needs_unref enables us to unref *window
- only if a non default window has been grabbed */
+ /* gdk_get_default_root_window () does not need to be unrefed,
+ * needs_unref enables us to unref *window only if a non default
+ * window has been grabbed
+ * */
gboolean needs_unref = TRUE;
/* Get the screen on which the screenshot should be taken */
screen = gdk_screen_get_default ();
+ /* Get the root window */
+ root = gdk_get_default_root_window ();
+
/* Get the window/desktop we want to screenshot*/
if (mode == FULLSCREEN)
{
@@ -182,14 +188,43 @@
/* wait for n=delay seconds */
sleep (delay);
- /* get the size of the part of the screen we want to screenshot */
- gdk_drawable_get_size(window, &width, &height);
+ /* Based on gnome-screenshot code */
+
+ /* get the size and the origin of the part of the screen we want to
+ * screenshot */
+ gdk_drawable_get_size (window, &real_width, &real_height);
+ gdk_window_get_origin (window, &x_real_orig, &y_real_orig);
- /* get the screenshot */
- screenshot = gdk_pixbuf_get_from_drawable (NULL,
- window,
- NULL, 0, 0, 0, 0,
- width, height);
+ /* Don't grab thing offscreen */
+
+ x_orig = x_real_orig;
+ y_orig = y_real_orig;
+ width = real_width;
+ height = real_height;
+
+ if (x_orig < 0)
+ {
+ width = width + x_orig;
+ x_orig = 0;
+ }
+
+ if (y_orig < 0)
+ {
+ height = height + y_orig;
+ y_orig = 0;
+ }
+
+ if (x_orig + width > gdk_screen_width ())
+ width = gdk_screen_width () - x_orig;
+
+ if (y_orig + height > gdk_screen_height ())
+ height = gdk_screen_height () - y_orig;
+
+ /* Take the screenshot from the root GdkWindow, to grab things such as
+ * menus. */
+ screenshot = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
+ x_orig, y_orig, 0, 0,
+ width, height);
if (needs_unref)
g_object_unref (window);
More information about the Goodies-commits
mailing list