Your message dated Tue, 19 May 2009 18:02:18 +0000
with message-id <[email protected]>
and subject line Bug#245266: fixed in scrot 0.8-10
has caused the Debian Bug report #245266,
regarding scrot: automatically choose focused window
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
245266: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=245266
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: scrot
Version: 0.8-6
Severity: wishlist

Please find attached a patch to add a --focused option which causes
scrot to take a snapshot of the window with the active input focus.

(I needed this while trying to use the xautomation package.  An xwd pipe
conversion to png was considerably slower than scrot, yet scrot could
not be given a window id or name, requiring the use of xte to simulate a
click, which was unreliable due to timing.  xte could fire the XTest
click before scrot had grabbed the event stream.)

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.2-mppe
Locale: LANG=C, LC_CTYPE=C

Versions of packages scrot depends on:
ii  giblib1                     1.2.3-3      wrapper library for imlib2, and ot
ii  libc6                       2.3.2.ds1-11 GNU C Library: Shared libraries an
ii  libfreetype6                2.1.7-2      FreeType 2 font engine, shared lib
ii  libimlib2                   1.1.0-12     Powerful image loading and renderi
ii  libx11-6                    4.3.0-7      X Window System protocol client li
ii  libxext6                    4.3.0-7      X Window System miscellaneous exte
ii  xlibs                       4.3.0-7      X Window System client libraries m
ii  zlib1g                      1:1.2.1-5    compression library - runtime

-- no debconf information

-- 
James Cameron
HP Software Security Response Team
Asia Pacific
--- ChangeLog.orig      2003-06-23 22:05:45.000000000 +1000
+++ ChangeLog   2004-04-21 22:00:14.000000000 +1000
@@ -1,3 +1,13 @@
+Wed Apr 21 21:53:26 2004  James Cameron  <[email protected]>
+
+       * src/options.c (scrot_parse_option_array): add --focused option.
+
+       * src/main.c (scrot_get_geometry, scrot_nice_clip): new functions
+       for common code used by both selected and focused screenshot.
+
+       * src/main.c (scrot_grab_focused): new function to grab currently
+       focused window after specified delay.
+
 Wed Mar 12 13:20:11 GMT 2003  Tom Gilbert <[email protected]>
 
   * Patch from Claes Nasten <[email protected]>
diff -u -r src.orig/options.h src/options.h
--- src.orig/options.h  2004-04-21 21:15:24.000000000 +1000
+++ src/options.h       2004-04-21 22:00:47.000000000 +1000
@@ -32,6 +32,7 @@
    int delay;
    int countdown;
    int select;
+   int focused;
    int quality;
    int border;
    int multidisp;
diff -u -r src.orig/options.c src/options.c
--- src.orig/options.c  2004-04-21 21:15:24.000000000 +1000
+++ src/options.c       2004-04-21 22:00:32.000000000 +1000
@@ -44,13 +44,15 @@
 static void
 scrot_parse_option_array(int argc, char **argv)
 {
-   static char stropts[] = "bcd:e:hmq:st:v+:";
+   static char stropts[] = "bcd:e:hmq:st:uv+:";
    static struct option lopts[] = {
       /* actions */
       {"help", 0, 0, 'h'},                  /* okay */
       {"version", 0, 0, 'v'},               /* okay */
       {"count", 0, 0, 'c'},
       {"select", 0, 0, 's'},
+      {"focused", 0, 0, 'u'},
+      {"focussed", 0, 0, 'u'}, /* macquarie dictionary has both spellings */
       {"border", 0, 0, 'b'},
       {"multidisp", 0, 0, 'm'},
       /* toggles */
@@ -95,6 +97,9 @@
         case 's':
            opt.select = 1;
            break;
+        case 'u':
+           opt.focused = 1;
+           break;
         case '+':
            opt.debug_level = atoi(optarg);
            break;
@@ -231,6 +236,7 @@
            "                            and join them together.\n"
            "  -s, --select              interactively choose a window or 
rectangle\n"
            "                            with the mouse\n"
+           "  -u, --focused             use the currently focused window\n"
            "  -t, --thumb NUM           generate thumbnail too. NUM is the 
percentage\n"
            "                            of the original size for the thumbnail 
to be,\n"
            "                            or the geometry in percent, e.g. 50x60 
or 80x20.\n"
diff -u -r src.orig/scrot.h src/scrot.h
--- src.orig/scrot.h    2004-04-21 21:15:24.000000000 +1000
+++ src/scrot.h 2004-04-21 22:00:42.000000000 +1000
@@ -72,7 +72,10 @@
                     char *filename_im, char *filename_thumb);
 void scrot_do_delay(void);
 Imlib_Image scrot_sel_and_grab_image(void);
+Imlib_Image scrot_grab_focused(void);
 void scrot_sel_area(int *x, int *y, int *w, int *h);
+void scrot_nice_clip(int *rx, int *ry, int *rw, int *rh);
+int scrot_get_geometry(Window target, int *rx, int *ry, int *rw, int *rh);
 Window scrot_get_window(Display *display,Window window,int x,int y);
 Window scrot_get_client_window(Display * display, Window target);
 Window scrot_find_window_by_property(Display * display, const Window window,
diff -u -r src.orig/main.c src/main.c
--- src.orig/main.c     2004-04-21 21:15:24.000000000 +1000
+++ src/main.c  2004-04-21 22:01:27.000000000 +1000
@@ -48,7 +48,9 @@
   }
 
 
-  if (opt.select)
+  if (opt.focused)
+    image = scrot_grab_focused();
+  else if (opt.select)
     image = scrot_sel_and_grab_image();
   else {
     scrot_do_delay();
@@ -171,6 +173,22 @@
 }
 
 Imlib_Image
+scrot_grab_focused(void)
+{
+  Imlib_Image im = NULL;
+  int rx = 0, ry = 0, rw = 0, rh = 0;
+  Window target = None;
+  int ignored;
+
+  scrot_do_delay();
+  XGetInputFocus(disp, &target, &ignored);
+  if (!scrot_get_geometry(target, &rx, &ry, &rw, &rh)) return NULL;
+  scrot_nice_clip(&rx, &ry, &rw, &rh);
+  im = gib_imlib_create_image_from_drawable(root, 0, rx, ry, rw, rh, 1);
+  return im;
+}
+
+Imlib_Image
 scrot_sel_and_grab_image(void)
 {
   Imlib_Image im = NULL;
@@ -313,57 +331,10 @@
         rh = 0 - rh;
       }
     } else {
-      Window child;
-      XWindowAttributes attr;
-      int stat;
-
       /* else it's a window click */
-      /* get geometry of window and use that */
-      /* get windowmanager frame of window */
-      if (target != root) {
-        unsigned int d, x;
-        int status;
-
-        status = XGetGeometry(disp, target, &root, &x, &x, &d, &d, &d, &d);
-        if (status != 0) {
-          Window rt, *children, parent;
-
-          for (;;) {
-            /* Find window manager frame. */
-            status = XQueryTree(disp, target, &rt, &parent, &children, &d);
-            if (status && (children != None))
-              XFree((char *) children);
-            if (!status || (parent == None) || (parent == rt))
-              break;
-            target = parent;
-          }
-          /* Get client window. */
-          if (!opt.border)
-            target = scrot_get_client_window(disp, target);
-          XRaiseWindow(disp, target);
-        }
-      }
-      stat = XGetWindowAttributes(disp, target, &attr);
-      if ((stat == False) || (attr.map_state != IsViewable))
-        return NULL;
-      rw = attr.width;
-      rh = attr.height;
-      XTranslateCoordinates(disp, target, root, 0, 0, &rx, &ry, &child);
+      if (!scrot_get_geometry(target, &rx, &ry, &rw, &rh)) return NULL;
     }
-
-    /* clip rectangle nicely */
-    if (rx < 0) {
-      rw += rx;
-      rx = 0;
-    }
-    if (ry < 0) {
-      rh += ry;
-      ry = 0;
-    }
-    if ((rx + rw) > scr->width)
-      rw = scr->width - rx;
-    if ((ry + rh) > scr->height)
-      rh = scr->height - ry;
+    scrot_nice_clip(&rx, &ry, &rw, &rh);
 
     XBell(disp, 0);
     im = gib_imlib_create_image_from_drawable(root, 0, rx, ry, rw, rh, 1);
@@ -371,6 +342,72 @@
   return im;
 }
 
+/* clip rectangle nicely */
+void
+scrot_nice_clip(int *rx, 
+               int *ry, 
+               int *rw, 
+               int *rh)
+{
+  if (*rx < 0) {
+    *rw += *rx;
+    *rx = 0;
+  }
+  if (*ry < 0) {
+    *rh += *ry;
+    *ry = 0;
+  }
+  if ((*rx + *rw) > scr->width)
+    *rw = scr->width - *rx;
+  if ((*ry + *rh) > scr->height)
+    *rh = scr->height - *ry;
+}
+
+/* get geometry of window and use that */
+int
+scrot_get_geometry(Window target,
+                  int *rx, 
+                  int *ry, 
+                  int *rw, 
+                  int *rh)
+{
+  Window child;
+  XWindowAttributes attr;
+  int stat;
+
+  /* get windowmanager frame of window */
+  if (target != root) {
+    unsigned int d, x;
+    int status;
+    
+    status = XGetGeometry(disp, target, &root, &x, &x, &d, &d, &d, &d);
+    if (status != 0) {
+      Window rt, *children, parent;
+      
+      for (;;) {
+       /* Find window manager frame. */
+       status = XQueryTree(disp, target, &rt, &parent, &children, &d);
+       if (status && (children != None))
+         XFree((char *) children);
+       if (!status || (parent == None) || (parent == rt))
+         break;
+       target = parent;
+      }
+      /* Get client window. */
+      if (!opt.border)
+       target = scrot_get_client_window(disp, target);
+      XRaiseWindow(disp, target);
+    }
+  }
+  stat = XGetWindowAttributes(disp, target, &attr);
+  if ((stat == False) || (attr.map_state != IsViewable))
+    return 0;
+  *rw = attr.width;
+  *rh = attr.height;
+  XTranslateCoordinates(disp, target, root, 0, 0, rx, ry, &child);
+  return 1;
+}
+
 Window
 scrot_get_window(Display * display,
                  Window window,

--- End Message ---
--- Begin Message ---
Source: scrot
Source-Version: 0.8-10

We believe that the bug you reported is fixed in the latest version of
scrot, which is due to be installed in the Debian FTP archive:

scrot_0.8-10.diff.gz
  to pool/main/s/scrot/scrot_0.8-10.diff.gz
scrot_0.8-10.dsc
  to pool/main/s/scrot/scrot_0.8-10.dsc
scrot_0.8-10_amd64.deb
  to pool/main/s/scrot/scrot_0.8-10_amd64.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
William Vera <[email protected]> (supplier of updated scrot package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Tue, 19 May 2009 09:27:27 -0500
Source: scrot
Binary: scrot
Architecture: source amd64
Version: 0.8-10
Distribution: unstable
Urgency: low
Maintainer: William Vera <[email protected]>
Changed-By: William Vera <[email protected]>
Description: 
 scrot      - command line screen capture utility
Closes: 245266
Changes: 
 scrot (0.8-10) unstable; urgency=low
 .
   * Added a patch to automatically choose focused window (Closes: #245266).
   * New patch to add this function at he manpage.
Checksums-Sha1: 
 39c94363b7ce380316242ba8e85f0bacbea6c9c9 1020 scrot_0.8-10.dsc
 73d5a96c49f21f8d957c503041b5da180d317bc3 6741 scrot_0.8-10.diff.gz
 32a8b55e59b435a0bfa1b296bd61521c28e37674 18790 scrot_0.8-10_amd64.deb
Checksums-Sha256: 
 7e723e95bc245c002bdc346b3ab1f4b1e772b54cfcf554911f0f82a6bbee5cb6 1020 
scrot_0.8-10.dsc
 27085274ab339d546766cd018ea1843d8d37d0e721c34e094e01c8a4a0ad0d4c 6741 
scrot_0.8-10.diff.gz
 abad83269135f32430b15f855cf243fd2b20a538985a556941e1b0b2e52415b2 18790 
scrot_0.8-10_amd64.deb
Files: 
 63515b37483fbd8ac17b48c23a66034e 1020 graphics optional scrot_0.8-10.dsc
 2f9e48371c61d7ee0719182e1acc0419 6741 graphics optional scrot_0.8-10.diff.gz
 eb7edb1be87829779b84f83751e55358 18790 graphics optional scrot_0.8-10_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkoS8McACgkQ2XA5inpabMd1ZACeKUSUhX/V9jfMqU+BgYtnBPO0
w1UAn1FNOboIvZMaC893VVJ89iFw8lob
=wiwJ
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to