This is intended to allow dumps of arbitrary sections of the root window.
Particularly, this is useful in RANDR 1.2+ multi-head setups where the root window spans all screens. By specifying the geometry of a single screen we can get a clean grab without post-cropping.
Patch is attached. Thanks -- Matt Vollrath [email protected] 423.202.0957 End Point Corporation http://www.endpoint.com
>From c851a7b1e8c817853210be85beb34c8679a004d1 Mon Sep 17 00:00:00 2001 From: Matt Vollrath <[email protected]> Date: Fri, 2 Nov 2012 17:55:12 +0000 Subject: [PATCH xwd] Translate window by -geometry This is intended to allow dumps of arbitrary sections of the root window. Signed-off-by: Matt Vollrath <[email protected]> --- xwd.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/xwd.c b/xwd.c index 5b40121..05b8a7b 100644 --- a/xwd.c +++ b/xwd.c @@ -98,11 +98,12 @@ static Bool standard_out = True; static Bool debug = False; static Bool silent = False; static Bool use_installed = False; +static char *geom = NULL; static long add_pixel_value = 0; extern int main(int, char **); -extern void Window_Dump(Window, FILE *); +extern void Window_Dump(Window, FILE *, char *); extern int Image_Size(XImage *); extern int Get_XColors(XWindowAttributes *, XColor **); extern void _swapshort(register char *, register unsigned); @@ -196,6 +197,11 @@ main(int argc, char **argv) silent = True; continue; } + if (!strcmp(argv[i], "-geometry")) { + if (++i >= argc) usage(); + geom = argv[i]; + continue; + } usage(); } #ifdef WIN32 @@ -212,7 +218,7 @@ main(int argc, char **argv) /* * Dump it! */ - Window_Dump(target_win, out_file); + Window_Dump(target_win, out_file, geom); XCloseDisplay(dpy); if (fclose(out_file)) { @@ -246,7 +252,7 @@ Get24bitDirectColors(XColor **colors) */ void -Window_Dump(Window window, FILE *out) +Window_Dump(Window window, FILE *out, char *geometry) { unsigned long swaptest = 1; XColor *colors; @@ -260,6 +266,8 @@ Window_Dump(Window window, FILE *out) XImage *image; int absx, absy, x, y; unsigned width, height; + int gbits, gx, gy; + unsigned gwidth, gheight; int dwidth, dheight; Window dummywin; XWDFileHeader header; @@ -309,6 +317,15 @@ Window_Dump(Window window, FILE *out) width = win_info.width; height = win_info.height; + /* translate geometry if provided */ + if (geometry) { + gbits = XParseGeometry( geometry, &gx, &gy, &gwidth, &gheight ); + if (gbits & XValue) absx += gx; + if (gbits & YValue) absy += gy; + if (gbits & WidthValue) width = gwidth; + if (gbits & HeightValue) height = gheight; + } + if (!nobdrs) { absx -= win_info.border_width; absy -= win_info.border_width; @@ -522,7 +539,7 @@ usage(void) fprintf (stderr, "usage: %s [-display host:dpy] [-debug] [-help] %s [-nobdrs] [-out <file>]", program_name, "[{-root|-id <id>|-name <name>}]"); - fprintf (stderr, " [-xy] [-add value] [-frame]\n"); + fprintf (stderr, " [-xy] [-add value] [-frame] [-geometry <geom>]\n"); exit(1); } -- 1.7.9.5
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
