wok-4.x view scrot/stuff/scrot.patch @ rev 12354
scrot: up 0.8-12 (with patches)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Wed Nov 07 02:08:04 2012 +0000 (2012-11-07) |
parents | |
children |
line source
1 # This patch was created manually from patches found here:
2 # http://scrot.sourcearchive.com/downloads/0.8-12/scrot_0.8-12.debian.tar.gz
4 ## 01_manpagefix.dpatch by William Vera <billy@billy.com.mx>
5 ## DP: Character cleanup for UTF-8 compatibility.
7 --- scrot-0.8-orig/scrot.1
8 +++ scrot-0.8/scrot.1
9 @@ -87,7 +87,7 @@
10 \\n prints a newline (ignored when used in the filename)
11 .fi
12 .SH EXAMPLE
13 -scrot '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/shots/'
14 +scrot '%Y\-%m\-%d_$wx$h.png' \-e 'mv $f ~/shots/'
15 .br
16 This would create a file called something like
17 2000-10-30_2560x1024.png and move it to your shots directory.
19 ## 02_options.c.dpatch by William Vera <billy@billy.com.mx>
20 ## DP: A little fix for wrong words.
22 --- scrot-0.8-orig/src/options.c
23 +++ scrot-0.8/src/options.c
24 @@ -229,7 +229,7 @@
25 " low quality means high compression.\n"
26 " -m, --multidisp For multiple heads, grab shot from each\n"
27 " and join them together.\n"
28 - " -s, --select interactively choose a window or rectnagle\n"
29 + " -s, --select interactively choose a window or rectangle\n"
30 " with the mouse\n"
31 " -t, --thumb NUM generate thumbnail too. NUM is the percentage\n"
32 " of the original size for the thumbnail to be,\n"
33 @@ -238,7 +238,7 @@
34 " Both the --exec and filename parameters can take format specifiers\n"
35 " that are expanded by " PACKAGE " when encountered.\n"
36 " There are two types of format specifier. Characters preceded by a '%%'\n"
37 - " are interpretted by strftime(2). See man strftime for examples.\n"
38 + " are interpreted by strftime(2). See man strftime for examples.\n"
39 " These options may be used to refer to the current date and time.\n"
40 " The second kind are internal to " PACKAGE
41 " and are prefixed by '$'\n"
43 ## 003_descmanpage.dpatch by William Vera <billy@billy.com.mx>
44 ## DP: Change the description on manpage.
46 --- scrot-0.8-orig/scrot.1
47 +++ scrot-0.8/scrot.1
48 @@ -1,6 +1,6 @@
49 .TH scrot 1 "Oct 26, 2000"
50 .SH NAME
51 -scrot - Screen capture using imlib2
52 +scrot - capture a screenshot using imlib2
53 .SH SYNOPSIS
54 scrot [options] [file]
55 .SH DESCRIPTION
57 ## 04-focused.dpatch by James Cameron <quozl@us.netrek.org>
58 ## DP: src/options.c (scrot_parse_option_array): add --focused option.
59 ## DP: src/main.c (scrot_get_geometry, scrot_nice_clip): new functions
60 ## for common code used by both selected and focused screenshot.
61 ## DP: src/main.c (scrot_grab_focused): new function to grab currently
62 ## focused window after specified delay.
64 --- scrot-0.8-orig/src/options.h
65 +++ scrot-0.8/src/options.h
66 @@ -32,6 +32,7 @@
67 int delay;
68 int countdown;
69 int select;
70 + int focused;
71 int quality;
72 int border;
73 int multidisp;
74 --- scrot-0.8-orig/src/options.c
75 +++ scrot-0.8/src/options.c
76 @@ -44,13 +44,15 @@
77 static void
78 scrot_parse_option_array(int argc, char **argv)
79 {
80 - static char stropts[] = "bcd:e:hmq:st:v+:";
81 + static char stropts[] = "bcd:e:hmq:st:uv+:";
82 static struct option lopts[] = {
83 /* actions */
84 {"help", 0, 0, 'h'}, /* okay */
85 {"version", 0, 0, 'v'}, /* okay */
86 {"count", 0, 0, 'c'},
87 {"select", 0, 0, 's'},
88 + {"focused", 0, 0, 'u'},
89 + {"focussed", 0, 0, 'u'}, /* macquarie dictionary has both spellings */
90 {"border", 0, 0, 'b'},
91 {"multidisp", 0, 0, 'm'},
92 /* toggles */
93 @@ -95,6 +97,9 @@
94 case 's':
95 opt.select = 1;
96 break;
97 + case 'u':
98 + opt.focused = 1;
99 + break;
100 case '+':
101 opt.debug_level = atoi(optarg);
102 break;
103 @@ -231,6 +236,7 @@
104 " and join them together.\n"
105 " -s, --select interactively choose a window or rectangle\n"
106 " with the mouse\n"
107 + " -u, --focused use the currently focused window\n"
108 " -t, --thumb NUM generate thumbnail too. NUM is the percentage\n"
109 " of the original size for the thumbnail to be,\n"
110 " or the geometry in percent, e.g. 50x60 or 80x20.\n"
111 --- scrot-0.8-orig/src/scrot.h
112 +++ scrot-0.8/src/scrot.h
113 @@ -72,7 +72,10 @@
114 char *filename_im, char *filename_thumb);
115 void scrot_do_delay(void);
116 Imlib_Image scrot_sel_and_grab_image(void);
117 +Imlib_Image scrot_grab_focused(void);
118 void scrot_sel_area(int *x, int *y, int *w, int *h);
119 +void scrot_nice_clip(int *rx, int *ry, int *rw, int *rh);
120 +int scrot_get_geometry(Window target, int *rx, int *ry, int *rw, int *rh);
121 Window scrot_get_window(Display *display,Window window,int x,int y);
122 Window scrot_get_client_window(Display * display, Window target);
123 Window scrot_find_window_by_property(Display * display, const Window window,
124 --- scrot-0.8-orig/src/main.c
125 +++ scrot-0.8/src/main.c
126 @@ -48,7 +48,9 @@
127 }
130 - if (opt.select)
131 + if (opt.focused)
132 + image = scrot_grab_focused();
133 + else if (opt.select)
134 image = scrot_sel_and_grab_image();
135 else {
136 scrot_do_delay();
137 @@ -171,6 +173,22 @@
138 }
140 Imlib_Image
141 +scrot_grab_focused(void)
142 +{
143 + Imlib_Image im = NULL;
144 + int rx = 0, ry = 0, rw = 0, rh = 0;
145 + Window target = None;
146 + int ignored;
147 +
148 + scrot_do_delay();
149 + XGetInputFocus(disp, &target, &ignored);
150 + if (!scrot_get_geometry(target, &rx, &ry, &rw, &rh)) return NULL;
151 + scrot_nice_clip(&rx, &ry, &rw, &rh);
152 + im = gib_imlib_create_image_from_drawable(root, 0, rx, ry, rw, rh, 1);
153 + return im;
154 +}
155 +
156 +Imlib_Image
157 scrot_sel_and_grab_image(void)
158 {
159 Imlib_Image im = NULL;
160 @@ -313,57 +331,10 @@
161 rh = 0 - rh;
162 }
163 } else {
164 - Window child;
165 - XWindowAttributes attr;
166 - int stat;
167 -
168 /* else it's a window click */
169 - /* get geometry of window and use that */
170 - /* get windowmanager frame of window */
171 - if (target != root) {
172 - unsigned int d, x;
173 - int status;
174 -
175 - status = XGetGeometry(disp, target, &root, &x, &x, &d, &d, &d, &d);
176 - if (status != 0) {
177 - Window rt, *children, parent;
178 -
179 - for (;;) {
180 - /* Find window manager frame. */
181 - status = XQueryTree(disp, target, &rt, &parent, &children, &d);
182 - if (status && (children != None))
183 - XFree((char *) children);
184 - if (!status || (parent == None) || (parent == rt))
185 - break;
186 - target = parent;
187 - }
188 - /* Get client window. */
189 - if (!opt.border)
190 - target = scrot_get_client_window(disp, target);
191 - XRaiseWindow(disp, target);
192 - }
193 - }
194 - stat = XGetWindowAttributes(disp, target, &attr);
195 - if ((stat == False) || (attr.map_state != IsViewable))
196 - return NULL;
197 - rw = attr.width;
198 - rh = attr.height;
199 - XTranslateCoordinates(disp, target, root, 0, 0, &rx, &ry, &child);
200 + if (!scrot_get_geometry(target, &rx, &ry, &rw, &rh)) return NULL;
201 }
202 -
203 - /* clip rectangle nicely */
204 - if (rx < 0) {
205 - rw += rx;
206 - rx = 0;
207 - }
208 - if (ry < 0) {
209 - rh += ry;
210 - ry = 0;
211 - }
212 - if ((rx + rw) > scr->width)
213 - rw = scr->width - rx;
214 - if ((ry + rh) > scr->height)
215 - rh = scr->height - ry;
216 + scrot_nice_clip(&rx, &ry, &rw, &rh);
218 XBell(disp, 0);
219 im = gib_imlib_create_image_from_drawable(root, 0, rx, ry, rw, rh, 1);
220 @@ -371,6 +342,72 @@
221 return im;
222 }
224 +/* clip rectangle nicely */
225 +void
226 +scrot_nice_clip(int *rx,
227 + int *ry,
228 + int *rw,
229 + int *rh)
230 +{
231 + if (*rx < 0) {
232 + *rw += *rx;
233 + *rx = 0;
234 + }
235 + if (*ry < 0) {
236 + *rh += *ry;
237 + *ry = 0;
238 + }
239 + if ((*rx + *rw) > scr->width)
240 + *rw = scr->width - *rx;
241 + if ((*ry + *rh) > scr->height)
242 + *rh = scr->height - *ry;
243 +}
244 +
245 +/* get geometry of window and use that */
246 +int
247 +scrot_get_geometry(Window target,
248 + int *rx,
249 + int *ry,
250 + int *rw,
251 + int *rh)
252 +{
253 + Window child;
254 + XWindowAttributes attr;
255 + int stat;
256 +
257 + /* get windowmanager frame of window */
258 + if (target != root) {
259 + unsigned int d, x;
260 + int status;
261 +
262 + status = XGetGeometry(disp, target, &root, &x, &x, &d, &d, &d, &d);
263 + if (status != 0) {
264 + Window rt, *children, parent;
265 +
266 + for (;;) {
267 + /* Find window manager frame. */
268 + status = XQueryTree(disp, target, &rt, &parent, &children, &d);
269 + if (status && (children != None))
270 + XFree((char *) children);
271 + if (!status || (parent == None) || (parent == rt))
272 + break;
273 + target = parent;
274 + }
275 + /* Get client window. */
276 + if (!opt.border)
277 + target = scrot_get_client_window(disp, target);
278 + XRaiseWindow(disp, target);
279 + }
280 + }
281 + stat = XGetWindowAttributes(disp, target, &attr);
282 + if ((stat == False) || (attr.map_state != IsViewable))
283 + return 0;
284 + *rw = attr.width;
285 + *rh = attr.height;
286 + XTranslateCoordinates(disp, target, root, 0, 0, rx, ry, &child);
287 + return 1;
288 +}
289 +
290 Window
291 scrot_get_window(Display * display,
292 Window window,
294 ## 05-addfocusedmanpage.dpatch by William Vera <billy@billy.com.mx>
295 ## DP: Add a new option in the man page (focused option).
297 --- scrot-0.8-orig/scrot.1
298 +++ scrot-0.8/scrot.1
299 @@ -43,6 +43,9 @@
300 .B -s, --select
301 Interactively select a window or rectangle with the mouse.
302 .TP 5
303 +.B -u, --focused
304 +Use the currently focused window.
305 +.TP 5
306 .B -t, --thumb NUM
307 generate thumbnail too. NUM is the percentage of the original size for the
308 thumbnail to be.
310 ## 06_manpagespace.dpatch by William Vera <billy@billy.com.mx>
311 ## DP: Improve spacing in manual page.
313 --- scrot-0.8-orig/scrot.1
314 +++ scrot-0.8/scrot.1
315 @@ -58,7 +58,7 @@
316 These options may be used to refer to the current date and time.
317 The second kind are internal to scrot and are prefixed by '$'
318 The following specifiers are recognised:
319 -.br
320 +.PP
321 .B $f
322 image path/filename (ignored when used in the filename)
323 .br
325 ## 07_fix-formatstring.dpatch by George Danchev <danchev@spnet.net>
326 ## DP: Prevent arbitrary long file names
328 --- scrot-0.8-orig/src/options.c
329 +++ scrot-0.8/src/options.c
330 @@ -124,6 +124,12 @@
331 if (!opt.output_file)
332 {
333 opt.output_file = argv[optind++];
334 +
335 + if ( strlen(opt.output_file) > 256 ) {
336 + printf("output filename too long.\n");
337 + exit(EXIT_FAILURE);
338 + }
339 +
340 if (opt.thumb)
341 opt.thumb_file = name_thumbnail(opt.output_file);
342 }
344 ## fix-beeping.dpatch by Ibragimov Rinat <ibragimovrinat@mail.ru>
345 ## DP: Fix missing option for beep prevention.
347 --- scrot-0.8-orig/scrot.1
348 +++ scrot-0.8/scrot.1
349 @@ -49,6 +49,9 @@
350 .B -t, --thumb NUM
351 generate thumbnail too. NUM is the percentage of the original size for the
352 thumbnail to be.
353 +.TP 5
354 +.B -z, --silent
355 +prevent beeping.
356 .SH SPECIAL STRINGS
357 Both the
358 .B --exec
359 --- scrot-0.8-orig/src/main.c
360 +++ scrot-0.8/src/main.c
361 @@ -154,7 +154,7 @@
362 {
363 Imlib_Image im;
365 - XBell(disp, 0);
366 + if (! opt.silent) XBell(disp, 0);
367 im =
368 gib_imlib_create_image_from_drawable(root, 0, 0, 0, scr->width,
369 scr->height, 1);
370 @@ -336,7 +336,7 @@
371 }
372 scrot_nice_clip(&rx, &ry, &rw, &rh);
374 - XBell(disp, 0);
375 + if (! opt.silent) XBell(disp, 0);
376 im = gib_imlib_create_image_from_drawable(root, 0, rx, ry, rw, rh, 1);
377 }
378 return im;
379 --- scrot-0.8-orig/src/options.c
380 +++ scrot-0.8/src/options.c
381 @@ -44,7 +44,7 @@
382 static void
383 scrot_parse_option_array(int argc, char **argv)
384 {
385 - static char stropts[] = "bcd:e:hmq:st:uv+:";
386 + static char stropts[] = "bcd:e:hmq:st:uv+:z";
387 static struct option lopts[] = {
388 /* actions */
389 {"help", 0, 0, 'h'}, /* okay */
390 @@ -55,6 +55,7 @@
391 {"focussed", 0, 0, 'u'}, /* macquarie dictionary has both spellings */
392 {"border", 0, 0, 'b'},
393 {"multidisp", 0, 0, 'm'},
394 + {"silent", 0, 0, 'z'},
395 /* toggles */
396 {"thumb", 1, 0, 't'},
397 {"delay", 1, 0, 'd'},
398 @@ -109,6 +110,9 @@
399 case 't':
400 options_parse_thumbnail(optarg);
401 break;
402 + case 'z':
403 + opt.silent = 1;
404 + break;
405 default:
406 break;
407 }
408 @@ -246,6 +250,7 @@
409 " -t, --thumb NUM generate thumbnail too. NUM is the percentage\n"
410 " of the original size for the thumbnail to be,\n"
411 " or the geometry in percent, e.g. 50x60 or 80x20.\n"
412 + " -z, --silent Prevent beeping\n"
413 "\n" " SPECIAL STRINGS\n"
414 " Both the --exec and filename parameters can take format specifiers\n"
415 " that are expanded by " PACKAGE " when encountered.\n"
416 --- scrot-0.8-orig/src/options.h
417 +++ scrot-0.8/src/options.h
418 @@ -35,6 +35,7 @@
419 int focused;
420 int quality;
421 int border;
422 + int silent;
423 int multidisp;
424 int thumb;
425 int thumb_width;
427 ## 09_fix-minusign.dpatch by William Vera <billy@billy.com.mx>
428 ## DP: Fix a hyphen-used-as-minus-sign in a manpage.
430 --- scrot-0.8-orig/scrot.1
431 +++ scrot-0.8/scrot.1
432 @@ -93,7 +93,7 @@
433 \\n prints a newline (ignored when used in the filename)
434 .fi
435 .SH EXAMPLE
436 -scrot '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/shots/'
437 +scrot '%Y-%m-%d_$wx$h.png' \-e 'mv $f ~/shots/'
438 .br
439 This would create a file called something like
440 2000-10-30_2560x1024.png and move it to your shots directory.