scrot: add debian patchset

Closes: #9241 [via git-merge-pr]
This commit is contained in:
crater2150 2017-11-16 15:45:00 +01:00 committed by Jürgen Buchmüller
parent 9010fb6ccb
commit 2b9193d473
9 changed files with 440 additions and 1 deletions

View File

@ -0,0 +1,16 @@
Description: Character cleanup for UTF-8 compatibility.
Author: William Vera <billy@billy.com.mx>
Last-Update: 2008-08-15
Index: scrot.1
===================================================================
--- scrot.1
+++ scrot.1
@@ -87,7 +87,7 @@ prints a literal '$'
\\n prints a newline (ignored when used in the filename)
.fi
.SH EXAMPLE
-scrot '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/shots/'
+scrot '%Y\-%m\-%d_$wx$h.png' \-e 'mv $f ~/shots/'
.br
This would create a file called something like
2000-10-30_2560x1024.png and move it to your shots directory.

View File

@ -0,0 +1,25 @@
Description: A little fix for wrong words.
Author: William Vera <billy@billy.com.mx>
Last-Update: 2008-08-15
Index: src/options.c
===================================================================
--- src/options.c
+++ src/options.c
@@ -229,7 +229,7 @@ show_usage(void)
" low quality means high compression.\n"
" -m, --multidisp For multiple heads, grab shot from each\n"
" and join them together.\n"
- " -s, --select interactively choose a window or rectnagle\n"
+ " -s, --select interactively choose a window or rectangle\n"
" with the mouse\n"
" -t, --thumb NUM generate thumbnail too. NUM is the percentage\n"
" of the original size for the thumbnail to be,\n"
@@ -238,7 +238,7 @@ show_usage(void)
" Both the --exec and filename parameters can take format specifiers\n"
" that are expanded by " PACKAGE " when encountered.\n"
" There are two types of format specifier. Characters preceded by a '%%'\n"
- " are interpretted by strftime(2). See man strftime for examples.\n"
+ " are interpreted by strftime(2). See man strftime for examples.\n"
" These options may be used to refer to the current date and time.\n"
" The second kind are internal to " PACKAGE
" and are prefixed by '$'\n"

View File

@ -0,0 +1,13 @@
Description: Change the description on manpage.
Author: William Vera <billy@billy.com.mx>
Last-Update: 2009-05-13
--- scrot.1
+++ scrot.1
@@ -1,6 +1,6 @@
.TH scrot 1 "Oct 26, 2000"
.SH NAME
-scrot - Screen capture using imlib2
+scrot - capture a screenshot using imlib2
.SH SYNOPSIS
scrot [options] [file]
.SH DESCRIPTION

View File

@ -0,0 +1,242 @@
Description: src/options.c (scrot_parse_option_array): add --focused option.
src/main.c (scrot_get_geometry, scrot_nice_clip): new functions
src/main.c (scrot_grab_focused): new function to grab currently
Author: James Cameron <quozl@us.netrek.org>
Last-Update: 2009-05-19
Index: src/options.h
===================================================================
--- src/options.h
+++ src/options.h
@@ -32,6 +32,7 @@ struct __scrotoptions
int delay;
int countdown;
int select;
+ int focused;
int quality;
int border;
int multidisp;
Index: src/options.c
===================================================================
--- src/options.c
+++ src/options.c
@@ -44,13 +44,15 @@ init_parse_options(int argc, char **argv
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 @@ scrot_parse_option_array(int argc, char
case 's':
opt.select = 1;
break;
+ case 'u':
+ opt.focused = 1;
+ break;
case '+':
opt.debug_level = atoi(optarg);
break;
@@ -231,6 +236,7 @@ show_usage(void)
" 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"
Index: src/scrot.h
===================================================================
--- src/scrot.h
+++ src/scrot.h
@@ -72,7 +72,10 @@ void scrot_exec_app(Imlib_Image image, s
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,
Index: src/main.c
===================================================================
--- src/main.c
+++ src/main.c
@@ -48,7 +48,9 @@ main(int argc,
}
- 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 @@ scrot_exec_app(Imlib_Image image, struct
}
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 @@ scrot_sel_and_grab_image(void)
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);
- }
-
- /* clip rectangle nicely */
- if (rx < 0) {
- rw += rx;
- rx = 0;
+ if (!scrot_get_geometry(target, &rx, &ry, &rw, &rh)) return NULL;
}
- 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 @@ scrot_sel_and_grab_image(void)
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,

View File

@ -0,0 +1,17 @@
Description: Add a new option in the man page (focused option).
Author: William Vera <billy@billy.com.mx>
Last-Update: 2009-05-19
Index: scrot.1
===================================================================
--- scrot.1
+++ scrot.1
@@ -43,6 +43,9 @@ For multiple heads, grab shot from each
.B -s, --select
Interactively select a window or rectangle with the mouse.
.TP 5
+.B -u, --focused
+Use the currently focused window.
+.TP 5
.B -t, --thumb NUM
generate thumbnail too. NUM is the percentage of the original size for the
thumbnail to be.

View File

@ -0,0 +1,16 @@
Description: Improve spacing in manual page.
Author: William Vera <billy@billy.com.mx>
Last-Update: 2009-10-25
Index: scrot.1
===================================================================
--- scrot.1
+++ scrot.1
@@ -61,7 +61,7 @@ are interpretted by strftime(2). See man
These options may be used to refer to the current date and time.
The second kind are internal to scrot and are prefixed by '$'
The following specifiers are recognised:
-.br
+.PP
.B $f
image path/filename (ignored when used in the filename)
.br

View File

@ -0,0 +1,20 @@
Description: Prevent arbitrary long file names
Author: George Danchev <danchev@spnet.net>
Last-Update: 2009-10-25
Index: src/options.c
===================================================================
--- src/options.c
+++ src/options.c
@@ -124,6 +124,12 @@ scrot_parse_option_array(int argc, char
if (!opt.output_file)
{
opt.output_file = argv[optind++];
+
+ if ( strlen(opt.output_file) > 256 ) {
+ printf("output filename too long.\n");
+ exit(EXIT_FAILURE);
+ }
+
if (opt.thumb)
opt.thumb_file = name_thumbnail(opt.output_file);
}

View File

@ -0,0 +1,90 @@
Description: Fix missing option for beep prevention.
Author: Ibragimov Rinat <ibragimovrinat@mail.ru>
Last-Update: 2010-06-30
Index: scrot.1
===================================================================
--- scrot.1
+++ scrot.1
@@ -49,6 +49,9 @@ Use the currently focused window.
.B -t, --thumb NUM
generate thumbnail too. NUM is the percentage of the original size for the
thumbnail to be.
+.TP 5
+.B -z, --silent
+prevent beeping.
.SH SPECIAL STRINGS
Both the
.B --exec
Index: src/main.c
===================================================================
--- src/main.c
+++ src/main.c
@@ -154,7 +154,7 @@ scrot_grab_shot(void)
{
Imlib_Image im;
- XBell(disp, 0);
+ if (! opt.silent) XBell(disp, 0);
im =
gib_imlib_create_image_from_drawable(root, 0, 0, 0, scr->width,
scr->height, 1);
@@ -336,7 +336,7 @@ scrot_sel_and_grab_image(void)
}
scrot_nice_clip(&rx, &ry, &rw, &rh);
- XBell(disp, 0);
+ if (! opt.silent) XBell(disp, 0);
im = gib_imlib_create_image_from_drawable(root, 0, rx, ry, rw, rh, 1);
}
return im;
Index: src/options.c
===================================================================
--- src/options.c
+++ src/options.c
@@ -44,7 +44,7 @@ init_parse_options(int argc, char **argv
static void
scrot_parse_option_array(int argc, char **argv)
{
- static char stropts[] = "bcd:e:hmq:st:uv+:";
+ static char stropts[] = "bcd:e:hmq:st:uv+:z";
static struct option lopts[] = {
/* actions */
{"help", 0, 0, 'h'}, /* okay */
@@ -55,6 +55,7 @@ scrot_parse_option_array(int argc, char
{"focussed", 0, 0, 'u'}, /* macquarie dictionary has both spellings */
{"border", 0, 0, 'b'},
{"multidisp", 0, 0, 'm'},
+ {"silent", 0, 0, 'z'},
/* toggles */
{"thumb", 1, 0, 't'},
{"delay", 1, 0, 'd'},
@@ -109,6 +110,9 @@ scrot_parse_option_array(int argc, char
case 't':
options_parse_thumbnail(optarg);
break;
+ case 'z':
+ opt.silent = 1;
+ break;
default:
break;
}
@@ -246,6 +250,7 @@ show_usage(void)
" -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"
+ " -z, --silent Prevent beeping\n"
"\n" " SPECIAL STRINGS\n"
" Both the --exec and filename parameters can take format specifiers\n"
" that are expanded by " PACKAGE " when encountered.\n"
Index: src/options.h
===================================================================
--- src/options.h
+++ src/options.h
@@ -35,6 +35,7 @@ struct __scrotoptions
int focused;
int quality;
int border;
+ int silent;
int multidisp;
int thumb;
int thumb_width;

View File

@ -1,7 +1,7 @@
# Template file for 'scrot' # Template file for 'scrot'
pkgname=scrot pkgname=scrot
version=0.8 version=0.8
revision=5 revision=6
build_style=gnu-configure build_style=gnu-configure
make_install_args="docsdir=/usr/share/doc/scrot" make_install_args="docsdir=/usr/share/doc/scrot"
makedepends="libX11-devel giblib-devel imlib2-devel" makedepends="libX11-devel giblib-devel imlib2-devel"