Skip to content
Snippets Groups Projects
Commit 834bd4bc authored by Jerome Guelfucci's avatar Jerome Guelfucci
Browse files

* 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.


(Old svn revision: 6113)
parent cfbc91d4
No related branches found
No related tags found
No related merge requests found
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.
......
......@@ -132,17 +132,23 @@ GdkPixbuf *screenshooter_take_screenshot (gint mode,
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 @@ GdkPixbuf *screenshooter_take_screenshot (gint mode,
/* 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);
/* 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;
/* get the screenshot */
screenshot = gdk_pixbuf_get_from_drawable (NULL,
window,
NULL, 0, 0, 0, 0,
width, height);
/* 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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment