wok-current annotate scrot/stuff/scrot.patch @ rev 14274

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