After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 155061 - Screenshot of an user-defined selection.
Screenshot of an user-defined selection.
Status: RESOLVED FIXED
Product: gnome-utils
Classification: Deprecated
Component: screenshot
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Jonathan Blandford
gnome-utils Maintainers
: 157719 310512 313174 334063 538918 559143 578349 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-10-11 03:28 UTC by Simford
Modified: 2009-04-28 18:25 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch against the CVS HEAD (13.85 KB, patch)
2005-07-17 17:45 UTC, Madhan Raj M
none Details | Review
Woohoo, new patch :-) (16.23 KB, patch)
2009-02-24 06:40 UTC, Vincent Untz
needs-work Details | Review
Updated patch (15.99 KB, patch)
2009-02-24 14:23 UTC, Vincent Untz
committed Details | Review

Description Simford 2004-10-11 03:28:08 UTC
one thing that might be nice to gnome-panel-screenshot
you have the possibility of drawing a box on your screen
and it takes a screenshot of that area
a bit like the rubberband select on the desktop
when you take a screenshot you have a minute or two to draw a box
Comment 1 Jonathan Blandford 2004-11-10 08:41:28 UTC
*** Bug 157719 has been marked as a duplicate of this bug. ***
Comment 2 Teppo Turtiainen 2005-07-15 17:32:28 UTC
*** Bug 310512 has been marked as a duplicate of this bug. ***
Comment 3 Madhan Raj M 2005-07-17 17:45:24 UTC
Created attachment 49327 [details] [review]
Patch against the CVS HEAD

Start gnome-screenshot, and click on the "Selection" button.
1. A small popup  window is created at the right bottom indicating the cursor
positon and the main dialog closes.
2. Selection has to be made using the cursor.
3. Pressing ESC, closes the dialog.
4. After making the selection, the normal screenshot dialog opens and the
selection can be saved.
Comment 4 Madhan Raj M 2005-07-20 17:34:45 UTC
Can anyone help me in drawing a selection rectangle, like Rubberbanding action,
as done on the desktop. I tried out, but couldn't implement that properly,.
Once that is done, then, this feature will be nice.
Comment 5 Teppo Turtiainen 2005-08-11 07:24:35 UTC
*** Bug 313174 has been marked as a duplicate of this bug. ***
Comment 6 Emmanuele Bassi (:ebassi) 2006-08-25 12:12:39 UTC
*** Bug 334063 has been marked as a duplicate of this bug. ***
Comment 7 Romulo Fernandes 2006-10-11 14:40:56 UTC
i believe that the screenshot dialog box should have a checkbox to select between full screen screenshot and box sized screenshot....If checked it lets you draw a box on the screenshot preview, and save it....What you guys think? i can work on that.
Comment 8 Tero Keinänen 2008-06-18 13:18:20 UTC
*** Bug 538918 has been marked as a duplicate of this bug. ***
Comment 9 Emmanuele Bassi (:ebassi) 2008-08-10 19:17:30 UTC
a simple way to do this would be modifying screenshot_get_pixbuf() inside screenshot-utils.c to take a GdkRectangle for the geometry of the area to grab. then take a screenshot of the full desktop and copy a sub-area of the resulting GdkPixbuf. it's not complicated, and in fact I had some code to select the area, but it's not finished.
Comment 10 Julien Raeis 2008-08-22 19:12:31 UTC
Great work :) This would be a very nice feature! A keyboard binding should also be created so you can take screenshots "on-the-fly" using something like "Shift  + PrintScreen + mouse-defined area" (or something more ergonomic).
Comment 11 Cosimo Cecchi 2008-11-08 13:54:55 UTC
*** Bug 559143 has been marked as a duplicate of this bug. ***
Comment 12 Cosimo Cecchi 2008-11-08 15:07:30 UTC
Marking the patch as "obsolete", as it does not apply anymore to gnome-screenshot trunk.
Comment 13 Vincent Untz 2009-02-24 06:40:41 UTC
Created attachment 129387 [details] [review]
Woohoo, new patch :-)

Here's a nice patch to implement this. It works fine here.

The only thing I'm not happy with is the code to draw a rectangle for the selection: I stole this from the GIMP, but it's still some X calls. I don't know if it's possible to do this any other way.

(well, in the composited case, we can use cairo on a semi-transparent window, there's even a FIXME for that)
Comment 14 Vincent Untz 2009-02-24 06:50:26 UTC
Oops. check_file_done() has some unused variables with the patch. Easy to fix :-)
Comment 15 Cosimo Cecchi 2009-02-24 09:24:08 UTC
Comment on attachment 129387 [details] [review]
Woohoo, new patch :-)

Vincent, thanks for the great patch.

>+select_area_filter (GdkXEvent *gdk_xevent,
>+                    GdkEvent  *event,
>+                    gpointer   user_data)
>+{
>+  select_area_filter_data *data = user_data;
>+  XEvent *xevent = (XEvent *) gdk_xevent;
>+
>+  switch (xevent->type)
>+    {
>+    case ButtonPress:

We've done some work in the previous cycle to avoid X calls as much as possible, replacing them with GDK where possible.
Can't you use the values within the GdkEvent here instead of poking at the XEvent?

>+gboolean
>+screenshot_select_area (int *px,
>+                        int *py,

>+  data.x_gc = XCreateGC (gdk_display,
>+                         GDK_WINDOW_XID (root),
>+                         GCFunction | GCPlaneMask | GCForeground | GCLineWidth |
>+                         GCLineStyle | GCCapStyle | GCJoinStyle |
>+                         GCGraphicsExposures | GCBackground | GCFillStyle |
>+                         GCClipXOrigin | GCClipYOrigin | GCClipMask |
>+                         GCSubwindowMode,
>+                         &gc_values);

Same here, I believe you can do the same with GdkGC, GdkGCValues and gdk_draw_rectangle().

The rest looks good to me. Can you please post an updated patch without direct X calls?
Comment 16 Vincent Untz 2009-02-24 14:21:22 UTC
(In reply to comment #15)
> (From update of attachment 129387 [details] [review] [edit])
> Vincent, thanks for the great patch.
> 
> >+select_area_filter (GdkXEvent *gdk_xevent,
> >+                    GdkEvent  *event,
> >+                    gpointer   user_data)
> >+{
> >+  select_area_filter_data *data = user_data;
> >+  XEvent *xevent = (XEvent *) gdk_xevent;
> >+
> >+  switch (xevent->type)
> >+    {
> >+    case ButtonPress:
> 
> We've done some work in the previous cycle to avoid X calls as much as
> possible, replacing them with GDK where possible.
> Can't you use the values within the GdkEvent here instead of poking at the
> XEvent?

From the gdk_window_add_filter() doc: "When a filter is called, event is unpopulated, except for event->window."

So, hrm, no, we can't :-)

> >+gboolean
> >+screenshot_select_area (int *px,
> >+                        int *py,
> 
> >+  data.x_gc = XCreateGC (gdk_display,
> >+                         GDK_WINDOW_XID (root),
> >+                         GCFunction | GCPlaneMask | GCForeground | GCLineWidth |
> >+                         GCLineStyle | GCCapStyle | GCJoinStyle |
> >+                         GCGraphicsExposures | GCBackground | GCFillStyle |
> >+                         GCClipXOrigin | GCClipYOrigin | GCClipMask |
> >+                         GCSubwindowMode,
> >+                         &gc_values);
> 
> Same here, I believe you can do the same with GdkGC, GdkGCValues and
> gdk_draw_rectangle().

Oh, sure. I wanted to do this with cairo, but I can't manage to directly draw on the root window with it :/ But gdk_draw_rectangle() is possible.
Comment 17 Vincent Untz 2009-02-24 14:23:11 UTC
Created attachment 129407 [details] [review]
Updated patch

Use gdk_draw_rectangle().

There's still XKeysymToKeycode(). Don't know how to get rid of this, and I suspect it's not easily possible.
Comment 18 Cosimo Cecchi 2009-02-24 16:18:01 UTC
I asked release-team a freeze break to get this feature in for 2.26. Otherwise, it's fine to commit it after branching.
Comment 19 Cosimo Cecchi 2009-02-27 13:41:06 UTC
release-team and gnome-i18n both gave their approvals, so I committed this to trunk.
Thanks again for the cool patch!

2009-02-27  Cosimo Cecchi  <cosimoc@gnome.org>

	* gnome-screenshot.c (target_toggled_cb),
	(create_screenshot_frame), (finish_prepare_screenshot),
	(async_existence_job_free), (check_file_done), (find_rectangle),
	(prepare_screenshot), (main):
	* screenshot-utils.c (select_area_button_press),
	(select_area_button_release), (select_area_motion_notify),
	(select_area_filter), (screenshot_select_area),
	(screenshot_get_pixbuf):
	* screenshot-utils.h: add support for taking a screenshot of an
	user-defined selection.
	Patch by Vincent Untz, bug #155061.
Comment 20 Nelson Benitez 2009-04-08 14:37:29 UTC
*** Bug 578349 has been marked as a duplicate of this bug. ***
Comment 21 Jean-Philippe Fleury 2009-04-17 20:22:02 UTC
Hi,

I've updated to Gnome 2.26.1, but I don't see any option for a selection. Is it fixed for 2.28?

Thanks.
Comment 22 Jean-Philippe Fleury 2009-04-28 18:25:26 UTC
(In reply to comment #21)
> I've updated to Gnome 2.26.1, but I don't see any option for a selection. Is it
> fixed for 2.28?

My mistake. It's in Gnome 2.26.1, but I was opening the software by the "Print Screen" key. We can see all options with this:

gnome-screenshot --interactive